Skip to content

Commit 2fe40a7

Browse files
committed
MDEV-18009 Missing redo log flush in innodb.instant_alter_crash
Ensure that the 'auxiliary transactions' that are there for flushing the incomplete undo log of the to-be-recovered DDL transactions are actually making modifications.
1 parent 505f283 commit 2fe40a7

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

mysql-test/suite/innodb/r/instant_alter_crash.result

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FLUSH TABLES;
55
CREATE TABLE t1(id INT PRIMARY KEY, c2 INT UNIQUE)
66
ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
77
CREATE TABLE t2 LIKE t1;
8-
INSERT INTO t1 VALUES(1,2);
8+
INSERT INTO t1 VALUES(0,2);
99
BEGIN;
1010
INSERT INTO t2 VALUES(2,1);
1111
ALTER TABLE t2 ADD COLUMN (c3 TEXT NOT NULL DEFAULT 'De finibus bonorum');
@@ -15,16 +15,17 @@ ALTER TABLE t1 ADD COLUMN (c3 TEXT NOT NULL DEFAULT ' et malorum');
1515
connection default;
1616
SET DEBUG_SYNC='now WAIT_FOR ddl';
1717
SET GLOBAL innodb_flush_log_at_trx_commit=1;
18-
COMMIT;
18+
INSERT INTO t2 VALUES(3,4,'accusantium doloremque laudantium');
1919
# Kill the server
2020
disconnect ddl;
2121
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
2222
SELECT * FROM t1;
2323
id c2
24-
1 2
24+
0 2
2525
SELECT * FROM t2;
2626
id c2 c3
2727
2 1 De finibus bonorum
28+
3 4 accusantium doloremque laudantium
2829
BEGIN;
2930
DELETE FROM t1;
3031
ROLLBACK;
@@ -37,16 +38,18 @@ ALTER TABLE t2 DROP COLUMN c3, ADD COLUMN c5 TEXT DEFAULT 'naturam abhorrere';
3738
connection default;
3839
SET DEBUG_SYNC='now WAIT_FOR ddl';
3940
SET GLOBAL innodb_flush_log_at_trx_commit=1;
40-
DELETE FROM t1;
41+
UPDATE t1 SET c2=c2+1;
4142
# Kill the server
4243
disconnect ddl;
4344
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
4445
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
4546
SELECT * FROM t1;
4647
id c2
48+
0 3
4749
SELECT * FROM t2;
4850
id c2 c3
4951
2 1 De finibus bonorum
52+
3 4 accusantium doloremque laudantium
5053
16 1551 Omnium enim rerum
5154
128 1571 principia parva sunt
5255
BEGIN;
@@ -67,11 +70,13 @@ DELETE FROM t1;
6770
disconnect ddl;
6871
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
6972
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
73+
FOUND 3 /\[Note\] InnoDB: Rolled back recovered transaction / in mysqld.1.err
7074
SELECT * FROM t1;
7175
id c2
7276
SELECT * FROM t2;
7377
id c2
7478
2 1
79+
3 4
7580
64 42
7681
16 1551
7782
128 1571
@@ -87,7 +92,7 @@ N_RECS=0; LEVEL=0
8792
header=0x010000030074 (id=0x696e66696d756d00)
8893
header=0x010008030000 (id=0x73757072656d756d00)
8994
t2 clustered index root page(type 18):
90-
N_RECS=6; LEVEL=0
95+
N_RECS=7; LEVEL=0
9196
header=0x01000003008f (id=0x0000000000000000)
9297
header=0x3000100c00d4 (id=0x80000000,
9398
DB_TRX_ID=0x000000000000,
@@ -99,26 +104,31 @@ header=0x0000180900f4 (id=0x80000002,
99104
DB_TRX_ID=0x000000000000,
100105
DB_ROLL_PTR=0x80000000000000,
101106
c2=0x80000001)
102-
header=0x0000200b0124 (id=0x80000010,
107+
header=0x0000200b0135 (id=0x80000003,
108+
DB_TRX_ID=0x000000000000,
109+
DB_ROLL_PTR=0x80000000000000,
110+
c2=0x80000004,
111+
c3=0x6163637573616e7469756d20646f6c6f72656d717565206c617564616e7469756d)
112+
header=0x0000280b0165 (id=0x80000010,
103113
DB_TRX_ID=0x000000000000,
104114
DB_ROLL_PTR=0x80000000000000,
105115
c2=0x8000060f,
106116
c3=0x4f6d6e69756d20656e696d20726572756d)
107-
header=0x000028090144 (id=0x80000040,
117+
header=0x000030090185 (id=0x80000040,
108118
DB_TRX_ID=0x000000000000,
109119
DB_ROLL_PTR=0x80000000000000,
110120
c2=0x8000002a)
111-
header=0x0000300b0179 (id=0x80000080,
121+
header=0x0000380b01ba (id=0x80000080,
112122
DB_TRX_ID=0x000000000000,
113123
DB_ROLL_PTR=0x80000000000000,
114124
c2=0x80000623,
115125
c3=0x207072696e63697069612070617276612073756e74)
116-
header=0x0000380b0074 (id=0x8000015b,
126+
header=0x0000400b0074 (id=0x8000015b,
117127
DB_TRX_ID=0x000000000000,
118128
DB_ROLL_PTR=0x80000000000000,
119129
c2=0x8000814d,
120130
c3=0x206574206d616c6f72756d)
121-
header=0x070008030000 (id=0x000000000000000100)
131+
header=0x080008030000 (id=0x000000000000000100)
122132
UNLOCK TABLES;
123133
DELETE FROM t2;
124134
InnoDB 0 transactions not purged

mysql-test/suite/innodb/t/instant_alter_crash.test

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let MYSQLD_DATADIR=`select @@datadir`;
1616
CREATE TABLE t1(id INT PRIMARY KEY, c2 INT UNIQUE)
1717
ENGINE=InnoDB ROW_FORMAT=REDUNDANT;
1818
CREATE TABLE t2 LIKE t1;
19-
INSERT INTO t1 VALUES(1,2);
19+
INSERT INTO t1 VALUES(0,2);
2020
BEGIN;
2121
INSERT INTO t2 VALUES(2,1);
2222
ALTER TABLE t2 ADD COLUMN (c3 TEXT NOT NULL DEFAULT 'De finibus bonorum');
@@ -29,7 +29,7 @@ ALTER TABLE t1 ADD COLUMN (c3 TEXT NOT NULL DEFAULT ' et malorum');
2929
connection default;
3030
SET DEBUG_SYNC='now WAIT_FOR ddl';
3131
SET GLOBAL innodb_flush_log_at_trx_commit=1;
32-
COMMIT;
32+
INSERT INTO t2 VALUES(3,4,'accusantium doloremque laudantium');
3333

3434
--source include/kill_mysqld.inc
3535
disconnect ddl;
@@ -54,7 +54,7 @@ ALTER TABLE t2 DROP COLUMN c3, ADD COLUMN c5 TEXT DEFAULT 'naturam abhorrere';
5454
connection default;
5555
SET DEBUG_SYNC='now WAIT_FOR ddl';
5656
SET GLOBAL innodb_flush_log_at_trx_commit=1;
57-
DELETE FROM t1;
57+
UPDATE t1 SET c2=c2+1;
5858

5959
--source include/kill_mysqld.inc
6060
disconnect ddl;
@@ -91,6 +91,10 @@ disconnect ddl;
9191
SET @saved_frequency= @@GLOBAL.innodb_purge_rseg_truncate_frequency;
9292
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
9393

94+
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
95+
let SEARCH_PATTERN= \[Note\] InnoDB: Rolled back recovered transaction ;
96+
-- source include/search_pattern_in_file.inc
97+
9498
SELECT * FROM t1;
9599
SELECT * FROM t2;
96100
BEGIN;

0 commit comments

Comments
 (0)