pt-table-checksum doesn't set USE database before deleting from checksums table

Bug #1372785 reported by bwitt
8
This bug affects 1 person
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-rel63.0-519.precise on Ubuntu precise (12.04).
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-ignore-db=db1
Master2 has replicate-ignore-db=db2

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/pt-table-checksum --defaults-file /etc/mysql_checksums.cnf --nocheck-replication-filters --recurse 1 --replicate mon.checksums --databases db2 --ignore-databases mysql --no-check-binlog-format --nocheck-plan --chunk-size-limit=4 --noreplicate-check

(on master2)
/usr/bin/pt-table-checksum --defaults-file /etc/mysql_checksums.cnf --nocheck-replication-filters --recurse 1 --replicate mon.checksums --databases db1 --ignore-databases mysql --no-check-binlog-format --nocheck-plan --chunk-size-limit=4 --noreplicate-check

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.

Revision history for this message
bwitt (brianwitt) wrote :
Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :

nilnandan@Dell-XPS:~$ pt-table-checksum --version
pt-table-checksum 2.2.11
nilnandan@Dell-XPS:~$

           if ( $oktonibble && $o->get('empty-replicate-table') ) {
               use_repl_db(
                  dbh => $master_cxn->dbh(),
                  repl_table => $repl_table,
                  OptionParser => $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"
            # db is a complicated subject; see sub for comments.
            use_repl_db(
               dbh => $master_cxn->dbh(),
               tbl => $tbl, # XXX working on this table
               repl_table => $repl_table,
               OptionParser => $o,
               Quoter => $q,
            );
            # #########################################################
            # XXX DO NOT CHANGE THE DB UNTIL THIS TABLE IS FINISHED XXX
            # #########################################################

Changed in percona-toolkit:
status: New → Confirmed
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PT-1244

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.