| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# If using DEBUG_SYNC to coordinate a slave's SQL DELAY via the DEBUG_DBUG |
| 4 |
# identifier "sql_delay_by_debug_sync", this helper file will help synchronize |
| 5 |
# a slave with the master for statements which don't need to be delayed. This |
| 6 |
# can be helpful, for example, for setup/cleanup statements, if they must be |
| 7 |
# run in the same lifetime as the statements used for the test. |
| 8 |
# |
| 9 |
# The actual synchronization will take place based on the input parameter |
| 10 |
# slave_sync_method, which can be "gtid", "file_coord", or "none"; and will use |
| 11 |
# the helper files sync_with_master_gtid.inc or sync_with_master.inc (or none |
| 12 |
# at all), respectively. |
| 13 |
# |
| 14 |
# |
| 15 |
# ==== Requirements ==== |
| 16 |
# |
| 17 |
# --source include/have_debug.inc |
| 18 |
# --source include/have_debug_sync.inc |
| 19 |
# set @@GLOBAL.debug_dbug= "+d,sql_delay_by_debug_sync"; |
| 20 |
# |
| 21 |
# |
| 22 |
# ==== Usage ==== |
| 23 |
# |
| 24 |
# --let $slave_sync_method= gtid|file_coord|none |
| 25 |
# [--let $num_event_groups= NUMBER] |
| 26 |
# --source include/sync_with_master_sql_delay_debug_sync.inc |
| 27 |
# |
| 28 |
# |
| 29 |
# Parameters: |
| 30 |
# $slave_sync_method |
| 31 |
# Value can be gtid, file_coord, or none; and will synchronize the slave |
| 32 |
# with the master via this method (i.e. using sync_with_master_gtid.inc |
| 33 |
# or sync_with_master.inc, respectively), after synchronizing the SQL |
| 34 |
# delay |
| 35 |
# |
| 36 |
# $num_event_groups |
| 37 |
# Number of event groups to synchronize the SQL delay for. If unset, will |
| 38 |
# be default to 1. |
| 39 |
# |
| 40 |
|
| 41 |
--let $include_filename= sync_with_master_sql_delay_debug_sync.inc |
| 42 |
--source include/begin_include_file.inc |
| 43 |
|
| 44 |
if (!$slave_sync_method) |
| 45 |
{ |
| 46 |
--die Parameter slave_sync_method must be set |
| 47 |
} |
| 48 |
|
| 49 |
if (`select "$slave_sync_method" not like "gtid" and "$slave_sync_method" not like "file_coord" and "$slave_sync_method" not like "none"`) |
| 50 |
{ |
| 51 |
--die Parameter slave_sync_method must have value "gtid", "file_coord" or "none" |
| 52 |
} |
| 53 |
|
| 54 |
if (`select "$slave_sync_method" not like "none" and strcmp("$master_pos", "") = 0`) |
| 55 |
{ |
| 56 |
--die sync_with_master.inc or sync_with_master_gtid.inc was not called to populate variable master_pos |
| 57 |
} |
| 58 |
|
| 59 |
if (!$num_event_groups) |
| 60 |
{ |
| 61 |
--let $num_event_groups= 1 |
| 62 |
} |
| 63 |
|
| 64 |
while ($num_event_groups) |
| 65 |
{ |
| 66 |
set debug_sync= "now WAIT_FOR at_sql_delay"; |
| 67 |
set debug_sync= "now SIGNAL continue_sql_thread"; |
| 68 |
--dec $num_event_groups |
| 69 |
} |
| 70 |
|
| 71 |
if (`select "$slave_sync_method" LIKE "gtid"`) |
| 72 |
{ |
| 73 |
--source include/sync_with_master_gtid.inc |
| 74 |
} |
| 75 |
|
| 76 |
if (`select "$slave_sync_method" LIKE "file_coord"`) |
| 77 |
{ |
| 78 |
--source include/sync_with_master.inc |
| 79 |
} |
| 80 |
|
| 81 |
--let $include_filename= sync_with_master_sql_delay_debug_sync.inc |
| 82 |
--source include/end_include_file.inc |