mariadb/mysql-test/suite/innodb/r/insert_into_empty.result
mariadb-DebarunBanerjee b12c14e3b4 MDEV-34265 Possible hang during IO burst with innodb_flush_sync enabled
When checkpoint age goes beyond the sync flush threshold and
buf_flush_sync_lsn is set, page cleaner enters into "furious flush"
stage to aggressively flush dirty pages from flush list and pull
checkpoint LSN above safe margin. In this stage, page cleaner skips
doing LRU flush and eviction.

In 10.6, all other threads entirely rely on page cleaner to generate
free pages. If free pages get over while page cleaner is busy in
"furious flush" stage, a session thread could wait for free page in the
middle of a min-transaction(mtr) while holding latches on other pages.

It, in turn, can prevent page cleaner to flush such pages preventing
checkpoint LSN to move forward creating a deadlock situation. Even
otherwise, it could create a stall and hang like situation for large BP
with plenty of dirty pages to flush before the stage could finish.

Fix: During furious flush, check and evict LRU pages after each flush
iteration.
2024-06-05 18:11:29 +05:30

284 lines
7 KiB
Text

SET foreign_key_checks=0, unique_checks=0;
#
# MDEV-24715 Assertion !node->table->skip_alter_undo
#
CREATE TABLE t (a INT UNIQUE) ENGINE=InnoDB
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
SELECT * FROM t;
a b
1 3
DROP TABLE t;
CREATE TEMPORARY TABLE t (a INT UNIQUE) ENGINE=InnoDB
REPLACE SELECT 1 AS a, 2 AS b UNION SELECT 1 AS a, 3 AS c;
SELECT * FROM t;
a b
1 3
DROP TEMPORARY TABLE t;
#
# MDEV-24720 AHI removal during bulk index rollback
#
SET @save_ahi = @@global.innodb_adaptive_hash_index;
SET GLOBAL innodb_adaptive_hash_index = 1;
CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB;
SET @old_bulk_op=
(SELECT variable_value FROM information_schema.global_status
WHERE variable_name = 'innodb_bulk_operations');
BEGIN;
INSERT INTO t1 SELECT * FROM seq_1_to_65536;
ROLLBACK;
SELECT variable_value-@old_bulk_op bulk_operations
FROM information_schema.global_status
WHERE variable_name = 'innodb_bulk_operations';
bulk_operations
1
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
#
# MDEV-24832 Root page AHI Removal fails fails during
# bulk index rollback
#
BEGIN;
INSERT INTO t1 SELECT * FROM seq_1_to_500;
ROLLBACK;
DROP TABLE t1;
SET GLOBAL innodb_adaptive_hash_index = @save_ahi;
#
# MDEV-24951 Assertion m.first->second.valid(trx->undo_no) failed
# in trx_undo_report_row_operation
#
CREATE TEMPORARY TABLE t (c INT) ENGINE=InnoDB;
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
SET tx_read_only=1;
BEGIN;
INSERT INTO t2 VALUES(0);
INSERT INTO t VALUES(0);
ROLLBACK;
BEGIN;
INSERT INTO t2 VALUES(0);
INSERT INTO t VALUES(0);
COMMIT;
INSERT INTO t VALUES(0);
DROP TEMPORARY TABLE t,t2;
ERROR 25006: Cannot execute statement in a READ ONLY transaction
SET tx_read_only=0;
DROP TEMPORARY TABLE t,t2;
#
# MDEV-24818 Optimize multiple INSERT into empty table
#
CREATE TABLE t1(f1 INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
INSERT INTO t1 VALUES (4),(5),(6);
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
COMMIT;
SELECT * FROM t1;
f1
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
SAVEPOINT a;
INSERT INTO t1 VALUES (4),(5),(6);
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
ROLLBACK TO SAVEPOINT a;
COMMIT;
SELECT * FROM t1;
f1
5
6
7
DROP TABLE t1;
SET foreign_key_checks=1;
CREATE TABLE t1(f1 INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
INSERT INTO t1 VALUES (4),(5),(6);
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
COMMIT;
SELECT * FROM t1;
f1
5
6
7
BEGIN;
INSERT INTO t1 VALUES (5),(6),(7);
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
SAVEPOINT a;
INSERT INTO t1 VALUES (4),(5),(6);
ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
ROLLBACK TO SAVEPOINT a;
COMMIT;
SELECT * FROM t1;
f1
5
6
7
DROP TABLE t1;
SET foreign_key_checks=0;
#
# MDEV-25315 Crash in SHOW ENGINE INNODB STATUS
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1);
BEGIN;
INSERT INTO t1 VALUES(1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO t2 VALUES(0);
INSERT INTO t1 VALUES(2), (2);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
SHOW ENGINE InnoDB STATUS;
COMMIT;
DROP TABLE t1,t2;
#
# MDEV-25297 Assertion: trx->roll_limit <= trx->undo_no
# in ROLLBACK TO SAVEPOINT
#
CREATE TABLE t1 (c INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (c INT PRIMARY KEY) ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES(0);
SAVEPOINT x;
INSERT INTO t2 VALUES(0);
INSERT INTO t1 VALUES(0);
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
ROLLBACK TO SAVEPOINT x;
ERROR HY000: Got error 153 "No savepoint with that name" during ROLLBACK
COMMIT;
SELECT * FROM t1;
c
SELECT * FROM t2;
c
DROP TABLE t1,t2;
#
# MDEV-25487 Assertion failed in lock_rec_move
#
CREATE TABLE t1 (a INT KEY) ENGINE=InnoDB;
SET @save_limit = @@GLOBAL.innodb_limit_optimistic_insert_debug;
SET GLOBAL innodb_limit_optimistic_insert_debug = 2;
BEGIN;
SELECT * FROM t1 LOCK IN SHARE MODE;
a
INSERT INTO t1 VALUES (0),(1),(2);
INSERT INTO t1 VALUES (0,1);
ERROR 21S01: Column count doesn't match value count at row 1
INSERT INTO t1 VALUES (2);
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
COMMIT;
SET GLOBAL innodb_limit_optimistic_insert_debug = @save_limit;
SELECT * FROM t1;
a
0
1
2
DROP TABLE t1;
#
# MDEV-25534 Assertion lock_table_has...LOCK_IX
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
SET autocommit=0;
LOCK TABLE t1 WRITE;
INSERT INTO t1 VALUES (1);
COMMIT;
CREATE TEMPORARY TABLE t0 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t0 VALUES (1);
INSERT INTO t1 VALUES (2);
COMMIT;
SET autocommit=1;
DROP TABLE t1;
DROP TEMPORARY TABLE t0;
#
# MDEV-25496 Assertion 'trx->bulk_insert' failed
# in trx_undo_report_row_operation on INSERT
#
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1),(0),(1);
DROP TABLE t;
#
# MDEV-28327 InnoDB persistent statistics fail to update
# after bulk insert
#
CREATE TABLE t1 (a INT PRIMARY KEY)ENGINE=InnoDB
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO t1 SELECT * FROM seq_1_to_4096;
# Wait till statistics update after bulk insert operation
SELECT n_rows>=4096 FROM mysql.innodb_table_stats WHERE TABLE_NAME="t1";
n_rows>=4096
1
DROP TABLE t1;
#
# MDEV-27214 Import with disabled keys corrupts meta-data like rows, indexes, ...
#
CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`a` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
STATS_PERSISTENT=1 STATS_AUTO_RECALC=1;
INSERT INTO `t1` VALUES (1,2),(2,3),(3,4);
# Wait till statistics update after bulk insert operation
SELECT TABLE_ROWS, AVG_ROW_LENGTH>0 FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
TABLE_ROWS AVG_ROW_LENGTH>0
3 1
DROP TABLE t1;
#
# MDEV-29975 InnoDB fails to release savepoint during bulk insert
#
CREATE TABLE t (c INT KEY) ENGINE=InnoDB;
begin;
INSERT INTO t VALUES (0,0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT a;
INSERT INTO t VALUES (0),(0);
ERROR 23000: Duplicate entry '0' for key 'PRIMARY'
SAVEPOINT a;
commit;
SELECT * FROM t;
c
DROP TABLE t;
#
# MDEV-29545 InnoDB: Can't find record during replace stmt
#
CREATE TABLE t1(c1 INT PRIMARY KEY)ENGINE=InnoDB;
BEGIN;
INSERT INTO t1 VALUES(3331);
connect con1,localhost,root,,,;
BEGIN;
SELECT c1 FROM t1;
c1
connection default;
COMMIT;
connection con1;
REPLACE INTO t1 VALUES(1984), (1984);
COMMIT;
connection default;
disconnect con1;
SELECT * FROM t1;
c1
1984
3331
DROP TABLE t1;
#
# MDEV-33979 Disallow bulk insert operation during
# partition update statement
#
CREATE TABLE t1(a INT KEY)ENGINE=InnoDB
PARTITION BY KEY(a) PARTITIONS 16;
INSERT INTO t1 VALUES(1);
UPDATE t1 SET a = 2 WHERE a = 1;
DROP TABLE t1;
#
# MDEV-34265 Possible hang during IO burst with innodb_flush_sync enabled
#
CREATE TABLE t1(f1 MEDIUMTEXT)ENGINE=InnoDB;
SET @save_dbug=@@GLOBAL.debug_dbug;
SET @@GLOBAL.debug_dbug='+d,ib_page_cleaner_sleep';
SET STATEMENT debug_dbug='+d,ib_free_page_sleep' FOR
INSERT INTO t1 VALUES(REPEAT(1, 8459264));
SET @@GLOBAL.debug_dbug=@save_dbug;
SELECT length(f1) FROM t1;
length(f1)
8459264
DROP TABLE t1;
# End of 10.6 tests