(apologies - tried to submit on Jira but I get persistent “you are not authorised” errors)
pt-table-checksum 3.7.1: SHOW REPLICAS issued against MariaDB on builds with non-default version_comment
Summary
pt-table-checksum 3.7.1 crashes with a SHOW REPLICAS syntax error against MariaDB when replica discovery falls through to the hosts recursion method. The MariaDB-flavor detection in _find_replicas_by_hosts regex-matches m/maria/i against the version_comment system variable, but distribution builds that override version_comment defeat this check. The FreeBSD ports build of MariaDB sets version_comment to FreeBSD Ports (not MariaDB Server), so detection fails and the tool issues SHOW REPLICAS — a MySQL 8.1+ statement that doesn’t exist in MariaDB.
3.5.2 was unaffected because it issued SHOW SLAVE HOSTS unconditionally.
Affected versions
- pt-table-checksum 3.7.1 (3.7.0 likely also affected)
- Not present in 3.5.2
Environment
- MariaDB 10.11.16 (
mariadb1011-serverfrom FreeBSD ports) - FreeBSD 14.3
- percona-toolkit 3.7.1 from FreeBSD ports
version=10.11.16-MariaDB-logversion_comment=FreeBSD Ports
Reproduction
On a master with at least one connected replica, against a MariaDB build whose version_comment does not contain the string “MariaDB”:
$ mysql -e "SHOW VARIABLES LIKE 'version%'"
+-------------------------+----------------------+
| Variable_name | Value |
+-------------------------+----------------------+
| version | 10.11.16-MariaDB-log |
| version_comment | FreeBSD Ports |
...
$ pt-table-checksum --replicate-check-only
DBD::mysql::db selectall_arrayref failed: You have an error in your SQL
syntax; check the manual that corresponds to your MariaDB server version
for the right syntax to use near 'REPLICAS' at line 1
[for Statement "SHOW REPLICAS"]
at /usr/local/bin/pt-table-checksum line 5463.
Observed behaviour
Crash with SHOW REPLICAS syntax error from the leaf-level replica during recursive discovery.
Expected behaviour
The tool should detect the server as MariaDB and issue SHOW SLAVE HOSTS.
Root cause
In _find_replicas_by_hosts (bin/pt-table-checksum, around line 5449 in v3.7.1):
my $vp = VersionParser->new($dbh);
my $sql = 'SHOW REPLICAS';
my $source_name = 'source';
if ( $vp lt '8.1' || $vp->flavor() =~ m/maria/i ) {
$sql = 'SHOW SLAVE HOSTS';
$source_name='master';
}
VersionParser::BUILDARGS populates flavor from the version_comment MySQL variable. Detection therefore only succeeds for builds that include “MariaDB” in version_comment — typically MariaDB Server from upstream. Any downstream build that overrides version_comment (FreeBSD ports uses FreeBSD Ports; other distributions/vendors may do similar) fails the regex even though the server is unambiguously MariaDB.
Two things make the bug worse in practice:
- The
versionvariable (10.11.16-MariaDB-log) reliably contains the stringMariaDBregardless of distribution branding, but it isn’t consulted. - Level-0 replica discovery uses
processlistby default and succeeds, hiding the bug from casual inspection.pt-table-checksumthen recurses into each discovered replica looking for further replicas; at the leaf levelprocesslistreturns empty and the tool falls through to thehostsmethod, which is where the crash occurs. On a two-node topology (one master, one replica) the recursion into the replica is what trips the bug; users on this topology may believehostsis never used.
Suggested fix
Also test the version string for “MariaDB”:
my $vp = VersionParser->new($dbh);
my $sql = 'SHOW REPLICAS';
my $source_name = 'source';
- if ( $vp lt '8.1' || $vp->flavor() =~ m/maria/i ) {
+ if ( $vp lt '8.1'
+ || $vp->flavor() =~ m/maria/i
+ || $vp->version() =~ m/maria/i ) {
$sql = 'SHOW SLAVE HOSTS';
$source_name='master';
}
version is server-side and reliable across distribution rebrands. The same gap likely exists in other tools that use VersionParser->flavor() for MariaDB detection; a more thorough fix would be to make VersionParser itself fall back to version when version_comment doesn’t disambiguate.
Workaround
Pass --recursion-method=processlist so that _find_replicas_by_hosts is never reached. Documented behaviour of this option already calls out that hosts-based discovery is unreliable, but the failure mode in this case is a hard crash rather than missed replicas.