1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-35109 PREP: simulate_delay_semisync_slave_reply use debug_sync

This is a preparatory commit for MDEV-35109 to make its
testing code cleaner (and harden other tests too).

The DEBUG_DBUG point simulate_delay_semisync_slave_reply
up to this patch used my_sleep() to delay an ACK response,
but sleeps are prone to test failures on machines that
run tests when already having a heavy load (e.g. on
buildbot).

This patch changes this DEBUG_DBUG sleep to use DEBUG_SYNC
to coordinate exactly when a slave should send its reply,
which is safer and faster.

As DEBUG_SYNC can't be used while a server is shutting
down, to synchronize threads with SHUTDOWN WAIT FOR SLAVES
logic, we use and extend wait_for_pattern_in_file.inc to
wait for an informational error message in the logic to
indicate that the shutdown process has reached the
intended state (i.e. indicating that the shutdown has
been delayed to await semi-sync ACKs). Specifically, the
extensions are as follows:

 1. wait_for_pattern_in_file.inc is extended with parameter
    wait_for_pattern_count as a number that indicates the
    number of times a pattern should occur in the file before
    return control back to the calling script.

 2. search_for_pattern_in_file.inc is extended with parameter
    SEARCH_ABORT_IS_SUCCESS to inverse the error/success
    logic, so the SEARCH_ABORT condition can be used to
    indicate success, rather than error.
This commit is contained in:
Brandon Nesterenko
2024-11-01 13:13:07 -06:00
parent f2bb2ab58c
commit 5290fa043b
8 changed files with 206 additions and 24 deletions

View File

@@ -18,6 +18,23 @@
# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this
# will abort if the search result doesn't match the requested one.
#
# Optionally, SEARCH_ABORT_IS_SUCCESS can be set to inverse the error logic
# when the SEARCH_ABORT condition is met. The specific cases and behaviors
# become:
#
# 1) In the normal case (SEARCH_ABORT_IS_SUCCESS is NOT set), when the
# matching result (FOUND N or NOT FOUND) matches SEARCH_ABORT, exit in
# error (via die); otherwise, we assume success and print the matching
# result. This is used in the normal search_pattern_in_file.inc case,
# as well as wait_for_pattern_in_file.inc when searching that some
# pattern exists at all (i.e. a result of NOT FOUND will trigger die,
# so the script can continue waiting until the result is found, and
# finally print the result).
#
# 2) If SEARCH_ABORT_IS_SUCCESS is set, then we want to inverse the logic
# from case (1). That is, if the match result is SEARCH_ABORT, this
# is the success case, and we die for all other matching results.
#
# Optionally, SEARCH_OUTPUT can be set to control the format of output.
# Supported formats:
# - (default) : "FOUND n /pattern/ in FILE " or "NOT FOUND ..."
@@ -82,14 +99,26 @@ perl;
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
my $print_func= sub { print($_[0]); };
my $die_func= sub { die($_[0]); };
my $abort_func;
my $match_func;
if ($ENV{SEARCH_ABORT} and $ENV{SEARCH_ABORT_IS_SUCCESS}) {
$abort_func= \&$print_func;
$match_func= \&$die_func;
} else {
$abort_func= \&$die_func;
$match_func= \&$print_func;
}
if ($ENV{SEARCH_OUTPUT} eq "matches") {
foreach (@matches) {
print $_ . "\n";
}
}
elsif ($ENV{SEARCH_ABORT} and $res =~ /^$ENV{SEARCH_ABORT}/) {
die "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
&$abort_func("$res /$search_pattern/ in $ENV{SEARCH_FILE}\n");
} else {
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
&$match_func("$res /$search_pattern/ in $ENV{SEARCH_FILE}\n");
}
EOF