pt-table-checksum doesn't set USE database before deleting from checksums table
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Running percona server 5.6.15-
Mixed mode replication on all hosts
percona toolkit 2.2.10
Replication set up thus:
Master1 <-> Master2
(with slaves connected to each)
Master1 has replicate-
Master2 has replicate-
New rows are inserted in db1 on master1 and into db2 on master2. db1 is replicated to master2 and then to each of its slaves. db2 is replicated to master1 and then to each slave. In order to work around bug 899415 with mysql replicas not respecting the binlog format change to statement, I'm running pt-table-checksum on each master, checking db1 and db2 on both master1 and master2, both into a table called mon.checksums:
(on master1)
/usr/bin/
(on master2)
/usr/bin/
The problem is that pt-table-checksum is setting the USE db to mon before doing the delete from mon.checksums where tbl=db1 (on master2 for instance) so that the delete gets replicated to master1's mon.checksums table. The rest of the checksum generating queries correctly set the USE db to the db of the table being checked (db1 in this instance).
I've attached a patch which fixes this by passing tbl => $tbl, into the use_repl_db call immediately before the delete.
nilnandan@ Dell-XPS: ~$ pt-table-checksum --version Dell-XPS: ~$
pt-table-checksum 2.2.11
nilnandan@
if ( $oktonibble && $o->get( 'empty- replicate- table') ) {
use_repl_ db(
dbh => $master_cxn->dbh(),
repl_ table => $repl_table,
OptionParse r => $o,
Quoter => $q,
PTDEBUG && _d($delete_ sth->{Statement });
$delete_ sth->execute( $tbl->{ db}, $tbl->{tbl});
);
}
# USE the correct db while checksumming this table. The "correct"
use_ repl_db(
repl_table => $repl_table,
OptionParser => $o,
Quoter => $q, ####### ####### ####### ####### ####### ####### ####### # ####### ####### ####### ####### ####### ####### ####### #
# db is a complicated subject; see sub for comments.
dbh => $master_cxn->dbh(),
tbl => $tbl, # XXX working on this table
);
# #######
# XXX DO NOT CHANGE THE DB UNTIL THIS TABLE IS FINISHED XXX
# #######