Skip to content

Commit

Permalink
Test fix for MDEV-6076 Persistent AUTO_INCREMENT for InnoDB
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Feb 8, 2017
1 parent 9fa2071 commit 3c411e3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
24 changes: 20 additions & 4 deletions mysql-test/suite/innodb_fts/r/crash_recovery.result
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ INSERT INTO articles (title,body) VALUES
BEGIN;
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...');
# Make durable the AUTO_INCREMENT in the above incomplete transaction.
connect flush_redo_log,localhost,root,,;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
BEGIN;
DELETE FROM articles LIMIT 1;
ROLLBACK;
disconnect flush_redo_log;
connection default;
# Kill and restart
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...');
Expand All @@ -25,7 +33,7 @@ AGAINST ('Database' IN NATURAL LANGUAGE MODE);
id title body
1 MySQL Tutorial DBMS stands for DataBase ...
5 MySQL vs. YourSQL In the following database comparison ...
7 MySQL Tutorial DBMS stands for DataBase ...
8 MySQL Tutorial DBMS stands for DataBase ...
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...') ,
('How To Use MySQL Well','After you went through a ...'),
Expand All @@ -36,6 +44,14 @@ INSERT INTO articles (title,body) VALUES
BEGIN;
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...');
# Make durable the AUTO_INCREMENT in the above incomplete transaction.
connect flush_redo_log,localhost,root,,;
SET GLOBAL innodb_flush_log_at_trx_commit=1;
BEGIN;
DELETE FROM articles LIMIT 1;
ROLLBACK;
disconnect flush_redo_log;
connection default;
# Kill and restart
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...');
Expand All @@ -45,10 +61,10 @@ AGAINST ('Database' IN NATURAL LANGUAGE MODE);
id title body
1 MySQL Tutorial DBMS stands for DataBase ...
5 MySQL vs. YourSQL In the following database comparison ...
7 MySQL Tutorial DBMS stands for DataBase ...
8 MySQL Tutorial DBMS stands for DataBase ...
12 MySQL vs. YourSQL In the following database comparison ...
14 MySQL Tutorial DBMS stands for DataBase ...
9 MySQL Tutorial DBMS stands for DataBase ...
13 MySQL vs. YourSQL In the following database comparison ...
16 MySQL Tutorial DBMS stands for DataBase ...
DROP TABLE articles;
CREATE TABLE articles (
id int PRIMARY KEY,
Expand Down
20 changes: 20 additions & 0 deletions mysql-test/suite/innodb_fts/t/crash_recovery.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ BEGIN;
INSERT INTO articles (title,body) VALUES
('MySQL Tutorial','DBMS stands for DataBase ...');

--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction.
--connect (flush_redo_log,localhost,root,,)
SET GLOBAL innodb_flush_log_at_trx_commit=1;
BEGIN;
DELETE FROM articles LIMIT 1;
ROLLBACK;
--disconnect flush_redo_log
--connection default

--source include/kill_and_restart_mysqld.inc

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

--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction.
--connect (flush_redo_log,localhost,root,,)
SET GLOBAL innodb_flush_log_at_trx_commit=1;
BEGIN;
DELETE FROM articles LIMIT 1;
ROLLBACK;
--disconnect flush_redo_log
--connection default

--source include/kill_and_restart_mysqld.inc

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

BEGIN;

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

Expand Down

0 comments on commit 3c411e3

Please sign in to comment.