From 730ff40b564d4280aea9ef53a6a6a32732d683ce Mon Sep 17 00:00:00 2001 From: Martin Amps Date: Tue, 16 Jul 2019 17:18:45 -0700 Subject: [PATCH] Backwards compatibility fix for super_read_only --- lib/MHA/SlaveUtil.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/MHA/SlaveUtil.pm b/lib/MHA/SlaveUtil.pm index d395a34..2e6ae34 100644 --- a/lib/MHA/SlaveUtil.pm +++ b/lib/MHA/SlaveUtil.pm @@ -177,6 +177,15 @@ sub is_mariadb($) { return 0; } +sub is_perconadb($) { + my $version_str = shift; + if ($version_str =~ m/.*Percona.*/i) + { + return 1; + } + return 0; +} + sub get_advisory_lock_internal($$$) { my $dbh = shift; my $timeout = shift; @@ -241,6 +250,13 @@ sub check_if_super_read_only { { PrintError => 0, RaiseError => 1 } ); croak "Failed to get DB Handle to check super_read_only on $host:$port!\n" unless ($dbh); + # Added in Percona 5.6.21, standard 5.7.8 + my $mysql_version = get_version($dbh); + my $target_version = is_perconadb($mysql_version) ? "5.6.21" : "5.7.8"; + if (! MHA::NodeUtil::mysql_version_ge( $mysql_version, $target_version ) ) { + return (0, 0); + } + my $sth = $dbh->prepare("SELECT \@\@global.super_read_only as Value"); $sth->execute(); my $href = $sth->fetchrow_hashref;