pt-online-schema-change is not able to modify more than one time a table with constraint
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Toolkit moved to https://jira.percona.com/projects/PT |
Invalid
|
Medium
|
Frank Cizmich |
Bug Description
versions tested: 2.2.1 and 2.2.4
When a table with constraint is modified via pt-osc, it cannot be modified again with the tool.
The error message is :
Error swapping tables: Failed to find a unique old table name after serveral attempts. (<-- typo in the message)
How to reproduce:
mysql world < world_structure.sql
the table to modify is City:
CREATE TABLE `City` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`Name` char(35) NOT NULL DEFAULT '',
`CountryCode` char(3) NOT NULL DEFAULT '',
`District` char(20) NOT NULL DEFAULT '',
`Population` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `CountryCode` (`CountryCode`),
CONSTRAINT `city_ibfk_1` FOREIGN KEY (`CountryCode`) REFERENCES `Country` (`Code`)
) ENGINE=InnoDB AUTO_INCREMENT=4080 DEFAULT CHARSET=latin1;
Let's add some fields:
pt-online-
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_
Altering `world`.`City`...
Creating new table...
Created new table world._City_new OK.
Altering new table...
Altered `world`.`_City_new` OK.
2013-08-01T08:26:11 Creating triggers...
2013-08-01T08:26:11 Created triggers OK.
2013-08-01T08:26:11 Copying approximately 1 rows...
2013-08-01T08:26:11 Copied rows OK.
2013-08-01T08:26:11 Swapping tables...
2013-08-01T08:26:11 Swapped original and new tables OK.
2013-08-01T08:26:11 Dropping old table...
2013-08-01T08:26:11 Dropped old table `world`.`_City_old` OK.
2013-08-01T08:26:11 Dropping triggers...
2013-08-01T08:26:11 Dropped triggers OK.
Successfully altered `world`.`City`.
Now let's add a new one:
pt-online-
Operation, tries, wait:
copy_rows, 10, 0.25
create_triggers, 10, 1
drop_triggers, 10, 1
swap_tables, 10, 1
update_
Altering `world`.`City`...
Creating new table...
Created new table world._City_new OK.
Altering new table...
Altered `world`.`_City_new` OK.
2013-08-01T08:28:01 Creating triggers...
2013-08-01T08:28:01 Created triggers OK.
2013-08-01T08:28:01 Copying approximately 1 rows...
2013-08-01T08:28:01 Copied rows OK.
2013-08-01T08:28:01 Swapping tables...
2013-08-01T08:28:02 Dropping triggers...
2013-08-01T08:28:02 Dropped triggers OK.
Not dropping the new table `world`.`_City_new` because --swap-tables failed. To drop the new table, execute:
DROP TABLE IF EXISTS `world`
`world`.`City` was not altered.
2013-08-01T08:28:02 Error swapping tables: 2013-08-01T08:28:02 Failed to find a unique old table name after serveral attempts.
To clean up, first verify that the original table `world`.`City` has not been modified or renamed, then drop the new table `world`.`_City_new` if it exists.
now an extra table is present:
+-----------------+
| Tables_in_world |
+-----------------+
| City |
| Country |
| CountryLanguage |
| _City_new |
+-----------------+
Expected result: _City_new should replace City
Changed in percona-toolkit: | |
status: | New → Confirmed |
importance: | Undecided → Medium |
milestone: | none → 2.2.5 |
tags: | added: pt-online-schema-change |
Changed in percona-toolkit: | |
milestone: | 2.2.5 → none |
Changed in percona-toolkit: | |
milestone: | none → 2.2.6 |
Changed in percona-toolkit: | |
milestone: | 2.2.6 → none |
importance: | Medium → Undecided |
Changed in percona-toolkit: | |
milestone: | none → 2.2.9 |
importance: | Undecided → Medium |
assignee: | nobody → Frank Cizmich (frank-cizmich) |
Changed in percona-toolkit: | |
milestone: | 2.2.9 → none |
Here is an error I got via PTDEBUG
2014-03-31T18:30:19 Swapping tables... schema_ change: 9637 12170 RENAME TABLE `bgelfer_ cms`.`history_ data` TO `bgelfer_ cms`.`_ history_ data_old` , `bgelfer_ cms`.`_ history_ data_new` TO `bgelfer_ cms`.`history_ data` cms/history_ data' already exists [for Statement "RENAME TABLE `bgelfer_ cms`.`history_ data` TO `bgelfer_ cms`.`_ history_ data_old` , `bgelfer_ cms`.`_ history_ data_new` TO `bgelfer_ cms`.`history_ data`"] at /usr/bin/ pt-online- schema- change line 9638.
# Retry:3655 12170 Try 1 of 10
# pt_online_
# Retry:3661 12170 Try code failed: DBD::mysql::db do failed: Table './bgelfer_
#