pt-online-schema-change doesn't retry RENAME TABLE

Bug #1093016 reported by Fernando Ipar on 2012-12-21
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Percona Toolkit moved to
Fix Released
Daniel Nichter

Bug Description

Not sure if this is a bug or a feature request, but with this table:

mysql [localhost] {msandbox} (test) > show create table test2\G
*************************** 1. row ***************************
       Table: test2
Create Table: CREATE TABLE `test2` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `c` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
1 row in set (0.00 sec)

And this invocation of pt-osc:

bash-3.2$ ./pt-online-schema-change --alter "add index idx_c (c)" --execute h=,P=5527,u=msandbox,p=msandbox,D=test,t=test2 2>&1 | tee pt-osc.log

if rows from test.test2 are locked before the RENAME TABLE operation, then the tool will wait for lock_wait_timeout time (makes sense) and then fail, dropping the new table. This is not good if the table is very large. I think a good alternative would be to have an option to make the tool fail as it does, but not removing the new table or the triggers, so that the rename can be retried, at least manually.

To lock the table for this specific test case, I just ran:

begin; select * from test2 limit 1 for update;

before the rename table operation (I populated the table with enough rows that the copy process takes a few seconds).

I am attaching pt-osc.log, which is the output of the full run when using PTDEBUG enabled.

Related branches

Fernando Ipar (fipar) wrote :
Daniel Nichter (daniel-nichter) wrote :

It's a bug: the tool doesn't retry the RENAME or the DROP TRIGGER statements like to does SQL statements to copy rows. The same retry and error handling for those SQL statements should be applied to the RENAME and DROP TRIGGER statements.

tags: added: pt-online-schema-change
Changed in percona-toolkit:
status: New → Triaged
summary: - If pt-osc fails due to a lock wait timeout at the rename table phase,
- the new table is dropped.
+ pt-online-schema-change doesn't retry RENAME TABLE
Daniel Nichter (daniel-nichter) wrote :

Fixed in 2.2.1. See bug 1113301.

Changed in percona-toolkit:
status: Triaged → In Progress
assignee: nobody → Daniel Nichter (daniel-nichter)
importance: Undecided → High
Changed in percona-toolkit:
milestone: none → 2.2.1
Changed in percona-toolkit:
status: In Progress → Fix Committed
Changed in percona-toolkit:
status: Fix Committed → Fix Released

Percona now uses JIRA for bug reports so this bug report is migrated to:

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

Other bug subscribers