mirror of
https://github.com/MariaDB/server.git
synced 2025-09-22 17:15:31 +02:00

The function row_purge_reset_trx_id() that had been introduced in commit3c09f148f3
(MDEV-12288) introduces some extra buffer pool and redo log activity that will cause a significant performance regression under some workloads. This is currently the most significant performance issue, after commitacd071f599
(MDEV-21923) fixed the InnoDB LSN allocation and MDEV-19749 the MDL bottleneck in 12.1. The purpose of row_purge_reset_trx_id() was to ensure that we can easily identify records for which no history exists. If DB_TRX_ID is 0, we could avoid looking up the transaction to see if the history is accessible or the record is implicitly locked. To avoid trx_sys_t::find() for stale DB_TRX_ID values, we can refer to trx_t::max_inactive_id, which was introduced in commit4105017a58
(MDEV-30357). Instead of comparing DB_TRX_ID to 0, we may compare it to this cached value. The cache would be updated by trx_sys_t::find_same_or_older(), which is invoked for some operations on secondary indexes. row_purge_reset_trx_id(): Remove. We will no longer reset the DB_TRX_ID to 0 after an INSERT. We will retain a single undo log for all operations, though. Before MDEV-12288, there had been separate insert_undo and update_undo logs. row_check_index(): No longer warn "InnoDB: Clustered index record with stale history in table". lock_rec_queue_validate(), lock_rec_convert_impl_to_expl(), row_vers_impl_x_locked_low(): Instead of comparing the DB_TRX_ID to 0, compare it to trx_t::max_inactive_id. In dict0load.cc we will not spend any effort to avoid extra trx_sys.find() calls for stale DB_TRX_ID in dictionary tables. This code does not currently use trx_t objects, and therefore we cannot easily access trx_t::max_inactive_id. Loading table definitions into the InnoDB data dictionary cache (dict_sys) should be a very rare operation. Reviewed by: Vladislav Lesin
200 lines
6.2 KiB
Text
200 lines
6.2 KiB
Text
# restart: with restart_parameters
|
|
SET GLOBAL innodb_file_per_table=1;
|
|
CREATE TABLE tr(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
|
|
CREATE TABLE tc(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPACT;
|
|
CREATE TABLE td(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
|
|
SET innodb_strict_mode=OFF;
|
|
CREATE TABLE tz(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=COMPRESSED
|
|
KEY_BLOCK_SIZE=1;
|
|
SET innodb_strict_mode=ON;
|
|
CREATE TABLE tp(a INT PRIMARY KEY)ENGINE=InnoDB ROW_FORMAT=DYNAMIC
|
|
PAGE_COMPRESSED=1 PAGE_COMPRESSION_LEVEL=9;
|
|
SYS_TABLES clustered index root page (8):
|
|
N_RECS=8; LEVEL=0; INDEX_ID=0x0000000000000001
|
|
header=0x01000003008d (NAME=0x696e66696d756d00)
|
|
header=0x0000101500d5 (NAME='SYS_FOREIGN',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x000000000000000b,
|
|
N_COLS=0x00000004,
|
|
TYPE=0x00000001,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000040,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000000)
|
|
header=0x000018150122 (NAME='SYS_FOREIGN_COLS',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x000000000000000c,
|
|
N_COLS=0x00000004,
|
|
TYPE=0x00000001,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000040,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000000)
|
|
header=0x0000201501ae (NAME='SYS_VIRTUAL',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x000000000000000d,
|
|
N_COLS=0x00000003,
|
|
TYPE=0x00000001,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000040,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000000)
|
|
header=0x0400301501f2 (NAME='test/tc',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x000000000000000f,
|
|
N_COLS=0x80000001,
|
|
TYPE=0x00000001,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000050,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000002)
|
|
header=0x00003815027a (NAME='test/td',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x0000000000000010,
|
|
N_COLS=0x80000001,
|
|
TYPE=0x00000021,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000050,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000003)
|
|
header=0x00004815016a (NAME='test/tp',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x0000000000000012,
|
|
N_COLS=0x80000001,
|
|
TYPE=0x000009a1,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000050,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000005)
|
|
header=0x000028150236 (NAME='test/tr',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x000000000000000e,
|
|
N_COLS=0x00000001,
|
|
TYPE=0x00000001,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000050,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000001)
|
|
header=0x000040150074 (NAME='test/tz',
|
|
DB_TRX_ID=0xXXXXXXXXXXXX,
|
|
DB_ROLL_PTR=0xXXXXXXXXXXXXXX,
|
|
ID=0x0000000000000011,
|
|
N_COLS=0x80000001,
|
|
TYPE=0x00000023,
|
|
MIX_ID=0x0000000000000000,
|
|
MIX_LEN=0x00000050,
|
|
CLUSTER_NAME=NULL(0 bytes),
|
|
SPACE=0x00000004)
|
|
header=0x050008030000 (NAME=0x73757072656d756d00)
|
|
# restart: with restart_parameters
|
|
SHOW CREATE TABLE tr;
|
|
ERROR 42S02: Table 'test.tr' doesn't exist in engine
|
|
SHOW CREATE TABLE tc;
|
|
ERROR 42S02: Table 'test.tc' doesn't exist in engine
|
|
SELECT * FROM tc;
|
|
ERROR 42S02: Table 'test.tc' doesn't exist in engine
|
|
SHOW CREATE TABLE td;
|
|
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
|
|
SELECT * FROM td;
|
|
ERROR HY000: Got error 194 "Tablespace is missing for a table" from storage engine InnoDB
|
|
SHOW CREATE TABLE tz;
|
|
Table Create Table
|
|
tz CREATE TABLE `tz` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1
|
|
BEGIN;
|
|
INSERT INTO tz VALUES(42);
|
|
ROLLBACK;
|
|
SELECT * FROM tz;
|
|
a
|
|
42
|
|
SHOW CREATE TABLE tp;
|
|
ERROR 42S02: Table 'test.tp' doesn't exist in engine
|
|
FOUND 3 /InnoDB: Table test/t[cp] in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=(129|289|3873|1232[13]) SYS_TABLES\.N_COLS=2147483649/ in mysqld.1.err
|
|
FOUND 1 /InnoDB: Table test/tr in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=65 SYS_TABLES\.MIX_LEN=4294967295\b/ in mysqld.1.err
|
|
Restoring SYS_TABLES clustered index root page (8)
|
|
# restart: with restart_parameters
|
|
SHOW CREATE TABLE tr;
|
|
Table Create Table
|
|
tr CREATE TABLE `tr` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=REDUNDANT
|
|
SHOW CREATE TABLE tc;
|
|
Table Create Table
|
|
tc CREATE TABLE `tc` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPACT
|
|
SHOW CREATE TABLE td;
|
|
Table Create Table
|
|
td CREATE TABLE `td` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC
|
|
SHOW CREATE TABLE tz;
|
|
Table Create Table
|
|
tz CREATE TABLE `tz` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1
|
|
SHOW CREATE TABLE tp;
|
|
Table Create Table
|
|
tp CREATE TABLE `tp` (
|
|
`a` int(11) NOT NULL,
|
|
PRIMARY KEY (`a`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC `PAGE_COMPRESSED`=1 `PAGE_COMPRESSION_LEVEL`=9
|
|
BEGIN;
|
|
INSERT INTO tr VALUES(1);
|
|
INSERT INTO tc VALUES(1);
|
|
INSERT INTO td VALUES(1);
|
|
INSERT INTO tz VALUES(1);
|
|
INSERT INTO tp VALUES(1);
|
|
ROLLBACK;
|
|
SELECT * FROM tr;
|
|
a
|
|
SELECT * FROM tc;
|
|
a
|
|
SELECT * FROM td;
|
|
a
|
|
SELECT * FROM tp;
|
|
a
|
|
DROP TABLE tr,tc,td,tz,tp;
|
|
# restart
|
|
ib_logfile0
|
|
ibdata1
|
|
sys_tables.bin
|
|
call mtr.add_suppression("ERROR HY000: Can't create table `test`.`t1`");
|
|
CREATE TABLE t1(f1 INT, f2 VARCHAR(1), KEY k1(f2),
|
|
FULLTEXT KEY(f2),
|
|
FOREIGN KEY (f2) REFERENCES t1(f3))ENGINE=InnoDB;
|
|
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
|
|
#
|
|
# MDEV-23199 page_compression flag is missing
|
|
# for full_crc32 tablespace
|
|
#
|
|
CREATE TABLE t1(f1 BIGINT PRIMARY KEY)ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES(1);
|
|
ALTER TABLE t1 PAGE_COMPRESSED = 1;
|
|
INSERT INTO t1 VALUES(2);
|
|
# restart
|
|
DROP TABLE t1;
|
|
#
|
|
# MDEV-34222 Alter operation on redundant table aborts the server
|
|
#
|
|
SET @df_row = @@global.INNODB_DEFAULT_ROW_FORMAT;
|
|
SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=REDUNDANT;
|
|
CREATE TABLE t1 (c CHAR(1)) ENGINE=InnoDB;
|
|
SET GLOBAL INNODB_DEFAULT_ROW_FORMAT=compact;
|
|
ALTER TABLE t1 PAGE_COMPRESSED=1;
|
|
ERROR HY000: Table storage engine 'InnoDB' does not support the create option 'PAGE_COMPRESSED=1 ROW_FORMAT=REDUNDANT'
|
|
DROP TABLE t1;
|
|
SET @@global.INNODB_DEFAULT_ROW_FORMAT = @df_row;
|