| 1 |
# We want a page split in this test case, to make it easy, we specify the |
| 2 |
# page size as 16K only. This deadlock issue is not related to page size. |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
|
| 5 |
--source include/count_sessions.inc |
| 6 |
|
| 7 |
# This test case requires the table and the DDTableBuffer in the same |
| 8 |
# tablespace. However, it could become invalid after we move DDTableBuffer |
| 9 |
# to a separate tablespace. |
| 10 |
CREATE TABLE t1 ( |
| 11 |
a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 12 |
b varchar(500), |
| 13 |
c varchar(500), |
| 14 |
d varchar(500), |
| 15 |
e varchar(500)) ENGINE = InnoDB TABLESPACE = innodb_system; |
| 16 |
|
| 17 |
CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE = InnoDB; |
| 18 |
|
| 19 |
# We need so many(7) and so long rows to fill up the page quickly, |
| 20 |
# so that the next insert would trigger a page split |
| 21 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0a', 250), repeat('1a', 250), repeat('2a', 250), repeat('3a', 250)); |
| 22 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0b', 250), repeat('1b', 250), repeat('2b', 250), repeat('3b', 250)); |
| 23 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0c', 250), repeat('1c', 250), repeat('2c', 250), repeat('3c', 250)); |
| 24 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0d', 250), repeat('1d', 250), repeat('2d', 250), repeat('3d', 250)); |
| 25 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0e', 250), repeat('1e', 250), repeat('2e', 250), repeat('3e', 250)); |
| 26 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0f', 250), repeat('1f', 250), repeat('2f', 250), repeat('3f', 250)); |
| 27 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0g', 250), repeat('1g', 250), repeat('2g', 250), repeat('3g', 250)); |
| 28 |
|
| 29 |
INSERT INTO t2 VALUES(0), (0), (0); |
| 30 |
|
| 31 |
--echo # Invoke checkpoint to persist metadata of t2 to DDTableBuffer |
| 32 |
SET @start_global_value = @@global.innodb_log_checkpoint_now; |
| 33 |
set global innodb_log_checkpoint_now=ON; |
| 34 |
SET @@global.innodb_log_checkpoint_now = @start_global_value; |
| 35 |
|
| 36 |
connect (con1,localhost,root,,); |
| 37 |
connect (con2,localhost,root,,); |
| 38 |
connection con1; |
| 39 |
|
| 40 |
SET DEBUG_SYNC='delete_metadata_before SIGNAL delete WAIT_FOR insert'; |
| 41 |
--send |
| 42 |
ALTER TABLE t2 ADD COLUMN b INT, ALGORITHM=INPLACE; |
| 43 |
|
| 44 |
connection default; |
| 45 |
SET DEBUG_SYNC='now WAIT_FOR delete'; |
| 46 |
--send |
| 47 |
INSERT INTO t1(b, c, d, e) VALUES(repeat('0a', 250), repeat('1a', 250), repeat('2a', 250), repeat('3a', 250)); |
| 48 |
|
| 49 |
connection con2; |
| 50 |
# It would be better to have 2 DEBUG_SYNC in the code and the test file to |
| 51 |
# reproduce the deadlock. However, once we fix the deadlock, it would never |
| 52 |
# get the the DEBUG_SYNC in INSERT path because the mutex is now acquired |
| 53 |
# before the DEBUG_SYNC. So we sleep here and this would make sure the test |
| 54 |
# can pass with the fix. |
| 55 |
sleep 2; |
| 56 |
SET DEBUG_SYNC='now SIGNAL insert'; |
| 57 |
disconnect con2; |
| 58 |
|
| 59 |
connection con1; |
| 60 |
reap; |
| 61 |
disconnect con1; |
| 62 |
connection default; |
| 63 |
reap; |
| 64 |
SET DEBUG_SYNC='RESET'; |
| 65 |
|
| 66 |
SELECT count(*) FROM t1; |
| 67 |
SELECT count(*) FROM t2; |
| 68 |
SHOW CREATE TABLE t2; |
| 69 |
DROP TABLE t1, t2; |
| 70 |
|
| 71 |
--source include/wait_until_count_sessions.inc |