Script pt-online-schema-change set new_table_name for all records in history table

I execute multiple jobs and found in history table pt_osc_history all records with one value in new_table_name field.

In script I see:

$ tail -n +9797 pt-online-schema-change | head -n 6
   if ( $o->get('history') ) {
      my $sth = $cxn->dbh()->prepare(
         "UPDATE ${hist_table} SET new_table_name = ?"
      );
      $sth->execute($new_tbl->{tbl});
   }

Update operation set one value for all recors. This is not corrected. Or corrected?

Hi @infis,

You are right, this is a bug. The UPDATE has no WHERE, so every new job overwrites new_table_name for all rows in the history table.

It’s already fixed in PT-2422, the UPDATE now has WHERE job_id = ?. The fix is in Percona Toolkit 3.7.0-2 and newer, so I believe you run 3.7.0 or older ( the line number you quoted matches 3.7.0 ). Please check with:

pt-online-schema-change --version

After the upgrade only new jobs get the right value, the old rows in pt_osc_history stay as they are, so the fix will not clean them.

https://perconadev.atlassian.net/browse/PT-2422