1# include/wait_for_binlog_checkpoint.inc 2# 3# SUMMARY 4# 5# Wait until binlog checkpoint has been logged for current binlog file. 6# This is useful to avoid races with output difference for binlog 7# checkpoints, as these are logged asynchronously from the binlog 8# background thread. 9# 10# USAGE: 11# 12# --source include/wait_for_binlog_checkpoint.inc 13 14let $_wait_count= 300; 15 16let $_found= 0; 17 18while ($_wait_count) 19{ 20 dec $_wait_count; 21 let $_cur_binlog= query_get_value(SHOW MASTER STATUS, File, 1); 22 let $_more= 1; 23 let $_row= 1; 24 while ($_more) 25 { 26 let $_event= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Event_type, $_row); 27 if ($_event == "No such row") 28 { 29 let $_more= 0; 30 } 31 if ($_event == "Binlog_checkpoint") 32 { 33 let $_info= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Info, $_row); 34 if (`SELECT INSTR("$_info", "$_cur_binlog") != 0`) 35 { 36 let $_more= 0; 37 let $_wait_count= 0; 38 let $_found= 1; 39 } 40 } 41 inc $_row; 42 } 43 if ($_wait_count) 44 { 45 real_sleep 0.1; 46 } 47} 48 49if (!$_found) 50{ 51 eval SHOW BINLOG EVENTS IN "$_cur_binlog"; 52 --die ERROR: failed while waiting for binlog checkpoint $_cur_binlog 53} 54