1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-34753 memory pressure - erroneous termination condition

Fix race condition in test case by waiting for the expected state to occur.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
Kristian Nielsen
2024-10-18 16:49:51 +02:00
committed by Daniel Black
parent eb29190398
commit abc46259c6
2 changed files with 53 additions and 25 deletions

View File

@ -18,6 +18,10 @@
# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this # 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. # will abort if the search result doesn't match the requested one.
# #
# Optionally, SEARCH_WAIT can be set to "FOUND" or "NOT FOUND", and this
# will wait for the condition to occur. The timeout can be set in
# SEARCH_TIMEOUT, default is 60 seconds.
#
# Optionally, SEARCH_OUTPUT can be set to control the format of output. # Optionally, SEARCH_OUTPUT can be set to control the format of output.
# Supported formats: # Supported formats:
# - (default) : "FOUND n /pattern/ in FILE " or "NOT FOUND ..." # - (default) : "FOUND n /pattern/ in FILE " or "NOT FOUND ..."
@ -55,6 +59,12 @@ perl;
my @search_files= glob($ENV{SEARCH_FILE}); my @search_files= glob($ENV{SEARCH_FILE});
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set"; my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
my $search_range= $ENV{SEARCH_RANGE}; my $search_range= $ENV{SEARCH_RANGE};
my $timeout= $ENV{SEARCH_TIMEOUT} || 60;
my @matches;
my $res;
my $start_time= time();
for (;;) {
my $content; my $content;
foreach my $search_file (@search_files) { foreach my $search_file (@search_files) {
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!"); open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
@ -78,8 +88,21 @@ perl;
close(FILE); close(FILE);
$content.= $file_content; $content.= $file_content;
} }
my @matches= ($content =~ /$search_pattern/gs); @matches= ($content =~ /$search_pattern/gs);
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND"; $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
if (($ENV{SEARCH_WAIT} eq 'FOUND' && $res eq 'NOT FOUND') ||
($ENV{SEARCH_WAIT} eq 'NOT FOUND' && $res =~ m{^FOUND })) {
if (time() - $start_time < $timeout) {
# Millisceond sleep emulated with select
select(undef, undef, undef, 0.1);
next;
}
die "Timeout waiting for $ENV{SEARCH_WAIT} ".
"for /$search_pattern/ in $ENV{SEARCH_FILE}\n";
}
last;
}
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1}; $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};

View File

@ -38,11 +38,16 @@ let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN= [Mm]emory pressure.*; let SEARCH_PATTERN= [Mm]emory pressure.*;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
# The garbage collection happens asynchronously after trigger, in a background
# thread. So wait for it to happen to avoid sporadic failure.
let $wait_condition=
SELECT CAST(VARIABLE_VALUE AS INTEGER) < @dirty_prev AS LESS_DIRTY_IS_GOOD SELECT CAST(VARIABLE_VALUE AS INTEGER) < @dirty_prev AS LESS_DIRTY_IS_GOOD
FROM INFORMATION_SCHEMA.GLOBAL_STATUS FROM INFORMATION_SCHEMA.GLOBAL_STATUS
WHERE VARIABLE_NAME='Innodb_buffer_pool_pages_dirty'; WHERE VARIABLE_NAME='Innodb_buffer_pool_pages_dirty';
--source include/wait_condition.inc
eval $wait_condition;
let SEARCH_PATTERN= InnoDB: Memory pressure event freed.*; let SEARCH_PATTERN= InnoDB: Memory pressure event freed.*;
let SEARCH_WAIT= FOUND;
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
set debug_dbug=@save_dbug; set debug_dbug=@save_dbug;