| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/count_sessions.inc |
| 3 |
--source include/have_debug.inc |
| 4 |
--source include/have_debug_sync.inc |
| 5 |
|
| 6 |
SET @old_innodb_enable_xap_unlock_unmodified_for_primary_debug= |
| 7 |
@@GLOBAL.innodb_enable_xap_unlock_unmodified_for_primary_debug; |
| 8 |
SET GLOBAL innodb_enable_xap_unlock_unmodified_for_primary_debug= 1; |
| 9 |
|
| 10 |
SET @saved_dbug = @@GLOBAL.debug_dbug; |
| 11 |
|
| 12 |
CREATE TABLE t(id INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=0; |
| 13 |
|
| 14 |
--let $i = 2 |
| 15 |
|
| 16 |
while ($i) { |
| 17 |
--source include/wait_all_purged.inc |
| 18 |
|
| 19 |
INSERT INTO t VALUES (10), (20), (30); |
| 20 |
|
| 21 |
--connect(prevent_purge,localhost,root,,) |
| 22 |
start transaction with consistent snapshot; |
| 23 |
|
| 24 |
--connection default |
| 25 |
DELETE FROM t WHERE id = 20; |
| 26 |
|
| 27 |
SET @@GLOBAL.debug_dbug= |
| 28 |
"+d,enable_row_purge_remove_clust_if_poss_low_sync_point"; |
| 29 |
|
| 30 |
# Cover both lock_release_on_prepare() and lock_release_on_prepare_try() |
| 31 |
# functions |
| 32 |
if ($i == 1) { |
| 33 |
SET @@GLOBAL.debug_dbug="+d,skip_lock_release_on_prepare_try"; |
| 34 |
} |
| 35 |
|
| 36 |
XA START '1'; |
| 37 |
UPDATE t SET id=40 WHERE id=30; |
| 38 |
XA END '1'; |
| 39 |
|
| 40 |
--connection prevent_purge |
| 41 |
COMMIT; |
| 42 |
|
| 43 |
# stop purge worker after it requested page X-latch, but before |
| 44 |
# lock_update_delete() call |
| 45 |
SET DEBUG_SYNC= |
| 46 |
'now WAIT_FOR row_purge_remove_clust_if_poss_low_before_delete'; |
| 47 |
SET @@GLOBAL.debug_dbug= |
| 48 |
"-d,enable_row_purge_remove_clust_if_poss_low_sync_point"; |
| 49 |
|
| 50 |
--connection default |
| 51 |
# lock_rec_unlock_unmodified() is executed either under lock_sys.wr_lock() or |
| 52 |
# under a combination of lock_sys.rd_lock() + record locks hash table cell |
| 53 |
# latch. Stop it before page latch request. |
| 54 |
SET DEBUG_SYNC= |
| 55 |
"lock_rec_unlock_unmodified_start SIGNAL lock_sys_latched WAIT_FOR cont"; |
| 56 |
--send XA PREPARE '1' |
| 57 |
|
| 58 |
--connection prevent_purge |
| 59 |
# let purge thread to continue execution and invoke lock_update_delete(), |
| 60 |
# which, in turns, requests locks_sys related latches. |
| 61 |
SET DEBUG_SYNC= 'now SIGNAL row_purge_remove_clust_if_poss_low_cont'; |
| 62 |
SET DEBUG_SYNC= 'now SIGNAL cont'; |
| 63 |
--disconnect prevent_purge |
| 64 |
|
| 65 |
--connection default |
| 66 |
# deadlock if the bug is not fixed, as lock_rec_unlock_unmodified() requests |
| 67 |
# page latch acquired by purge worker, and the purge worker requests lock_sys |
| 68 |
# related latches in lock_update_delete() call, acquired by the current XA |
| 69 |
# in lock_rec_unlock_unmodified() caller. |
| 70 |
--reap |
| 71 |
XA COMMIT '1'; |
| 72 |
|
| 73 |
SET DEBUG_SYNC="RESET"; |
| 74 |
|
| 75 |
TRUNCATE TABLE t; |
| 76 |
|
| 77 |
--dec $i |
| 78 |
} |
| 79 |
|
| 80 |
SET @@GLOBAL.debug_dbug = @saved_dbug; |
| 81 |
DROP TABLE t; |
| 82 |
|
| 83 |
SET GLOBAL innodb_enable_xap_unlock_unmodified_for_primary_debug= |
| 84 |
@old_innodb_enable_xap_unlock_unmodified_for_primary_debug; |
| 85 |
|
| 86 |
--source include/wait_until_count_sessions.inc |