| 1 |
--source include/not_group_replication_plugin.inc |
| 2 |
# This test assumes 4 workers are used |
| 3 |
--let $option_name = replica_parallel_workers |
| 4 |
--let $option_value = 4 |
| 5 |
--source include/only_with_option.inc |
| 6 |
--source include/only_mts_replica_parallel_type_logical_clock.inc |
| 7 |
--source include/have_debug.inc |
| 8 |
--source include/have_debug_sync.inc |
| 9 |
--source include/have_binlog_format_row.inc |
| 10 |
--source include/master-slave.inc |
| 11 |
|
| 12 |
################################################################################ |
| 13 |
# BUG#19641963 RPL.RPL_SEMI_SYNC_GROUP_COMMIT_DEADLOCK FAILS WITH ASSERT IN |
| 14 |
# MTS CODE |
| 15 |
# |
| 16 |
# The assertion failure happened in below case: |
| 17 |
# Coord Worker1 Worker2 |
| 18 |
# ===== ======== ======== |
| 19 |
# applying ts 3 applying ts 4 |
| 20 |
# min_waited_timestamp=3 |
| 21 |
# waiting for the signal |
| 22 |
# from a worker |
| 23 |
# mark ts 3 finished mark ts 4 finished |
| 24 |
# |
| 25 |
# slave_worker_ends_group slave_worker_ends_group |
| 26 |
# store store |
| 27 |
# min_waited_timestamp(3) min_waited_timestamp(3) |
| 28 |
# into a local variable into a local variable |
| 29 |
# |
| 30 |
# find the local variable |
| 31 |
# is not SEQ_UNINIT, so |
| 32 |
# update lwm to 4 |
| 33 |
# (get_lwm_timestamp) |
| 34 |
# signal coordinator lwm |
| 35 |
# is changed |
| 36 |
# |
| 37 |
# get the signal from Worker2 |
| 38 |
# set min_waited_timestamp=0 |
| 39 |
# dispatch ts 5 |
| 40 |
# applying ts 5 |
| 41 |
# |
| 42 |
# dispatch ts 7(have a gap, |
| 43 |
# ts 6 is not in the binlog) |
| 44 |
# waiting for all workers |
| 45 |
# to finish |
| 46 |
# |
| 47 |
# mta_checkpoint_routine |
| 48 |
# remove ts 3,4 from GAQ |
| 49 |
# lwm = 5. GAQ head is ts 7 |
| 50 |
# find the local variable |
| 51 |
# is not SEQ_UNINIT, so it |
| 52 |
# calls get_lwm_timestamp to |
| 53 |
# update lwm and |
| 54 |
# assertion failure happens |
| 55 |
# in get_lwm_timestamp() |
| 56 |
# assert lwm(5)+1 == GAQ head ts(7) |
| 57 |
# |
| 58 |
# The test verifys that the assertion failure doesn't happen. |
| 59 |
################################################################################ |
| 60 |
--source include/rpl_connection_slave.inc |
| 61 |
SET @saved_innodb_lock_wait_timeout = @@GLOBAL.innodb_lock_wait_timeout; |
| 62 |
SET GLOBAL innodb_lock_wait_timeout = 1000; |
| 63 |
--source include/restart_slave_sql.inc |
| 64 |
|
| 65 |
--source include/rpl_connection_master.inc |
| 66 |
CREATE TABLE t1(c1 INT PRIMARY KEY); |
| 67 |
CREATE TABLE t2(c1 INT PRIMARY KEY); |
| 68 |
|
| 69 |
--source include/sync_slave_sql_with_master.inc |
| 70 |
# |
| 71 |
# Below two transactions will pause two workers and make coordinator |
| 72 |
# in the status that it is waiting for a timestamp to be applied. |
| 73 |
# |
| 74 |
# Blocking the worker applying the same statement |
| 75 |
BEGIN; |
| 76 |
INSERT INTO t1 VALUES(1); |
| 77 |
|
| 78 |
# Blocking the worker applying the same statement |
| 79 |
--source include/rpl_connection_slave1.inc |
| 80 |
BEGIN; |
| 81 |
INSERT INTO t2 VALUES(1); |
| 82 |
|
| 83 |
--source include/rpl_connection_master.inc |
| 84 |
|
| 85 |
# Two transactions have same commit parent, so they can be applied parallel |
| 86 |
SET debug = '+d,set_commit_parent_100'; |
| 87 |
INSERT INTO t1 VALUES(1); |
| 88 |
INSERT INTO t2 VALUES(1); |
| 89 |
SET debug = '-d,set_commit_parent_100'; |
| 90 |
|
| 91 |
# Its commit parent is the sequence_number of INSERT INTO t2 VALUES(1); |
| 92 |
# So coordinator has to wait for the INSERT to be applied. |
| 93 |
INSERT INTO t1 VALUES(2); |
| 94 |
|
| 95 |
# Increments timestamp twice to generate a timestamp gap. |
| 96 |
SET debug = '+d,logical_clock_step_2'; |
| 97 |
INSERT INTO t1 VALUES(3); |
| 98 |
SET debug = '-d,logical_clock_step_2'; |
| 99 |
|
| 100 |
--source include/save_master_pos.inc |
| 101 |
|
| 102 |
# Make sure coordinator is waiting for a commit parent and |
| 103 |
# guaratee min_waited_timestamp is set to a valid timestamp |
| 104 |
--source include/rpl_connection_slave.inc |
| 105 |
--let $wait_condition = SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state = 'Waiting for dependent transaction to commit' |
| 106 |
--source include/wait_condition.inc |
| 107 |
|
| 108 |
# It will pause the worker after it read min_waited_timestamp |
| 109 |
SET GLOBAL debug = '+d,replica_worker_ends_group_before_signal_lwm'; |
| 110 |
ROLLBACK; |
| 111 |
|
| 112 |
# Make sure the worker read min_waited_timestamp |
| 113 |
--let $wait_condition = SELECT count(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state = 'debug sync point: now' |
| 114 |
--source include/wait_condition.inc |
| 115 |
|
| 116 |
# clear the debug point so other workers are not paused |
| 117 |
SET GLOBAL debug = '-d,replica_worker_ends_group_before_signal_lwm'; |
| 118 |
|
| 119 |
# It will pause coordinator after it finds that all workers finished. |
| 120 |
SET GLOBAL debug = '+d,wait_for_workers_to_finish_after_wait'; |
| 121 |
|
| 122 |
--source include/rpl_connection_slave1.inc |
| 123 |
# Resume the worker applying INSERT INTO t2 VALUES(1) |
| 124 |
ROLLBACK; |
| 125 |
#--let $wait_condition = SELECT count(*) = 3 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state = 'Waiting for an event from Coordinator' |
| 126 |
#--source include/wait_condition.inc |
| 127 |
|
| 128 |
# Make sure coordinator is handling the gap and |
| 129 |
--let $wait_condition = SELECT count(*) = 2 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state = 'debug sync point: now' |
| 130 |
--source include/wait_condition.inc |
| 131 |
|
| 132 |
SET debug_sync='now SIGNAL worker_continue'; |
| 133 |
|
| 134 |
# Make sure the worker applying INSERT INTO t1 VALUES(1) finished |
| 135 |
--let $wait_condition = SELECT count(*) = 4 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state = 'Waiting for an event from Coordinator' |
| 136 |
--source include/wait_condition.inc |
| 137 |
|
| 138 |
# |
| 139 |
# Cleanup |
| 140 |
# |
| 141 |
SET debug_sync='now SIGNAL coordinator_continue'; |
| 142 |
--source include/sync_slave_sql.inc |
| 143 |
SET GLOBAL debug = '-d,wait_for_workers_to_finish_after_wait'; |
| 144 |
|
| 145 |
--source include/rpl_connection_slave.inc |
| 146 |
SET GLOBAL innodb_lock_wait_timeout = @saved_innodb_lock_wait_timeout; |
| 147 |
|
| 148 |
--source include/rpl_connection_master.inc |
| 149 |
DROP TABLE t1, t2; |
| 150 |
--source include/rpl_end.inc |