mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-13564: Implement innodb_unsafe_truncate=ON for compatibility
While MariaDB Server 10.2 is not really guaranteed to be compatible with Percona XtraBackup 2.4 (for example, the MySQL 5.7 undo log format change that could be present in XtraBackup, but was reverted from MariaDB in MDEV-12289), we do not want to disrupt users who have deployed xtrabackup and MariaDB Server 10.2 in their environments. With this change, MariaDB 10.2 will continue to use the backup-unsafe TRUNCATE TABLE code, so that neither the undo log nor the redo log formats will change in an incompatible way. Undo tablespace truncation will keep using the redo log only. Recovery or backup with old code will fail to shrink the undo tablespace files, but the contents will be recovered just fine. In the MariaDB Server 10.2 series only, we introduce the configuration parameter innodb_unsafe_truncate and make it ON by default. To allow MariaDB Backup (mariabackup) to work properly with TRUNCATE TABLE operations, use loose_innodb_unsafe_truncate=OFF. MariaDB Server 10.3.10 and later releases will always use the backup-safe TRUNCATE TABLE, and this parameter will not be added there. recv_recovery_rollback_active(): Skip row_mysql_drop_garbage_tables() unless innodb_unsafe_truncate=OFF. It is too unsafe to drop orphan tables if RENAME operations are not transactional within InnoDB. LOG_HEADER_FORMAT_10_3: Replaces LOG_HEADER_FORMAT_CURRENT. log_init(), log_group_file_header_flush(), srv_prepare_to_delete_redo_log_files(), innobase_start_or_create_for_mysql(): Choose the redo log format and subformat based on the value of innodb_unsafe_truncate.
This commit is contained in:
114
mysql-test/suite/innodb/r/truncate_inject.result
Normal file
114
mysql-test/suite/innodb/r/truncate_inject.result
Normal file
@ -0,0 +1,114 @@
|
||||
SET @save_dbug = @@SESSION.debug_dbug;
|
||||
call mtr.add_suppression("InnoDB: Flagged corruption of .* in table `test`\\.`t` in TRUNCATE TABLE");
|
||||
# 1. Error in assigning undo logs for truncate action
|
||||
CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
|
||||
ENGINE = InnoDB;
|
||||
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SET debug_dbug = '+d,ib_err_trunc_assigning_undo_log';
|
||||
truncate table t;
|
||||
ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
select * from t;
|
||||
i f c
|
||||
1 1.1 a
|
||||
2 2.2 b
|
||||
3 3.3 c
|
||||
# 2. Error while preparing for truncate
|
||||
SET debug_dbug = '+d,ib_err_trunc_preparing_for_truncate';
|
||||
truncate table t;
|
||||
ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
select * from t;
|
||||
i f c
|
||||
1 1.1 a
|
||||
2 2.2 b
|
||||
3 3.3 c
|
||||
# 3. Error while dropping/creating indexes
|
||||
SET debug_dbug = '+d,ib_err_trunc_drop_index';
|
||||
truncate table t;
|
||||
ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check Warning InnoDB: Index PRIMARY is marked as corrupted
|
||||
test.t check error Corrupt
|
||||
select * from t;
|
||||
Got one of the listed errors
|
||||
drop table t;
|
||||
CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
|
||||
ENGINE = InnoDB;
|
||||
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SET debug_dbug = '+d,ib_err_trunc_create_index';
|
||||
truncate table t;
|
||||
ERROR HY000: Got error 168 "Unknown (generic) error from engine" from storage engine InnoDB
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check Warning InnoDB: Index PRIMARY is marked as corrupted
|
||||
test.t check error Corrupt
|
||||
select * from t;
|
||||
Got one of the listed errors
|
||||
drop table t;
|
||||
CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100), INDEX ck(c))
|
||||
ENGINE = InnoDB;
|
||||
insert into t values (1, 1.1, 'a'), (2, 2.2, 'b'), (3, 3.3, 'c');
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
|
||||
truncate table t;
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
select * from t;
|
||||
i f c
|
||||
drop table t;
|
||||
# 4. Error while completing truncate of table involving FTS
|
||||
CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
|
||||
FULLTEXT INDEX(c)) ENGINE = InnoDB;
|
||||
insert into t values (1, 1.1, 'mysql is now oracle company'),
|
||||
(2, 2.2, 'innodb is part of mysql'),
|
||||
(3, 3.3, 'innodb is default storage engine of mysql');
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
|
||||
truncate table t;
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
select * from t;
|
||||
i f c
|
||||
drop table t;
|
||||
# 5. Error while updating sys-tables
|
||||
CREATE TABLE t (i int PRIMARY KEY, f float UNIQUE, c char(100),
|
||||
FULLTEXT INDEX(c)) ENGINE = InnoDB;
|
||||
insert into t values (1, 1.1, 'mysql is now oracle company'),
|
||||
(2, 2.2, 'innodb is part of mysql'),
|
||||
(3, 3.3, 'innodb is default storage engine of mysql');
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
SET debug_dbug = '+d,ib_err_trunc_temp_recreate_index';
|
||||
truncate table t;
|
||||
SET debug_dbug = @save_dbug;
|
||||
check table t;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t check status OK
|
||||
select * from t order by i;
|
||||
i f c
|
||||
drop table t;
|
Reference in New Issue
Block a user