Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.6.5, 10.4(EOL), 10.5, 10.6, 10.7(EOL)
-
None
Description
When adding a column in the middle of a table, then adding another column in the middle of the table using ADD COLUMN ... AFTER, in INSTANT mode; and then accidentally trying to export the tablespace and import into a table with the original schema without the extra column, the server crashes, and then can't recover properly from the situation it got stuck in on next restart.
How to reproduce:
Run
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (
|
id INT NOT NULL,
|
i1 INT,
|
i2 INT,
|
PRIMARY KEY (id)
|
) ENGINE=INNODB;
|
|
DROP TABLE IF EXISTS t2;
|
CREATE TABLE t2 (
|
id INT NOT NULL,
|
i1 INT,
|
i2 INT,
|
PRIMARY KEY (id)
|
) ENGINE=INNODB;
|
|
ALTER TABLE test.t1 add COLUMN i3 INT AFTER i1;
|
|
ALTER TABLE t2 DISCARD TABLESPACE;
|
FLUSH TABLES t1 FOR EXPORT;
|
to create tables and prepare for import. Then copy tablespace and config file, using a different terminal:
cd /var/lib/mysql/test
cp -vp t1.ibd t2.ibd
cp -vp t1.cfg t2.cfg
and finish the import in the same mysql client session as above
UNLOCK TABLES;
|
ALTER TABLE t2 IMPORT TABLESPACE;
|
This should abort with a column count mismatch error, but instead crashes the server when not specifying the algorithm, and so using INPLACE by default. When doing the same with ALGORITHM=COPY it does not crash and reports the almost correct
ALTER TABLE t2 IMPORT TABLESPACE, ALGORITHM=COPY;
|
ERROR 1808 (HY000): Schema mismatch (Number of columns don't match, table has 6 columns but the tablespace meta-data file has 7 columns)
|
(separate bug report will be filed for the wrong column counts in that error message)
Backtrace (note: this is a standalone setup, Galera not loaded/enabled)
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(my_print_stacktrace)[0x55791c17a442]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(handle_fatal_signal)[0x55791bc2d6a5]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(__restore_rt)[0x7f28deaad3c0]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(std::thread::thread<void (&)(), , void>(void (&)()))[0x55791c09c723]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(Wsrep_server_service::log_dummy_write_set(wsrep::client_state&, wsrep::ws_meta const&))[0x55791b8b72b4]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(Wsrep_server_service::log_dummy_write_set(wsrep::client_state&, wsrep::ws_meta const&))[0x55791b8b8127]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(wsrep_notify_status(wsrep::server_state::state, wsrep::view const*))[0x55791bf1cc2d]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(mysql_discard_or_import_tablespace(THD*, TABLE_LIST*, bool))[0x55791ba9e06b]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(Sql_cmd_discard_import_tablespace::execute(THD*))[0x55791bb148d4]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(mysql_execute_command(THD*, bool))[0x55791ba01e66]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55791b9f1b97]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55791b9fdde5]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(do_command(THD*, bool))[0x55791b9fffe8]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(do_handle_one_connection(CONNECT*, bool))[0x55791bb10147]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(handle_one_connection)[0x55791bb1049d]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(MyCTX_nopad::finish(unsigned char*, unsigned int*))[0x55791be6f9cd]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(start_thread)[0x7f28deaa1609]
|
Dec 15 13:04:56 ubuntu-focal mariadbd[769]: ??:0(clone)[0x7f28de68f293]
|
And this the recovery failure on next restart
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=42335,42335
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace: ./test/t1.ibd uses space ID: 5. Cannot open filepath: ./test/t2.ibd which uses the same space ID.
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Warning] InnoDB: We do not continue the crash recovery, because the table may become corrupt if we cannot apply the log records in the InnoDB log to it. To fix the problem and start mysqld:
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Note] InnoDB: 1) If there is a permission problem in the file and mysqld cannot open the file, you should modify the permissions.
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Note] InnoDB: 2) If the tablespace is not needed, or you can restore an older version from a backup, then you can remove the .ibd file, and use --innodb_force_recovery=1 to force startup without this file.
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Note] InnoDB: 3) If the file system or the disk is broken, and you cannot remove the .ibd file, you can set --innodb_force_recovery.
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
|
Dec 15 13:05:04 ubuntu-focal mariadbd[2459]: 2021-12-15 13:05:04 0 [Note] InnoDB: Starting shutdown...
|
Attachments
Issue Links
- relates to
-
MDEV-18543 IMPORT TABLESPACE fails after instant DROP COLUMN
- Closed
-
MDEV-25066 IMPORT TABLESPACE not possible if source table had column moved in INSTANT mode
- Closed