pt-online-schema-change eating portion of a table
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
| Percona Toolkit moved to https://jira.percona.com/projects/PT |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
We have a situation where pt-online-
Please consider the following table:
CREATE TABLE `RICK_HOP` (
`ID` bigint(20) unsigned NOT NULL,
`ID_BOOKING` bigint(20) unsigned NOT NULL DEFAULT '0' ,
`ID_FLIGHT` int(1) unsigned NOT NULL DEFAULT '1',
`ID_LEG` int(11) unsigned NOT NULL DEFAULT '0' ,
`ID_HOP` int(11) unsigned NOT NULL DEFAULT '0' ,
`DEPARTURE_
`DEPARTURE_DATE` datetime DEFAULT NULL ,
`DEPARTURE_
`ARRIVAL_AIRPORT` char(3) DEFAULT NULL ,
`ARRIVAL_DATE` datetime DEFAULT NULL ,
`ARRIVAL_
`ID_AIRLINE` char(3) DEFAULT NULL ,
`ID_AIRLINE_
`PNR` varchar(20) DEFAULT '' ,
`CLASS_
`CLASS_TO_BOOK` char(1) DEFAULT '' ,
`FARE_BASIS` varchar(20) DEFAULT NULL ,
`CLASS_TO_BOOK_C` char(1) DEFAULT '' ,
`FARE_BASIS_C` varchar(20) DEFAULT NULL ,
`CLASS_TO_BOOK_I` char(1) DEFAULT '' ,
`FARE_BASIS_I` varchar(20) DEFAULT NULL ,
`SEATS` int(2) NOT NULL DEFAULT '0' ,
`DAY_CHANGE` tinyint(1) DEFAULT '0' ,
`FLIGHT_
`STOPS` int(11) DEFAULT '0' ,
`AIRPORT_CHANGE` tinyint(1) DEFAULT '0' ,
`ELAPSED_
`JOURNAY_
`ELECTRONIC_
`STATUS` varchar(20) NOT NULL DEFAULT '',
`FLIGHT_NUMBER` varchar(15) DEFAULT NULL ,
`AIRCRAFT` varchar(50) DEFAULT NULL ,
`VALUE1` varchar(255) CHARACTER SET utf8 DEFAULT NULL ,
`VALUE2` varchar(255) CHARACTER SET utf8 DEFAULT NULL ,
`ADT_
`CHD_
`INF_
`LAST_UPDATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY `unique_
KEY `DEPARTURE_DATE` (`DEPARTURE_DATE`),
KEY `DEPAIR_DEPDATE` (`DEPARTURE_
KEY `LAST_UPDATE` (`LAST_UPDATE`),
KEY `ID` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Table contains 150,000 rows.
The first column 'ID' is candidate to become an auto_increment primary key for the table.
First 120,000 rows in the table have an increasing value for ID from 1 to 120,000 and we are using the following command line to change the ID column into an auto_increment primary key:
pt-online-
After the above completes successfully, the resulting table has 29,999 less rows than then original one.
This also happens with latest release (pt-online-
If we run the above ALTER command directly it works as intended (the 30,000 rows with ID=0 are correctly populated with auto incremental values).
We have noted that running without the "--no-check-plan" flag causes pt-online-
We are attaching a dump for the table that you can use to run the above command line and verify the bug.
Rick Pizzi (pizzi) wrote : | #2 |
Rick Pizzi (pizzi) wrote : | #3 |
Some investigation brought me to the reason for the tool not copying the rows.
It only copies rows with ID > 0, then it copies the first row which has ID = 0
but for some reason this row doesn't get an AUTO INCREMENT value assigned but is rather
stored with ID=0 in the new table!
As a consequence, all future inserts by the tool are ignored (due to the IGNORE clause in
the INSERT statement that pt-online-
If we comment out the IGNORE clause from the tool binary and run it again, we get:
017-08-09T17:40:20 Error copying rows from `rick`.`RICK_HOP` to `rick`.
In fact, looks like the first row which gets copied, is copied with ID=0.
Since it is perfectly legit to use zero in an auto_increment column to get a new value, this is
quite surprising.... but it explains why the tool eats all subsequent rows. And why it only copies one row if all rows in source table have ID=0.
Rick Pizzi (pizzi) wrote : | #4 |
Found out that pt-online-
This explain.
Can you please tell me the reason for such choice?
Carlos Salguero (carlos-salguero) wrote : | #5 |
Thanks for the bug report and for investigating it.
Even when it is not a good practice to have a primary key value=0, pt-online-
What I can do is:
1) Document this behavior.
2) Maybe I can add an option to suppress setting NO_AUTO_
Would that work for you?
Rick Pizzi (pizzi) wrote : | #6 |
I would be interested in knowing why the tool explicitly sets NO_AUTO_
An option to disable this behaviour would be nice. It would be also worth mentioning in the manual that the NO_AUTO_
Thanks!
Rick
Changed in percona-toolkit: | |
status: | New → Won't Fix |
Carlos Salguero (carlos-salguero) wrote : | #7 |
Carlos Salguero (carlos-salguero) wrote : | #8 |
Disregard the last comment please.
Shahriyar Rzayev (rzayev-sehriyar) wrote : | #9 |
Percona now uses JIRA for bug reports so this bug report is migrated to: https:/
If we run the same with ALL rows having ID=0, the tool will only copy ONE row!!