mariadb/mysql-test/include/search_pattern_in_file++.inc

82 lines
3 KiB
PHP
Raw Normal View History

MDEV-13437 InnoDB fails to return error for XA COMMIT or XA ROLLBACK in read-only mode Assertions failed due to incorrect handling of the --tc-heuristic-recover option when InnoDB is in read-only mode either due to innodb_read_only=1 or innodb_force_recovery>3. InnoDB failed to refuse a XA COMMIT or XA ROLLBACK operation, and there were errors in the error handling in the upper layer. This was fixed by making InnoDB XA operations respect the high_level_read_only flag. The InnoDB part of the fix and parts of the test main.tc_heuristic_recover were provided by Marko Mäkelä. LOCK_log mutex lock/unlock had to be added to fix MDEV-13438. The measure is confirmed by mysql sources as well. For testing of the conflicting option combination, mysql-test-run is made to export a new $MYSQLD_LAST_CMD. It holds the very last value generated by mtr.mysqld_start(). Even though the options have been also always stored in $mysqld->{'started_opts'} there were no access to them beyond the automatic server restart by mtr through the expect file interface. Effectively therefore $MYSQLD_LAST_CMD represents a more general interface to $mysqld->{'started_opts'} which can be used in wider scopes including server launch with incompatible options. Notice another existing method to restart the server with incompatible options relying on $MYSQLD_CMD is is aware of $mysqld->{'started_opts'} (the actual options that the server is launched by mtr). In order to use this method they would have to be provided manually. NOTE: When merging to 10.2, the file search_pattern_in_file++.inc should be replaced with the pre-existing search_pattern_in_file.inc.
2017-08-29 09:52:52 +02:00
# Purpose:
# Simple search with Perl for a pattern in some file.
#
# The advantages compared to thinkable auxiliary constructs using the
# mysqltest language and SQL are:
# 1. We do not need a running MySQL server.
# 2. SQL causes "noise" during debugging and increases the size of logs.
# Perl code does not disturb at all.
#
# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
# before sourcing this routine.
#
# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
# to search. If negative, it will search that many bytes at the end of the
# file. By default the search happens from the last CURRENT_TEST:
# marker till the end of file (appropriate for searching error logs).
#
# 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.
#
# In case of
# - SEARCH_FILE and/or SEARCH_PATTERN is not set
# - SEARCH_FILE cannot be opened
# the test will abort immediate.
#
# Typical use case (check invalid server startup options):
# let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
# --error 0,1
# --remove_file $error_log
# let SEARCH_FILE= $error_log;
# # Stop the server
# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
# --exec echo "wait" > $restart_file
# --shutdown_server 10
# --source include/wait_until_disconnected.inc
#
# --error 1
# --exec $MYSQLD_CMD <whatever wrong setting> > $error_log 2>&1
# # The server restart aborts
# let SEARCH_PATTERN= \[ERROR\] Aborting;
# --source include/search_pattern_in_file.inc
#
# Created: 2011-11-11 mleich
#
perl;
use strict;
die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
my @search_files= glob($ENV{SEARCH_FILE});
my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
my $search_range= $ENV{SEARCH_RANGE};
my $content;
foreach my $search_file (@search_files) {
open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
my $file_content;
if ($search_range > 0) {
read(FILE, $file_content, $search_range, 0);
} elsif ($search_range < 0) {
my $size= -s $search_file;
$search_range = -$size if $size > -$search_range;
seek(FILE, $search_range, 2);
read(FILE, $file_content, -$search_range, 0);
} else {
while(<FILE>) { # error log
if (/^CURRENT_TEST:/) {
$content='';
} else {
$content.=$_;
}
}
}
close(FILE);
$content.= $file_content;
}
my @matches=($content =~ m/$search_pattern/gs);
my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
$ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
die "$ENV{SEARCH_ABORT}\n"
if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
MDEV-13437 InnoDB fails to return error for XA COMMIT or XA ROLLBACK in read-only mode Assertions failed due to incorrect handling of the --tc-heuristic-recover option when InnoDB is in read-only mode either due to innodb_read_only=1 or innodb_force_recovery>3. InnoDB failed to refuse a XA COMMIT or XA ROLLBACK operation, and there were errors in the error handling in the upper layer. This was fixed by making InnoDB XA operations respect the high_level_read_only flag. The InnoDB part of the fix and parts of the test main.tc_heuristic_recover were provided by Marko Mäkelä. LOCK_log mutex lock/unlock had to be added to fix MDEV-13438. The measure is confirmed by mysql sources as well. For testing of the conflicting option combination, mysql-test-run is made to export a new $MYSQLD_LAST_CMD. It holds the very last value generated by mtr.mysqld_start(). Even though the options have been also always stored in $mysqld->{'started_opts'} there were no access to them beyond the automatic server restart by mtr through the expect file interface. Effectively therefore $MYSQLD_LAST_CMD represents a more general interface to $mysqld->{'started_opts'} which can be used in wider scopes including server launch with incompatible options. Notice another existing method to restart the server with incompatible options relying on $MYSQLD_CMD is is aware of $mysqld->{'started_opts'} (the actual options that the server is launched by mtr). In order to use this method they would have to be provided manually. NOTE: When merging to 10.2, the file search_pattern_in_file++.inc should be replaced with the pre-existing search_pattern_in_file.inc.
2017-08-29 09:52:52 +02:00
EOF