diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /mysql-test/include/wait_for_binlog_checkpoint.inc | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-upstream.tar.xz mariadb-10.5-upstream.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/include/wait_for_binlog_checkpoint.inc')
-rw-r--r-- | mysql-test/include/wait_for_binlog_checkpoint.inc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mysql-test/include/wait_for_binlog_checkpoint.inc b/mysql-test/include/wait_for_binlog_checkpoint.inc new file mode 100644 index 00000000..960cf4e4 --- /dev/null +++ b/mysql-test/include/wait_for_binlog_checkpoint.inc @@ -0,0 +1,53 @@ +# include/wait_for_binlog_checkpoint.inc +# +# SUMMARY +# +# Wait until binlog checkpoint has been logged for current binlog file. +# This is useful to avoid races with output difference for binlog +# checkpoints, as these are logged asynchronously from the binlog +# background thread. +# +# USAGE: +# +# --source include/wait_for_binlog_checkpoint.inc + +let $_wait_count= 300; + +let $_found= 0; + +while ($_wait_count) +{ + dec $_wait_count; + let $_cur_binlog= query_get_value(SHOW MASTER STATUS, File, 1); + let $_more= 1; + let $_row= 1; + while ($_more) + { + let $_event= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Event_type, $_row); + if ($_event == "No such row") + { + let $_more= 0; + } + if ($_event == "Binlog_checkpoint") + { + let $_info= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Info, $_row); + if (`SELECT INSTR("$_info", "$_cur_binlog") != 0`) + { + let $_more= 0; + let $_wait_count= 0; + let $_found= 1; + } + } + inc $_row; + } + if ($_wait_count) + { + real_sleep 0.1; + } +} + +if (!$_found) +{ + eval SHOW BINLOG EVENTS IN "$_cur_binlog"; + --die ERROR: failed while waiting for binlog checkpoint $_cur_binlog +} |