Merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-does-not-work-with-sql_mode-ONLY_FULL_GROUP_BY-1019479 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 612
Merged at revision: 620
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-does-not-work-with-sql_mode-ONLY_FULL_GROUP_BY-1019479
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.13
Diff against target: 67 lines (+39/-0)
2 files modified
bin/pt-table-checksum (+20/-0)
t/pt-table-checksum/basics.t (+19/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-table-checksum-does-not-work-with-sql_mode-ONLY_FULL_GROUP_BY-1019479
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+245681@code.launchpad.net

Description of the change

Problem:
pt-table-checksum fails when the sql_mode ONLY_FULL_GROUP_BY is set, even though the query that fails is deterministic.

Solution:
disable this mode during the session. (leave all other modes on)

Notes:
- tried to modify the query to comply, but it is dynamically generated on the fly according to different parameters so a solution along these lines was either not elegant or not efficient.

- important issue to fix for upcoming 5.7 version since this sql_mode will be on by default.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/pt-table-checksum'
--- bin/pt-table-checksum 2014-11-11 13:28:27 +0000
+++ bin/pt-table-checksum 2015-01-06 18:03:52 +0000
@@ -9131,6 +9131,26 @@
9131 return if $o->get('explain');9131 return if $o->get('explain');
9132 my $sql;9132 my $sql;
91339133
9134 # https://bugs.launchpad.net/percona-toolkit/+bug/1019479
9135 # sql_mode ONLY_FULL_GROUP_BY often raises error even when query is
9136 # safe and deterministic. It's best to turn it off for the session
9137 # at this point.
9138 $sql = 'SELECT @@SQL_MODE';
9139 PTDEBUG && _d($dbh, $sql);
9140 my ($sql_mode) = eval { $dbh->selectrow_array($sql) };
9141 if ( $EVAL_ERROR ) {
9142 die "Error getting the current SQL_MODE: $EVAL_ERROR";
9143 }
9144 $sql_mode =~ s/ONLY_FULL_GROUP_BY//i;
9145 $sql = qq[SET SQL_MODE='$sql_mode'];
9146 PTDEBUG && _d($dbh, $sql);
9147 eval { $dbh->do($sql) };
9148 if ( $EVAL_ERROR ) {
9149 die "Error setting SQL_MODE"
9150 . ": $EVAL_ERROR";
9151 }
9152
9153
9134 # https://bugs.launchpad.net/percona-toolkit/+bug/9193529154 # https://bugs.launchpad.net/percona-toolkit/+bug/919352
9135 # The tool shouldn't blindly attempt to change binlog_format;9155 # The tool shouldn't blindly attempt to change binlog_format;
9136 # instead, it should check if it's already set to STATEMENT.9156 # instead, it should check if it's already set to STATEMENT.
91379157
=== modified file 't/pt-table-checksum/basics.t'
--- t/pt-table-checksum/basics.t 2014-08-05 19:51:34 +0000
+++ t/pt-table-checksum/basics.t 2015-01-06 18:03:52 +0000
@@ -56,6 +56,7 @@
56 $master_dbh->do("use $repl_db");56 $master_dbh->do("use $repl_db");
57}57}
5858
59
59# ############################################################################60# ############################################################################
60# Default checksum and results. The tool does not technically require any61# Default checksum and results. The tool does not technically require any
61# options on well-configured systems (which the test env cannot be). With62# options on well-configured systems (which the test env cannot be). With
@@ -509,6 +510,24 @@
509);510);
510511
511# #############################################################################512# #############################################################################
513# Bug 1019479: does not work with sql_mode ONLY_FULL_GROUP_BY
514# #############################################################################
515
516# add a couple more modes to test that commas don't affect setting
517$master_dbh->do("SET sql_mode = 'NO_ZERO_DATE,ONLY_FULL_GROUP_BY,STRICT_ALL_TABLES'");
518
519# force chunk-size because bug doesn't show up if table done in one chunk
520$exit_status = pt_table_checksum::main(@args,
521 qw(--quiet --quiet -t sakila.actor --chunk-size=50));
522
523is(
524 $exit_status,
525 0,
526 "sql_mode ONLY_FULL_GROUP_BY is overidden"
527);
528
529
530# #############################################################################
512# Done.531# Done.
513# #############################################################################532# #############################################################################
514$sb->wipe_clean($master_dbh);533$sb->wipe_clean($master_dbh);

Subscribers

People subscribed via source and target branches

to all changes: