diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index 51b6177b..0591726e 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -8031,8 +8031,22 @@ sub main { }, ); PTDEBUG && _d(scalar @$slaves, 'slaves found'); + if ( scalar @$slaves ) { + print "Found " . scalar(@$slaves) . " slaves:\n"; + foreach my $cxn ( @$slaves ) { + print " " . $cxn->name() . "\n"; + } + } + elsif ( ($o->get('recursion-method') || '') ne 'none') { + print "No slaves found. See --recursion-method if host " + . $cxn->name() . " has slaves.\n"; + } + else { + print "Ignoring all slaves because --recursion-method=none " + . "was specified\n"; + } - if ( $o->get('check-slave-lag') ) { + if ( my $dsn = $o->get('check-slave-lag') ) { PTDEBUG && _d('Will use --check-slave-lag to check for slave lag'); my $cxn = $make_cxn->( dsn_string => $o->get('check-slave-lag'), @@ -8044,6 +8058,16 @@ sub main { PTDEBUG && _d('Will check slave lag on all slaves'); $slave_lag_cxns = $slaves; } + if ( $slave_lag_cxns && scalar @$slave_lag_cxns ) { + print "Will check slave lag on:\n"; + foreach my $cxn ( @$slave_lag_cxns ) { + print " " . $cxn->name() . "\n"; + } + } + else { + print "Not checking slave lag because no slaves were found " + . "and --check-slave-lag was not specified.\n"; + } # ##################################################################### # Check for replication filters. @@ -8513,14 +8537,36 @@ sub main { } }; - for my $slave (@$slaves) { - PTDEBUG && _d('Waiting until', $slave->name(), - 'replicates the table'); - sleep 0.5 while ! $tp->check_table( - dbh => $slave->dbh(), - db => $new_tbl->{db}, - tbl => $new_tbl->{tbl} - ); + if ( $slaves && scalar @$slaves ) { + foreach my $slave (@$slaves) { + my ($pr, $pr_first_report); + if ( $o->get('progress') ) { + $pr = new Progress( + jobsize => scalar @$slaves, + spec => $o->get('progress'), + name => "Waiting for " . $slave->name(), + ); + $pr_first_report = sub { + print "Waiting forever for new table $new_tbl->{name} to replicate " + . "to " . $slave->name() . "...\n"; + }; + } + $pr->start() if $pr; + my $has_table = 0; + while ( !$has_table ) { + $has_table = $tp->check_table( + dbh => $slave->dbh(), + db => $new_tbl->{db}, + tbl => $new_tbl->{tbl} + ); + last if $has_table; + $pr->update( + sub { return 0; }, + first_report => $pr_first_report, + ) if $pr; + sleep 1; + } + } } # --plugin hook diff --git a/t/pt-online-schema-change/ansi_quotes.t b/t/pt-online-schema-change/ansi_quotes.t index 895c9b48..87aaf6cf 100644 --- a/t/pt-online-schema-change/ansi_quotes.t +++ b/t/pt-online-schema-change/ansi_quotes.t @@ -61,7 +61,7 @@ is( $exit_status, 0, "--dry-run exit 0 (bug 1058285)" -); +) or diag($output); unlike( $output, diff --git a/t/pt-online-schema-change/basics.t b/t/pt-online-schema-change/basics.t index e40dca9c..b5007157 100644 --- a/t/pt-online-schema-change/basics.t +++ b/t/pt-online-schema-change/basics.t @@ -13,6 +13,7 @@ use Test::More; use Time::HiRes qw(sleep); $ENV{PTTEST_FAKE_TS} = 1; +$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1; use PerconaTest; use Sandbox; diff --git a/t/pt-online-schema-change/charset.t b/t/pt-online-schema-change/charset.t index f786d4b0..8208aa95 100644 --- a/t/pt-online-schema-change/charset.t +++ b/t/pt-online-schema-change/charset.t @@ -56,10 +56,10 @@ $sb->load_file('master', "$sample/basic_no_fks.sql"); my @create = split("\n\n", $output); like( - $create[1], + $create[1] || '', qr/DEFAULT CHARSET=utf8/, "Can alter charset of new table" -); +) or diag($output); # ############################################################################# # Done. diff --git a/t/pt-online-schema-change/samples/stats-execute-5.5.txt b/t/pt-online-schema-change/samples/stats-execute-5.5.txt index b929241f..7b1f6f60 100644 --- a/t/pt-online-schema-change/samples/stats-execute-5.5.txt +++ b/t/pt-online-schema-change/samples/stats-execute-5.5.txt @@ -1,3 +1,9 @@ +Found 2 slaves: + h=127.0.0.1,P=12346 + h=127.0.0.1,P=12347 +Will check slave lag on: + h=127.0.0.1,P=12346 + h=127.0.0.1,P=12347 Operation, tries, wait: copy_rows, 10, 0.25 create_triggers, 10, 1 @@ -14,6 +20,7 @@ TS Dropped triggers OK. Successfully altered `bug_1045317`.`bits`. Creating new table... Created new table bug_1045317._bits_new OK. +Waiting forever for new table `bug_1045317`.`_bits_new` to replicate to h=127.0.0.1,P=12346... Altering new table... Altered `bug_1045317`.`_bits_new` OK. TS Creating triggers...