Skip to content

Commit 0271ba6

Browse files
committed
Turn off statement based binlog checks
For RDS we use row based replication however `pt-table-checksum` wants to enforce statement and despite passing in the `--no-check-binlog-format` flag, it would still run it (even though the documentation suggests[1] it shouldn't). This appears to be a bug because there is another binlog format check that is wrapped in `$o->get('check-binlog-format')` slightly further down. To resolve this, I've updated the remaining binlog format check in the same expression as the one below and it now honours the `--no-check-binlog-format` as expected. [1]: https://www.percona.com/doc/percona-toolkit/3.0/pt-table-checksum.html#cmdoption-pt-table-checksum--[no]check-binlog-format
1 parent 7b0d02b commit 0271ba6

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

bin/pt-table-checksum

+29-28
Original file line numberDiff line numberDiff line change
@@ -9272,35 +9272,36 @@ sub main {
92729272
die "Error setting SQL_MODE"
92739273
. ": $EVAL_ERROR";
92749274
}
9275-
92769275

9277-
# https://bugs.launchpad.net/percona-toolkit/+bug/919352
9278-
# The tool shouldn't blindly attempt to change binlog_format;
9279-
# instead, it should check if it's already set to STATEMENT.
9280-
# This is becase starting with MySQL 5.1.29, changing the format
9281-
# requires a SUPER user.
9282-
if ( VersionParser->new($dbh) >= '5.1.5' ) {
9283-
$sql = 'SELECT @@binlog_format';
9284-
PTDEBUG && _d($dbh, $sql);
9285-
my ($original_binlog_format) = $dbh->selectrow_array($sql);
9286-
PTDEBUG && _d('Original binlog_format:', $original_binlog_format);
9287-
if ( $original_binlog_format !~ /STATEMENT/i ) {
9288-
$sql = q{/*!50108 SET @@binlog_format := 'STATEMENT'*/};
9289-
eval {
9290-
PTDEBUG && _d($dbh, $sql);
9291-
$dbh->do($sql);
9292-
};
9293-
if ( $EVAL_ERROR ) {
9294-
die "Failed to $sql: $EVAL_ERROR\n"
9295-
. "This tool requires binlog_format=STATEMENT, "
9296-
. "but the current binlog_format is set to "
9297-
."$original_binlog_format and an error occurred while "
9298-
. "attempting to change it. If running MySQL 5.1.29 or newer, "
9299-
. "setting binlog_format requires the SUPER privilege. "
9300-
. "You will need to manually set binlog_format to 'STATEMENT' "
9301-
. "before running this tool.\n";
9302-
}
9303-
}
9276+
if ( $o->get('check-binlog-format') ) {
9277+
# https://bugs.launchpad.net/percona-toolkit/+bug/919352
9278+
# The tool shouldn't blindly attempt to change binlog_format;
9279+
# instead, it should check if it's already set to STATEMENT.
9280+
# This is becase starting with MySQL 5.1.29, changing the format
9281+
# requires a SUPER user.
9282+
if ( VersionParser->new($dbh) >= '5.1.5' ) {
9283+
$sql = 'SELECT @@binlog_format';
9284+
PTDEBUG && _d($dbh, $sql);
9285+
my ($original_binlog_format) = $dbh->selectrow_array($sql);
9286+
PTDEBUG && _d('Original binlog_format:', $original_binlog_format);
9287+
if ( $original_binlog_format !~ /STATEMENT/i ) {
9288+
$sql = q{/*!50108 SET @@binlog_format := 'STATEMENT'*/};
9289+
eval {
9290+
PTDEBUG && _d($dbh, $sql);
9291+
$dbh->do($sql);
9292+
};
9293+
if ( $EVAL_ERROR ) {
9294+
die "Failed to $sql: $EVAL_ERROR\n"
9295+
. "This tool requires binlog_format=STATEMENT, "
9296+
. "but the current binlog_format is set to "
9297+
."$original_binlog_format and an error occurred while "
9298+
. "attempting to change it. If running MySQL 5.1.29 or newer, "
9299+
. "setting binlog_format requires the SUPER privilege. "
9300+
. "You will need to manually set binlog_format to 'STATEMENT' "
9301+
. "before running this tool.\n";
9302+
}
9303+
}
9304+
}
93049305
}
93059306

93069307
# Set transaction isolation level. We set binlog_format to STATEMENT,

0 commit comments

Comments
 (0)