[MDEV-18288] Transportable Tablespaces leave AUTO_INCREMENT in mismatched state, causing INSERT errors in newly imported tables when .cfg is not used. Created: 2019-01-17 Updated: 2024-02-06 Resolved: 2024-02-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.2.4, 10.3.0, 10.4.0, 10.5.0 |
| Fix Version/s: | 10.5.25, 10.6.18, 10.11.8, 11.0.6, 11.1.5, 11.2.4, 11.3.3, 11.4.2 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Juan | Assignee: | Debarun Banerjee |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
When a tablespace is imported by first creating the table structure and then discarding the empty tablespace and importing a matching tablespace with a different number of rows, the value of AUTO_INCREMENT is undefined in the new table structure, so even though SHOW TABLE STATUS shows the correct number of rows, INSERTs relying on the AUTO_INCREMENT property of a primary key id column fail with
This attempted INSERT increments the table's AUTO_INCREMENT counter to '2' despite the error, and the error will continue to happen until the actual max value of the id column has been reached. For example:
at this point t1 will contain id's 1, 2, and 3.
and back in the shell, copy t1.ibd back into the datadir while still preserving ownership attributes, and return to the MariaDB monitor.
Whenever the max value of id in the target table declaration is lower than the actual number of imported rows, this error happens. |
| Comments |
| Comment by Marko Mäkelä [ 2020-08-26 ] | |
|
If I understood the test case correctly (I did not try executing it), IMPORT TABLESPACE would fail to read the PAGE_ROOT_AUTO_INC of the imported table ( Could this bug be worked around by the following?
This should reset the AUTO_INCREMENT attribute to the lowest possible value. | |
| Comment by Debarun Banerjee [ 2024-02-01 ] | |
|
During import, if cfg file is not specified, we don't update the autoinc field in innodb dictionary object dict_table_t. The next insert tries to It can be observed that the issue is resolved once server is restarted as the persistent value is read correctly from PAGE_ROOT_AUTO_INC from index root page. The patch fixes the issue by reading the the autoincrement value directly from PAGE_ROOT_AUTO_INC during import if cfg file is not specified. | |
| Comment by Debarun Banerjee [ 2024-02-01 ] | |
|
Please have a look. | |
| Comment by Debarun Banerjee [ 2024-02-01 ] | |
|
Added required test changes to fix 2 test failures. 1. import_bugs.test: Embedded mode warning has absolute path. Regular 2. full_crc32_import.test: Table level auto increment mismatch after | |
| Comment by Debarun Banerjee [ 2024-02-06 ] | |
|
pushed to 10.5 commit 66bb229e910bfeff9fd41ee9d8743344e0738025 (HEAD | |
| Comment by Debarun Banerjee [ 2024-02-06 ] | |
|
Added 11.* next unreleased versions. |