From 2e38f936a65ba0a360553c90dc3916d7e15b32f5 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Wed, 15 Aug 2012 13:26:13 -0300 Subject: [PATCH 1/3] Silence rollback warnings in t/lib/DSNParser.t --- t/lib/DSNParser.t | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/t/lib/DSNParser.t b/t/lib/DSNParser.t index 91c28cc5..179317a2 100644 --- a/t/lib/DSNParser.t +++ b/t/lib/DSNParser.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 37; +use Test::More; use DSNParser; use OptionParser; @@ -545,6 +545,9 @@ foreach my $password_comma ( @password_commas ) { # ############################################################################# # Bug 984915: SQL calls after creating the dbh aren't checked # ############################################################################# +# Make sure to disconnect any lingering dbhs, since full_output will fork +# and then die, which will cause rollback warnings for connected dbhs. +$dbh->disconnect() if $dbh; $dsn = $dp->parse('h=127.1,P=12345,u=msandbox,p=msandbox'); my @opts = $dp->get_cxn_params($dsn); @@ -569,5 +572,4 @@ like( # ############################################################################# # Done. # ############################################################################# -$dbh->disconnect() if $dbh; -exit; +done_testing; From d2b854cd9dceff42075a17ea526aa3e80c023ba3 Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Wed, 15 Aug 2012 14:00:52 -0300 Subject: [PATCH 2/3] CleanupTask: Restore STDERR and STDOUT to what they were when the object was created --- bin/pt-online-schema-change | 8 ++++++++ lib/CleanupTask.pm | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index f76ac8b7..04fd3907 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -5637,6 +5637,10 @@ sub new { my $self = { task => $task, }; + open $self->{stdout_copy}, ">&=", *STDOUT + or die "Cannot dup stdout: $OS_ERROR"; + open $self->{stderr_copy}, ">&=", *STDERR + or die "Cannot dup stderr: $OS_ERROR"; PTDEBUG && _d('Created cleanup task', $task); return bless $self, $class; } @@ -5646,6 +5650,10 @@ sub DESTROY { my $task = $self->{task}; if ( ref $task ) { PTDEBUG && _d('Calling cleanup task', $task); + open local *STDOUT, ">&=", $self->{stdout_copy} + if $self->{stdout_copy}; + open local *STDERR, ">&=", $self->{stderr_copy} + if $self->{stderr_copy}; $task->(); } else { diff --git a/lib/CleanupTask.pm b/lib/CleanupTask.pm index dcc2a56d..f6ab0489 100644 --- a/lib/CleanupTask.pm +++ b/lib/CleanupTask.pm @@ -42,6 +42,10 @@ sub new { my $self = { task => $task, }; + open $self->{stdout_copy}, ">&=", *STDOUT + or die "Cannot dup stdout: $OS_ERROR"; + open $self->{stderr_copy}, ">&=", *STDERR + or die "Cannot dup stderr: $OS_ERROR"; PTDEBUG && _d('Created cleanup task', $task); return bless $self, $class; } @@ -51,6 +55,12 @@ sub DESTROY { my $task = $self->{task}; if ( ref $task ) { PTDEBUG && _d('Calling cleanup task', $task); + # Temporarily restore STDOUT and STDERR to what they were + # when the object was created + open local *STDOUT, ">&=", $self->{stdout_copy} + if $self->{stdout_copy}; + open local *STDERR, ">&=", $self->{stderr_copy} + if $self->{stderr_copy}; $task->(); } else { From 69522341275dad47ff048eae1f30eecfee6ace2f Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Wed, 15 Aug 2012 14:33:04 -0300 Subject: [PATCH 3/3] t/pt-archiver/basics.t: Skip some --bulk-insert tests if LOCAL INFILE is disabled --- t/pt-archiver/basics.t | 91 +++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 46 deletions(-) diff --git a/t/pt-archiver/basics.t b/t/pt-archiver/basics.t index 364c325e..b3c6c5d8 100644 --- a/t/pt-archiver/basics.t +++ b/t/pt-archiver/basics.t @@ -28,9 +28,6 @@ if ( !$master_dbh ) { elsif ( !$slave1_dbh ) { plan skip_all => 'Cannot connect to sandbox slave1'; } -else { - plan tests => 29; -} my $output; my $rows; @@ -188,55 +185,57 @@ cmp_ok( # ############################################################################# # Bug 903387: pt-archiver doesn't honor b=1 flag to create SQL_LOG_BIN statement # ############################################################################# +SKIP: { + skip('LOAD DATA LOCAL INFILE is disabled', 3) if !$can_load_data; + $sb->load_file('master', "t/pt-archiver/samples/bulk_regular_insert.sql"); + $sb->wait_for_slaves(); -$sb->load_file('master', "t/pt-archiver/samples/bulk_regular_insert.sql"); -$sb->wait_for_slaves(); + my $original_rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); + is_deeply( + $original_rows, + [ + [1, 'aa', '11:11:11'], + [2, 'bb', '11:11:12'], + [3, 'cc', '11:11:13'], + [4, 'dd', '11:11:14'], + [5, 'ee', '11:11:15'], + [6, 'ff', '11:11:16'], + [7, 'gg', '11:11:17'], + [8, 'hh', '11:11:18'], + [9, 'ii', '11:11:19'], + [10,'jj', '11:11:10'], + ], + "Bug 903387: slave has rows" + ); -my $original_rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); -is_deeply( - $original_rows, - [ - [1, 'aa', '11:11:11'], - [2, 'bb', '11:11:12'], - [3, 'cc', '11:11:13'], - [4, 'dd', '11:11:14'], - [5, 'ee', '11:11:15'], - [6, 'ff', '11:11:16'], - [7, 'gg', '11:11:17'], - [8, 'hh', '11:11:18'], - [9, 'ii', '11:11:19'], - [10,'jj', '11:11:10'], - ], - "Bug 903387: slave has rows" -); + $output = output( + sub { pt_archiver::main( + '--source', "D=bri,t=t,F=$cnf,b=1", + '--dest', "D=bri,t=t_arch", + qw(--where 1=1 --replace --commit-each --bulk-insert --bulk-delete), + qw(--limit 10)) }, + ); -$output = output( - sub { pt_archiver::main( - '--source', "D=bri,t=t,F=$cnf,b=1", - '--dest', "D=bri,t=t_arch", - qw(--where 1=1 --replace --commit-each --bulk-insert --bulk-delete), - qw(--limit 10)) }, -); - -$rows = $master_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); -is_deeply( - $rows, - [ - [10,'jj', '11:11:10'], - ], - "Bug 903387: rows deleted on master" -) or diag(Dumper($rows)); - -$rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); -is_deeply( - $rows, - $original_rows, - "Bug 903387: slave still has rows" -) or diag(Dumper($rows)); + $rows = $master_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); + is_deeply( + $rows, + [ + [10,'jj', '11:11:10'], + ], + "Bug 903387: rows deleted on master" + ) or diag(Dumper($rows)); + $rows = $slave1_dbh->selectall_arrayref("SELECT * FROM bri.t ORDER BY id"); + is_deeply( + $rows, + $original_rows, + "Bug 903387: slave still has rows" + ) or diag(Dumper($rows)); +} # ############################################################################# # Done. # ############################################################################# $sb->wipe_clean($master_dbh); ok($sb->ok(), "Sandbox servers") or BAIL_OUT(__FILE__ . " broke the sandbox"); -exit; + +done_testing;