Merge fix-pt-osc-find-new-table-bug-1195628.

This commit is contained in:
Daniel Nichter
2013-12-10 20:47:29 -08:00
5 changed files with 63 additions and 13 deletions

View File

@@ -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

View File

@@ -61,7 +61,7 @@ is(
$exit_status,
0,
"--dry-run exit 0 (bug 1058285)"
);
) or diag($output);
unlike(
$output,

View File

@@ -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;
@@ -704,7 +705,8 @@ ok(
no_diff(
sub { pt_online_schema_change::main(@args, "$dsn,D=bug_1045317,t=bits",
'--execute', '--statistics',
'--alter', "modify column val ENUM('M','E','H') NOT NULL")
'--alter', "modify column val ENUM('M','E','H') NOT NULL",
'--recursion-method', 'none')
},
($sandbox_version ge '5.5' && $db_flavor !~ m/XtraDB Cluster/
? "$sample/stats-execute-5.5.txt"

View File

@@ -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.

View File

@@ -1,3 +1,5 @@
No slaves found. See --recursion-method if host h=127.1,P=12345 has slaves.
Not checking slave lag because no slaves were found and --check-slave-lag was not specified.
Operation, tries, wait:
copy_rows, 10, 0.25
create_triggers, 10, 1