diff --git a/bin/pt-archiver b/bin/pt-archiver index 7706a6f2..80570d94 100755 --- a/bin/pt-archiver +++ b/bin/pt-archiver @@ -3916,13 +3916,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -3935,6 +3942,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-heartbeat b/bin/pt-heartbeat index f3c78632..62a66242 100755 --- a/bin/pt-heartbeat +++ b/bin/pt-heartbeat @@ -465,13 +465,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -484,6 +491,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-kill b/bin/pt-kill index 17e81823..9f589f2b 100755 --- a/bin/pt-kill +++ b/bin/pt-kill @@ -4197,13 +4197,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -4216,6 +4223,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-online-schema-change b/bin/pt-online-schema-change index c4799a0c..71782bf1 100755 --- a/bin/pt-online-schema-change +++ b/bin/pt-online-schema-change @@ -4522,6 +4522,9 @@ sub get_slave_status { my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; @@ -4531,7 +4534,7 @@ sub get_slave_status { die 'This server is using replication channels but "channel" was not specified on the command line'; } } else { - if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne ($self->{channel} || '')) { + if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; } else { $ss = $sss_rows->[0]; @@ -4542,11 +4545,14 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); $self->{not_a_slave}->{$dbh}++; - } + } } sub get_master_status { diff --git a/bin/pt-query-digest b/bin/pt-query-digest index fb9535dc..8a9d0f9e 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -10845,13 +10845,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -10864,6 +10871,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-slave-find b/bin/pt-slave-find index d6c70920..19cf565c 100755 --- a/bin/pt-slave-find +++ b/bin/pt-slave-find @@ -2605,13 +2605,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -2624,6 +2631,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-slave-restart b/bin/pt-slave-restart index 7739da7e..90f306ee 100755 --- a/bin/pt-slave-restart +++ b/bin/pt-slave-restart @@ -3016,13 +3016,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -3035,6 +3042,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 25f37966..cffd5060 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -5469,13 +5469,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -5488,6 +5495,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 9b22be46..2b089703 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -6999,13 +6999,20 @@ sub get_slave_status { if (!$self->{channel}) { die 'This server returned more than one row for SHOW SLAVE STATUS but "channel" was not specified on the command line'; } + my $slave_use_channels; for my $row (@$sss_rows) { $row = { map { lc($_) => $row->{$_} } keys %$row }; # lowercase the keys + if ($row->{channel_name}) { + $slave_use_channels = 1; + } if ($row->{channel_name} eq $self->{channel}) { $ss = $row; last; } } + if (!$ss && $slave_use_channels) { + die 'This server is using replication channels but "channel" was not specified on the command line'; + } } else { if ($sss_rows->[0]->{channel_name} && $sss_rows->[0]->{channel_name} ne $self->{channel}) { die 'This server is using replication channels but "channel" was not specified on the command line'; @@ -7018,6 +7025,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS'); diff --git a/lib/DSNParser.pm b/lib/DSNParser.pm index c6f20788..88c26906 100644 --- a/lib/DSNParser.pm +++ b/lib/DSNParser.pm @@ -175,16 +175,6 @@ sub parse { } } - # The Perl MySQL driver will override the values from the options file with the other - # values specified in the DSN. For us, if the user specified the F parameter, we only - # want options to be loaded from the config file. - # This is important because if for example, the user specifies F for the --check-slave-lag - # paramteter and we don't clean up the other options, the other DSN parameters will be - # inherited from the master and we don't want that. - if ($final_props{F}) { - %final_props = ( 'F' => $final_props{F} ); - } - return \%final_props; } diff --git a/lib/MasterSlave.pm b/lib/MasterSlave.pm index 0714601c..06286268 100644 --- a/lib/MasterSlave.pm +++ b/lib/MasterSlave.pm @@ -475,6 +475,9 @@ sub get_slave_status { $ss = { map { lc($_) => $ss->{$_} } keys %$ss }; # lowercase the keys return $ss; } + if (!$ss && $self->{channel}) { + die "Specified channel name is invalid"; + } } PTDEBUG && _d('This server returns nothing for SHOW SLAVE STATUS');