mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
8f8ba75855
This also fixes MDEV-20198: Instant ALTER TABLE is not crash safe InnoDB dictionary recovery wrongly used the READ UNCOMMITTED isolation level, causing some mismatch. For example, if a table was renamed or replaced in a transaction, according to READ UNCOMMITTED the table might not exist at all. We implement READ COMMITTED isolation level for accessing the dictionary tables SYS_TABLES, SYS_COLUMNS, SYS_INDEXES, SYS_FIELDS, SYS_VIRTUAL, SYS_FOREIGN, SYS_FOREIGN_COLS. For most of these tables, no secondary index exists. For the secondary indexes (on SYS_TABLES.ID, SYS_FOREIGN.FOR_NAME, SYS_FOREIGN.REF_NAME), we will always look up the primary key in the clustered index and check if the record actually is a committed version. dict_check_sys_tables(): Recover tablespaces also from delete-marked committed records, so that if a matching .ibd file exists, it will be removed by fil_delete_tablespace() when the committed delete-marked SYS_INDEXES record of the clustered index is purged in row_purge_remove_clust_if_poss_low(). fil_ibd_open(): Change the Boolean parameter "validate" to a ternary one, to suppress error messages when the file might not exist. It is possible that a .ibd file was deleted and the server shut down before the SYS_INDEXES and SYS_TABLES records were purged. Hence, if dict_check_sys_tables() finds a committed delete-marked record, we must not complain if the tablespace file is not found. On Windows, we msut treat ERROR_PATH_NOT_FOUND (directory not found) in the same way as ERROR_FILE_NOT_FOUND. This fixes a few failures where a previous test successfully executed DROP DATABASE (and deleted all files and the directory), but a committed delete-marked SYS_TABLES record had not been purged before server restart. dict_getnext_system_low(): Do not filter out delete-marked records. dict_startscan_system(), dict_getnext_system(): Do filter out delete-marked records, for accessing the INFORMATION_SCHEMA tables. dict_sys_tables_rec_read(): Return the DB_TRX_ID of the committed version of the record. This is needed in dict_load_table_low(). dict_load_foreign_cols(), dict_load_foreign(): Add a parameter for the current transaction identifier. In some DDL operations, the FOREIGN KEY constraints are being loaded from the data dictionary before the DDL transaction has been committed. For SYS_FOREIGN and SYS_FOREIGN_COLS, we must implement the special case of READ COMMITTED that the changes of the uncommitted current transaction are visible. dict_load_foreign(): Validate the table name. We could find a SYS_FOREIGN.ID via a committed delete-marked secondary index record that does not match the REF_NAME or FOR_NAME of the secondary index record. dict_load_index_low(): Optionally take the table as a parameter, so that table->def_trx_id can be updated in case of a committed delete-marked SYS_INDEXES record corresponding to DROP INDEX, but not corresponding to an index stub of ADD INDEX. dict_load_indexes(): Do not update table->def_trx_id in case of delete-marked records. rec_is_metadata(), rec_offs_make_valid(), rec_get_offsets_func(), row_build_low(): Relax some assertions. We may now have !index->is_instant() even if a metadata record is present in the index. Previously, the recovery of instant ADD/DROP COLUMN assumed that READ UNCOMMITTED of the data dictionary will be performed. Now, we will have a READ COMMITTED copy of the data dictionary cache, and a READ UNCOMMITTED copy of the metadata record. btr_page_reorganize_low(): Correctly update the FIL_PAGE_TYPE when rolling back an instant ADD/DROP COLUMN operation. row_rec_to_index_entry_impl(): Relax some assertions, and disallow accessing "extra" fields. This fixes the recovery of a crash during an instant ADD COLUMN after a successful instant DROP COLUMN, in the test innodb.instant_alter_crash. Tested by: Matthias Leich
76 lines
3.4 KiB
Text
76 lines
3.4 KiB
Text
SET GLOBAL innodb_fast_shutdown=0;
|
|
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0
|
|
SET GLOBAL innodb_file_per_table=1;
|
|
#
|
|
# Bug#21644827 - FTS, ASSERT !SRV_READ_ONLY_MODE || M_IMPL.M_LOG_MODE ==
|
|
# MTR_LOG_NO_REDO
|
|
#
|
|
SET GLOBAL innodb_file_per_table=ON;
|
|
create table t1 (a int not null, d varchar(15) not null, b
|
|
varchar(198) not null, c char(156)) engine=InnoDB
|
|
row_format=redundant;
|
|
create temporary table t like t1;
|
|
insert into t values(123, 'abcdef', 'jghikl', 'mnop');
|
|
insert into t values(456, 'abcdef', 'jghikl', 'mnop');
|
|
insert into t values(789, 'abcdef', 'jghikl', 'mnop');
|
|
insert into t values(134, 'kasdfsdsadf', 'adfjlasdkfjasd', 'adfsadflkasdasdfljasdf');
|
|
insert into t1 select a,d,b,c from t, seq_1_to_1024;
|
|
SET GLOBAL innodb_file_per_table=OFF;
|
|
create table t2 (a int not null, d varchar(15) not null, b
|
|
varchar(198) not null, c char(156), fulltext ftsic(c)) engine=InnoDB
|
|
row_format=redundant;
|
|
insert into t2 select a,d,b,c from t, seq_1_to_1024;
|
|
create table t3 (a int not null, d varchar(15) not null, b varchar(198),
|
|
c varchar(150), index k1(c(99), b(56)), index k2(b(5), c(10))) engine=InnoDB
|
|
row_format=redundant;
|
|
insert into t3 values(444, 'dddd', 'bbbbb', 'aaaaa');
|
|
insert into t3 values(555, 'eeee', 'ccccc', 'aaaaa');
|
|
SET GLOBAL innodb_fast_shutdown=0;
|
|
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0 --innodb-read-only
|
|
SELECT COUNT(*) FROM t1;
|
|
COUNT(*)
|
|
4096
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
4096
|
|
SELECT COUNT(*) FROM t3;
|
|
COUNT(*)
|
|
2
|
|
TRUNCATE TABLE t1;
|
|
ERROR HY000: Table 't1' is read only
|
|
TRUNCATE TABLE t2;
|
|
ERROR HY000: Table 't2' is read only
|
|
TRUNCATE TABLE t3;
|
|
ERROR HY000: Table 't3' is read only
|
|
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0
|
|
TRUNCATE TABLE t1;
|
|
TRUNCATE TABLE t2;
|
|
TRUNCATE TABLE t3;
|
|
corrupted SYS_TABLES.MIX_LEN for test/t1
|
|
corrupted SYS_TABLES.MIX_LEN for test/t2
|
|
corrupted SYS_TABLES.MIX_LEN for test/t3
|
|
# restart: --innodb-data-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-log-group-home-dir=MYSQLTEST_VARDIR/tmp/row_format_redundant --innodb-data-file-path=ibdata1:1M:autoextend --innodb-undo-tablespaces=0 --innodb-stats-persistent=0
|
|
TRUNCATE TABLE t1;
|
|
ERROR 42S02: Table 'test.t1' doesn't exist in engine
|
|
TRUNCATE TABLE t2;
|
|
TRUNCATE TABLE t3;
|
|
SELECT COUNT(*) FROM t1;
|
|
ERROR 42S02: Table 'test.t1' doesn't exist in engine
|
|
SELECT COUNT(*) FROM t2;
|
|
COUNT(*)
|
|
0
|
|
SELECT COUNT(*) FROM t3;
|
|
COUNT(*)
|
|
0
|
|
RENAME TABLE t1 TO tee_one;
|
|
ERROR HY000: Error on rename of './test/t1' to './test/tee_one' (errno: 155 "The table does not exist in the storage engine")
|
|
DROP TABLE t1;
|
|
Warnings:
|
|
Warning 1932 Table 'test.t1' doesn't exist in engine
|
|
DROP TABLE t2,t3;
|
|
FOUND 6 /\[ERROR\] InnoDB: Table test/t1 in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b/ in mysqld.1.err
|
|
# restart
|
|
ib_buffer_pool
|
|
ib_logfile0
|
|
ibdata1
|
|
db.opt
|