| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that gtid_state->update_gtids_impl does not take |
| 4 |
# global_sid_lock before gtid_mode_lock. It once did, and this could |
| 5 |
# lead to a deadlock with a concurrent SET GTID_MODE. |
| 6 |
# |
| 7 |
# Note: if we implement on-the-fly lock order validation with |
| 8 |
# assertions in the server, we can remove this test. |
| 9 |
# |
| 10 |
# ==== Implementation ==== |
| 11 |
# |
| 12 |
# 1. server_1 starts to execute an INSERT. It pauses before it takes |
| 13 |
# global_sid_lock in gtid_state->update_gtids_impl (sync point |
| 14 |
# 'update_gtid_state_before_global_sid_lock). It signals to default |
| 15 |
# that it has reached this point (signal 'before_global_sid_lock'). |
| 16 |
# |
| 17 |
# 2. default receives 'before_global_sid_lock'. |
| 18 |
# |
| 19 |
# 3. server_1_1 starts to execute SET GTID_MODE. It takes |
| 20 |
# gtid_mode_lock. Then it pauses before it takes global_sid_lock |
| 21 |
# (sync point 'after_log_file_name_initialized'). At the same time |
| 22 |
# it signals server_1 to continue (signal 'have_gtid_mode_lock'). |
| 23 |
# |
| 24 |
# 4. server_1 unpauses. Then it takes global_sid_lock. Then it signals |
| 25 |
# to server_1_1 to continue (signal 'have_global_sid_lock' from |
| 26 |
# sync point 'update_gtid_state_after_global_sid_lock'). |
| 27 |
# |
| 28 |
# 5. server_1 continues; it holds global_sid_lock and tries to acquire |
| 29 |
# gtid_mode_lock. |
| 30 |
# |
| 31 |
# 6. server_1_1 continues; it holds gtid_mode_lock and tries to acquire |
| 32 |
# global_sid_lock. |
| 33 |
|
| 34 |
--source include/big_test.inc |
| 35 |
--source include/have_debug_sync.inc |
| 36 |
# One binlog_format is enough. |
| 37 |
--source include/have_binlog_format_statement.inc |
| 38 |
# One gtid_mode is enough. |
| 39 |
--let $rpl_topology= none |
| 40 |
--source include/rpl_init.inc |
| 41 |
|
| 42 |
CREATE TABLE t1 (a INT); |
| 43 |
|
| 44 |
--connection server_1 |
| 45 |
# 1. wait before global_sid_lock in update_gtids_impl. |
| 46 |
SET @@SESSION.DEBUG_SYNC = 'update_gtid_state_before_global_sid_lock SIGNAL before_global_sid_lock WAIT_FOR have_gtid_mode_lock'; |
| 47 |
# 4. once released, take global_sid_lock, signal SET GTID_MODE to continue. |
| 48 |
# 5. continue into the deadlock. |
| 49 |
SET @@SESSION.DEBUG_SYNC = 'update_gtid_state_after_global_sid_lock SIGNAL have_global_sid_lock'; |
| 50 |
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'; |
| 51 |
send INSERT INTO t1 VALUES (1); |
| 52 |
|
| 53 |
# 2. wait for INSERT to be just before the global_sid_lock. |
| 54 |
--connection default |
| 55 |
SET @@SESSION.DEBUG_SYNC = 'now WAIT_FOR before_global_sid_lock'; |
| 56 |
|
| 57 |
--connection server_1_1 |
| 58 |
# 3. wait when holding gtid_mode_lock, before takeing global_sid_lock. |
| 59 |
# 6. once the INSERT has taken global_sid_lock, unpause and hit the deadlock |
| 60 |
SET @@SESSION.DEBUG_SYNC= 'after_log_file_name_initialized SIGNAL have_gtid_mode_lock WAIT_FOR have_global_sid_lock'; |
| 61 |
SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE; |
| 62 |
|
| 63 |
--connection server_1 |
| 64 |
--reap |
| 65 |
|
| 66 |
SET @@GLOBAL.GTID_MODE = OFF; |
| 67 |
DROP TABLE t1; |