From d1404d129fad758559a4c2424772fbb5837283c0 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Wed, 10 May 2017 11:50:25 -0300 Subject: [PATCH] WIP --- bin/pt-table-sync | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 197cb31f..43e5e446 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -6943,7 +6943,36 @@ sub get_slave_status { ||= $dbh->prepare('SHOW SLAVE STATUS'); PTDEBUG && _d($dbh, 'SHOW SLAVE STATUS'); $sth->execute(); - my ($ss) = @{$sth->fetchall_arrayref({})}; + my ($sss_rows) = $sth->fetchall_arrayref({}); # Show Slave Status rows + + warn ">>>>===================================================================================================="; + warn Data::Dumper::Dumper($sss_rows); + warn ">>>>===================================================================================================="; + # If SHOW SLAVE STATUS returns more than one row it means that this slave is connected to more + # than one master using replication channels. + # If we have a channel name as a parameter, we need to select the correct row and return it. + # If we don't have a channel name as a parameter, there is no way to know what the correct master is so, + # return an error. + my $ss; + $self->{channel} = 'masterchan2'; + if ( $sss_rows && @$sss_rows && scalar @$sss_rows > 1) { + warn "KKKKKKKKKKKKKKKKKK"; + if (!$self->{channel}) { + warn 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; + $self->{not_a_slave}->{$dbh}++; + return; + } + for my $row (@$sss_rows) { + if ($row->{Channel_Name} eq $self->{channel}) { + $ss = $row; + last; + } + } + } else { + warn "MMMMMMMMMMMMMMMMMMMMMMMMM"; + $ss = $sss_rows->[0]; + } + if ( $ss && %$ss ) { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys @@ -6996,10 +7025,16 @@ sub wait_for_master { . "$master_status->{position}, $timeout)"; PTDEBUG && _d($slave_dbh, $sql); my $start = time; - ($result) = $slave_dbh->selectrow_array($sql); + $result = $slave_dbh->selectrow_array($sql); + warn ">>>"; + warn Data::Dumper::Dumper($result); $waited = time - $start; + warn "===================================================================================================="; + warn "slave_dbh $slave_dbh"; + warn Data::Dumper::Dumper($slave_dbh); + warn Data::Dumper::Dumper($master_status); PTDEBUG && _d('Result of waiting:', $result); PTDEBUG && _d("Waited", $waited, "seconds"); }