Skip to content

Commit 3c411e3

Browse files
committed
Test fix for MDEV-6076 Persistent AUTO_INCREMENT for InnoDB
Before killing the server, ensure that the redo log for the incomplete transaction is flushed, so that the AUTO_INCREMENT sequence will always be updated. Usually the INSERT transaction would not have persisted the sequence before the server was killed, but sometimes it could happen, causing result mismatch. Note: This test used to be called innodb_fts.innodb_fts_misc_debug.
1 parent 9fa2071 commit 3c411e3

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

mysql-test/suite/innodb_fts/r/crash_recovery.result

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ INSERT INTO articles (title,body) VALUES
1515
BEGIN;
1616
INSERT INTO articles (title,body) VALUES
1717
('MySQL Tutorial','DBMS stands for DataBase ...');
18+
# Make durable the AUTO_INCREMENT in the above incomplete transaction.
19+
connect flush_redo_log,localhost,root,,;
20+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
21+
BEGIN;
22+
DELETE FROM articles LIMIT 1;
23+
ROLLBACK;
24+
disconnect flush_redo_log;
25+
connection default;
1826
# Kill and restart
1927
INSERT INTO articles (title,body) VALUES
2028
('MySQL Tutorial','DBMS stands for DataBase ...');
@@ -25,7 +33,7 @@ AGAINST ('Database' IN NATURAL LANGUAGE MODE);
2533
id title body
2634
1 MySQL Tutorial DBMS stands for DataBase ...
2735
5 MySQL vs. YourSQL In the following database comparison ...
28-
7MySQL Tutorial DBMS stands for DataBase ...
36+
8MySQL Tutorial DBMS stands for DataBase ...
2937
INSERT INTO articles (title,body) VALUES
3038
('MySQL Tutorial','DBMS stands for DataBase ...') ,
3139
('How To Use MySQL Well','After you went through a ...'),
@@ -36,6 +44,14 @@ INSERT INTO articles (title,body) VALUES
3644
BEGIN;
3745
INSERT INTO articles (title,body) VALUES
3846
('MySQL Tutorial','DBMS stands for DataBase ...');
47+
# Make durable the AUTO_INCREMENT in the above incomplete transaction.
48+
connect flush_redo_log,localhost,root,,;
49+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
50+
BEGIN;
51+
DELETE FROM articles LIMIT 1;
52+
ROLLBACK;
53+
disconnect flush_redo_log;
54+
connection default;
3955
# Kill and restart
4056
INSERT INTO articles (title,body) VALUES
4157
('MySQL Tutorial','DBMS stands for DataBase ...');
@@ -45,10 +61,10 @@ AGAINST ('Database' IN NATURAL LANGUAGE MODE);
4561
id title body
4662
1 MySQL Tutorial DBMS stands for DataBase ...
4763
5 MySQL vs. YourSQL In the following database comparison ...
48-
7 MySQL Tutorial DBMS stands for DataBase ...
4964
8 MySQL Tutorial DBMS stands for DataBase ...
50-
12 MySQL vs. YourSQL In the following database comparison ...
51-
14 MySQL Tutorial DBMS stands for DataBase ...
65+
9 MySQL Tutorial DBMS stands for DataBase ...
66+
13 MySQL vs. YourSQL In the following database comparison ...
67+
16 MySQL Tutorial DBMS stands for DataBase ...
5268
DROP TABLE articles;
5369
CREATE TABLE articles (
5470
id int PRIMARY KEY,

mysql-test/suite/innodb_fts/t/crash_recovery.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ BEGIN;
3838
INSERT INTO articles (title,body) VALUES
3939
('MySQL Tutorial','DBMS stands for DataBase ...');
4040

41+
--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction.
42+
--connect (flush_redo_log,localhost,root,,)
43+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
44+
BEGIN;
45+
DELETE FROM articles LIMIT 1;
46+
ROLLBACK;
47+
--disconnect flush_redo_log
48+
--connection default
49+
4150
--source include/kill_and_restart_mysqld.inc
4251

4352
# This insert will re-initialize the Doc ID counter, it should not crash
@@ -67,6 +76,15 @@ BEGIN;
6776
INSERT INTO articles (title,body) VALUES
6877
('MySQL Tutorial','DBMS stands for DataBase ...');
6978

79+
--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction.
80+
--connect (flush_redo_log,localhost,root,,)
81+
SET GLOBAL innodb_flush_log_at_trx_commit=1;
82+
BEGIN;
83+
DELETE FROM articles LIMIT 1;
84+
ROLLBACK;
85+
--disconnect flush_redo_log
86+
--connection default
87+
7088
--source include/kill_and_restart_mysqld.inc
7189

7290
# This insert will re-initialize the Doc ID counter, it should not crash
@@ -103,6 +121,8 @@ INSERT INTO articles VALUES
103121

104122
BEGIN;
105123

124+
# Below we do not depend on the durability of the AUTO_INCREMENT sequence,
125+
# so we can skip the above flush_redo_log trick.
106126
INSERT INTO articles VALUES
107127
(100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...');
108128

0 commit comments

Comments
 (0)