| 1 |
# suite/t/rpl_ndb/wait_schema_logging.inc |
| 2 |
# |
| 3 |
# SUMMARY |
| 4 |
# Waits until schema op performed on $source_server is |
| 5 |
# being logged by $dest_server |
| 6 |
# Assumes that source_server and dest_server are connected |
| 7 |
# to the same cluster |
| 8 |
# Assumes that $dest_server has binlogging enabled. |
| 9 |
# |
| 10 |
############################################################### |
| 11 |
# Include file to wait for schema logging setup, where schema |
| 12 |
# changes made on $source_server are logged on $dest_server |
| 13 |
############################################################### |
| 14 |
|
| 15 |
connection $dest_server; |
| 16 |
|
| 17 |
#--echo Waiting for schema event logging to be active between $source_server and $dest_server |
| 18 |
#--echo - First check that $dest_server has binary logging enabled |
| 19 |
|
| 20 |
let $binlog= query_get_value(show variables like 'log_bin', Value, 1); |
| 21 |
if (`SELECT "$binlog" != "ON"`) |
| 22 |
{ |
| 23 |
show variables like 'server_id'; |
| 24 |
show variables like 'log_bin'; |
| 25 |
--die ERROR: Binlogging not activated |
| 26 |
} |
| 27 |
|
| 28 |
--disable_query_log |
| 29 |
RESET MASTER; |
| 30 |
--enable_query_log |
| 31 |
|
| 32 |
# Following code 'inspired' by include/wait_for_binlog_event.inc |
| 33 |
|
| 34 |
--let $wait_binlog_event=drop table |
| 35 |
|
| 36 |
let $_loop_count= 10; |
| 37 |
let $_event= ; |
| 38 |
let $_event_pos= 1; |
| 39 |
|
| 40 |
while (`SELECT INSTR("$_event","$wait_binlog_event") = 0`) |
| 41 |
{ |
| 42 |
#--echo loop_count is $_loop_count; |
| 43 |
dec $_loop_count; |
| 44 |
if (!$_loop_count) |
| 45 |
{ |
| 46 |
SHOW BINLOG EVENTS; |
| 47 |
--die ERROR: failed while waiting local cluster schema event logging to start |
| 48 |
} |
| 49 |
|
| 50 |
connection $source_server; |
| 51 |
--disable_query_log |
| 52 |
create table wait_schema_logging (a int primary key) engine=ndb; |
| 53 |
drop table wait_schema_logging; |
| 54 |
--enable_query_log |
| 55 |
connection $dest_server; |
| 56 |
|
| 57 |
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos); |
| 58 |
#--echo Event is : $_event |
| 59 |
while (`SELECT ("$_event" != "No such row") and (INSTR("$_event", "$wait_binlog_event") = 0)`) |
| 60 |
{ |
| 61 |
inc $_event_pos; |
| 62 |
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos); |
| 63 |
#--echo Event did not match- next event is $_event; |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
# Since we're attached to the same cluster, if we've seen the event |
| 68 |
# then synchronous binlogging of changes is on (i.e. synchronous with |
| 69 |
# the original schema change) |
| 70 |
# Therefore it should now be safe to reset the master on the destination |
| 71 |
# server as no more binlog changes are in-flight. |
| 72 |
connection $dest_server; |
| 73 |
|
| 74 |
--disable_query_log |
| 75 |
RESET MASTER; |
| 76 |
--enable_query_log |
| 77 |
|
| 78 |
#--echo - Schema event logging is active |