mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-29440 InnoDB instant ALTER TABLE recovery must use READ UNCOMMITTED
In commit 8f8ba75855
(MDEV-27234)
the data dictionary recovery was changed to use READ COMMITTED
so that table-rebuild operations (OPTIMIZE TABLE, TRUNCATE TABLE,
some forms of ALTER TABLE) would be recovered correctly.
However, for operations that avoid a table rebuild thanks to
being able to instantly ADD, DROP or reorder columns, recovery
must use the READ UNCOMMITTED isolation level so that changes to
the hidden metadata record can be rolled back.
We will detect instant operations by detecting uncommitted changes
to SYS_COLUMNS in case there is no uncommitted change of SYS_TABLES.ID
for the table. In any table-rebuilding DDL operation, the SYS_TABLES.ID
(and likely also the table name) will be updated.
As part of rolling back the instant ALTER TABLE operation, after the
operation on the hidden metadata record has been rolled back, a rollback
of an INSERT into SYS_COLUMNS in row_undo_ins_remove_clust_rec() will
invoke trx_t::evict_table() to discard the READ UNCOMMITTED definition
of the table. After that, subsequent recovery steps will load and use
the correct table definition.
Reviewed by: Thirunarayanan Balathandayuthapani
Tested by: Matthias Leich
This commit is contained in:
@@ -198,6 +198,30 @@ disconnect ddl;
|
||||
SHOW CREATE TABLE t1;
|
||||
SHOW CREATE TABLE t2;
|
||||
SHOW CREATE TABLE t3;
|
||||
DROP TABLE t1,t2,t3;
|
||||
DROP TABLE t2,t3;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-29440 InnoDB instant ALTER TABLE recovery wrongly uses
|
||||
--echo # READ COMMITTED isolation level instead of READ UNCOMMITTED
|
||||
--echo #
|
||||
CREATE TABLE t2(a INT UNSIGNED PRIMARY KEY) ENGINE=InnoDB;
|
||||
INSERT INTO t2 VALUES (1),(2),(3),(4),(5),(6);
|
||||
|
||||
connect ddl, localhost, root;
|
||||
SET DEBUG_SYNC='innodb_alter_inplace_before_commit SIGNAL ddl WAIT_FOR ever';
|
||||
--send
|
||||
ALTER TABLE t2 ADD COLUMN b TINYINT UNSIGNED NOT NULL DEFAULT 42 FIRST;
|
||||
|
||||
connection default;
|
||||
SET DEBUG_SYNC='now WAIT_FOR ddl';
|
||||
SET GLOBAL innodb_flush_log_at_trx_commit=1;
|
||||
DELETE FROM t1;
|
||||
|
||||
--source include/kill_mysqld.inc
|
||||
disconnect ddl;
|
||||
--source include/start_mysqld.inc
|
||||
|
||||
CHECK TABLE t2;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--list_files $MYSQLD_DATADIR/test
|
||||
|
Reference in New Issue
Block a user