Bug #113440 Table spaces with instant_col information can no longer be imported
Submitted: 15 Dec 2023 13:06 Modified: 17 Dec 2023 13:17
Reporter: Przemyslaw Malkowski Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:8.0.35 OS:Any
Assigned to: CPU Architecture:Any
Tags: ALGORITHM=INSTANT

[15 Dec 2023 13:06] Przemyslaw Malkowski
Description:
When a table was modified using the INSTANT algorithm in versions before 8.0.29, and later the server was upgraded, it is no longer possible to export and import the table space correctly. The import operation fails with:

mysql > alter table t1 import tablespace;
ERROR 1817 (HY000): Index corrupt: Clustered index validation failed, due to data file corruption.

How to repeat:
Install a fresh 8.0.28 instance, create a table, add a new column using this algorithm, then upgrade the server to the latest 8.0 and try to export and import this table space.

An example test:

mysql [localhost:8035] {msandbox} ((none)) > select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.28    |
+-----------+
1 row in set (0.00 sec)

mysql [localhost:8035] {msandbox} (db1) > CREATE TABLE `t1` (
    ->   `id` int DEFAULT NULL
    -> ) ENGINE=InnoDB;
Query OK, 0 rows affected (0.03 sec)

mysql [localhost:8035] {msandbox} (db1) > insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)

mysql [localhost:8035] {msandbox} (db1) > ALTER TABLE t1 ADD COLUMN c1 INT, ALGORITHM=INSTANT;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0

$ ibd2sdi /data/sandboxes/msb_8_0_28/data/db1/t1.ibd |grep -i instant
        "se_private_data": "instant_col=1;",

$ dbdeployer admin upgrade msb_8_0_28 msb_8_0_35
Data directory msb_8_0_28/data moved to msb_8_0_35/data 
......... sandbox server started

The data directory from msb_8_0_35/data is preserved in msb_8_0_35/data-msb_8_0_35
The data directory from msb_8_0_28/data is now used in msb_8_0_35/data
msb_8_0_28 is not operational and can be deleted

-- error log shows successful upgrade:
2023-12-15T12:48:22.602650Z 4 [System] [MY-013381] [Server] Server upgrade from '80028' to '80035' started.
2023-12-15T12:48:27.209927Z 4 [System] [MY-013381] [Server] Server upgrade from '80028' to '80035' completed.

mysql [localhost:8053] {msandbox} (db1) > select @@version;
+-----------+
| @@version |
+-----------+
| 8.0.35    |
+-----------+
1 row in set (0.00 sec)

mysql [localhost:8053] {msandbox} (db1) > select count(*) from t1;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

mysql [localhost:8053] {msandbox} (db1) > create table db2.t1 like db1.t1;
Query OK, 0 rows affected (0.02 sec)

mysql [localhost:8053] {msandbox} (db1) > flush tables db1.t1 for export;
Query OK, 0 rows affected (0.09 sec)

\! cp msb_8_0_35/data/db1/t1.* /tmp/

mysql [localhost:8053] {msandbox} (db1) > unlock tables;
Query OK, 0 rows affected (0.00 sec)

mysql [localhost:8053] {msandbox} (db2) > alter table db2.t1 discard tablespace;
Query OK, 0 rows affected (0.08 sec)

\! cp /tmp/t1.* msb_8_0_35/data/db2/

mysql [localhost:8053] {msandbox} (db2) > alter table db2.t1 import tablespace;
ERROR 1817 (HY000): Index corrupt: Clustered index validation failed, due to data file corruption.

-- err log:
2023-12-15T12:54:04.872526Z 11 [ERROR] [MY-012734] [InnoDB] Summed data size 33, returned by func 29
2023-12-15T12:54:04.872578Z 11 [ERROR] [MY-012738] [InnoDB] Apparent corruption in space 398 page 4 index `GEN_CLUST_INDEX`
2023-12-15T12:54:04.872594Z 11 [ERROR] [MY-013050] [InnoDB] In page 4 of index `GEN_CLUST_INDEX` of table `db2`.`t1`

Suggested fix:
Fix the importing procedure accordingly.
[17 Dec 2023 13:17] MySQL Verification Team
Hello Przemyslaw,

Thank you for the report and feedback. 
Verified as described.

Thanks,
Umesh