| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug.inc |
| 3 |
--source include/count_sessions.inc |
| 4 |
|
| 5 |
CREATE TABLE t ( |
| 6 |
`a` INT NOT NULL, |
| 7 |
`b` INT NOT NULL, |
| 8 |
PRIMARY KEY (`a`) |
| 9 |
) ENGINE=InnoDB; |
| 10 |
|
| 11 |
--disable_query_log |
| 12 |
SET @old_innodb_limit_optimistic_insert_debug = @@innodb_limit_optimistic_insert_debug; |
| 13 |
--enable_query_log |
| 14 |
|
| 15 |
SET GLOBAL innodb_limit_optimistic_insert_debug = 3; |
| 16 |
|
| 17 |
INSERT INTO t VALUES(10, 0); |
| 18 |
INSERT INTO t VALUES(20, 0); |
| 19 |
INSERT INTO t VALUES(30, 0); |
| 20 |
|
| 21 |
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; |
| 22 |
XA START '1'; |
| 23 |
REPLACE INTO t VALUES(10, 1); |
| 24 |
REPLACE INTO t VALUES(20, 1); |
| 25 |
|
| 26 |
# We need the following sync point because mysql_insert() resets |
| 27 |
# trx->duplicates with the following condition: |
| 28 |
# |
| 29 |
# if (duplic == DUP_REPLACE && |
| 30 |
# (!table->triggers || !table->triggers->has_delete_triggers())) |
| 31 |
# table->file->extra(HA_EXTRA_WRITE_CANNOT_REPLACE); |
| 32 |
# |
| 33 |
# and ha_innobase::extra() resets trx_t::duplicates, but we need |
| 34 |
# lock_update_split_right() to be invoked when trx->duplicates is set to |
| 35 |
# repeat the bug. So the transaction will hang just after |
| 36 |
# row_insert_for_mysql() call until another transaction inserts new row and |
| 37 |
# splits the page. |
| 38 |
SET DEBUG_SYNC= 'ib_after_row_insert SIGNAL inserted WAIT_FOR cont'; |
| 39 |
--send REPLACE INTO t VALUES(30, 1) |
| 40 |
|
| 41 |
connect (con1,localhost,root); |
| 42 |
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; |
| 43 |
XA START '2'; |
| 44 |
SET DEBUG_SYNC= 'now WAIT_FOR inserted'; |
| 45 |
# The following statement will cause page split and (20, ...) will be split |
| 46 |
# record. As the previous REPLACE set non-gap X-lock on it, |
| 47 |
# lock_update_split_right() and lock_rec_inherit_to_gap() will 'inherit' the |
| 48 |
# lock from the very first (20, ...) new right page record to the supremum of |
| 49 |
# the old left page, what should not be for READ COMMITTED isolation level |
| 50 |
INSERT INTO t VALUES(40, 2); |
| 51 |
SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 52 |
|
| 53 |
--connection default |
| 54 |
--reap |
| 55 |
XA END '1'; |
| 56 |
# This will cause the assertion failure, because the supremum of the left page |
| 57 |
# has X-lock. |
| 58 |
XA PREPARE '1'; |
| 59 |
--connection default |
| 60 |
XA COMMIT '1'; |
| 61 |
|
| 62 |
--connection con1 |
| 63 |
XA END '2'; |
| 64 |
XA PREPARE '2'; |
| 65 |
XA COMMIT '2'; |
| 66 |
--disconnect con1 |
| 67 |
|
| 68 |
--connection default |
| 69 |
SET DEBUG_SYNC= "RESET"; |
| 70 |
DROP TABLE t; |
| 71 |
|
| 72 |
--disable_query_log |
| 73 |
SET GLOBAL innodb_limit_optimistic_insert_debug = @old_innodb_limit_optimistic_insert_debug; |
| 74 |
--enable_query_log |
| 75 |
|
| 76 |
--source include/wait_until_count_sessions.inc |