pt-table-checksum should always create schema and tables with IF NOT EXISTS

Bug #950294 reported by Alfie John
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to https://jira.percona.com/projects/PT
Fix Released
Medium
Brian Fraser

Bug Description

When pt-table-checksum is run on a master which already has the percona schema, the following won't be run:

   - CREATE DATABASE percona
   - CREATE TABLE dsns
   - CREATE TABLE checksums

However if a slave doesn't have the schema, replication will break with "Table 'percona.checksums' doesn't exist".

If by default the schema is always created when checksumming, then we guarantee that the schema will be everywhere and replication is happy.

Note that this will need to happen along with (https://bugs.launchpad.net/percona-toolkit/+bug/950290) seeing as the above queries need an IF NOT EXISTS to make sure we don't run into other problems.

On a further note, Baron mentioned that some people might not want to, or not even be able to create the schema given restricted privileges. I don't think this is an issue seeing as --nocreate-replicate-table exists. It might just need to be documented.

Related branches

Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

Confirmed. In check_repl_table():

   # If the repl db doesn't exit, auto-create it, maybe.
   my ($db, $tbl) = $q->split_unquote($repl_table);
   my $sql = "SHOW DATABASES LIKE '$db'";
   ...
   if ( !$tbl_exists ) {
      if ( $o->get('create-replicate-table') ) {
         create_repl_table(%args)
      }

tags: added: breaks-replication pt-table-checksum
Changed in percona-toolkit:
status: New → Confirmed
importance: Undecided → Medium
Changed in percona-toolkit:
milestone: none → 2.1.3
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

In summary: right now ptc does not create dbs/tables if they already exist, which is a problem if they don't exit on slaves. So it needs to "always" create them, unless --no-create-replicate-table. Furthermore, when it does create dbs/tables, it must use IF NOT EXISTS so the reverse case won't cause an error: master doesn't have the db/tables but the slaves do.

summary: - pt-table-checksum should create the percona schema by default
+ pt-table-checksum should create schema and tables with IF NOT EXISTS
summary: - pt-table-checksum should create schema and tables with IF NOT EXISTS
+ pt-table-checksum should always create schema and tables with IF NOT
+ EXISTS
Brian Fraser (fraserbn)
Changed in percona-toolkit:
assignee: nobody → Brian Fraser (fraserbn)
Brian Fraser (fraserbn)
Changed in percona-toolkit:
status: Confirmed → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released
Revision history for this message
Mike Warner (mwarner) wrote :

I don't see this as fixed. I installed the toolkit this AM and the fact that the slave didn't have test.checksum killed my replication. Now I get the fun of fixing it.

Could it be that this was fixed but not really merged with the toolkit release code or got clobbered by someone else's changes?

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-495

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

Duplicates of this bug

Other bug subscribers

Remote bug watches

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