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:
committed by
Daniel Black
parent
eb29190398
commit
abc46259c6
@ -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,31 +59,50 @@ 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 $content;
|
my $timeout= $ENV{SEARCH_TIMEOUT} || 60;
|
||||||
foreach my $search_file (@search_files) {
|
my @matches;
|
||||||
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
|
my $res;
|
||||||
my $file_content;
|
|
||||||
if ($search_range > 0) {
|
my $start_time= time();
|
||||||
read(FILE, $file_content, $search_range, 0);
|
for (;;) {
|
||||||
} elsif ($search_range < 0) {
|
my $content;
|
||||||
my $size= -s $search_file;
|
foreach my $search_file (@search_files) {
|
||||||
$search_range = -$size if $size > -$search_range;
|
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
|
||||||
seek(FILE, $search_range, 2);
|
my $file_content;
|
||||||
read(FILE, $file_content, -$search_range, 0);
|
if ($search_range > 0) {
|
||||||
} else {
|
read(FILE, $file_content, $search_range, 0);
|
||||||
while(<FILE>) { # error log
|
} elsif ($search_range < 0) {
|
||||||
if (/^CURRENT_TEST:/) {
|
my $size= -s $search_file;
|
||||||
$content='';
|
$search_range = -$size if $size > -$search_range;
|
||||||
|
seek(FILE, $search_range, 2);
|
||||||
|
read(FILE, $file_content, -$search_range, 0);
|
||||||
} else {
|
} else {
|
||||||
$content.=$_;
|
while(<FILE>) { # error log
|
||||||
|
if (/^CURRENT_TEST:/) {
|
||||||
|
$content='';
|
||||||
|
} else {
|
||||||
|
$content.=$_;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
close(FILE);
|
||||||
|
$content.= $file_content;
|
||||||
}
|
}
|
||||||
close(FILE);
|
@matches= ($content =~ /$search_pattern/gs);
|
||||||
$content.= $file_content;
|
$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;
|
||||||
}
|
}
|
||||||
my @matches= ($content =~ /$search_pattern/gs);
|
|
||||||
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
|
|
||||||
|
|
||||||
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
|
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
SELECT CAST(VARIABLE_VALUE AS INTEGER) < @dirty_prev AS LESS_DIRTY_IS_GOOD
|
# The garbage collection happens asynchronously after trigger, in a background
|
||||||
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
|
# thread. So wait for it to happen to avoid sporadic failure.
|
||||||
WHERE VARIABLE_NAME='Innodb_buffer_pool_pages_dirty';
|
let $wait_condition=
|
||||||
|
SELECT CAST(VARIABLE_VALUE AS INTEGER) < @dirty_prev AS LESS_DIRTY_IS_GOOD
|
||||||
|
FROM INFORMATION_SCHEMA.GLOBAL_STATUS
|
||||||
|
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;
|
||||||
|
Reference in New Issue
Block a user