mariadb/mysql-test/suite/rpl/t/rpl_relay_max_extension.test
Vladislav Vaintroub 061adae9a2 MDEV-16944 Fix file sharing issues on Windows in mysqltest
On Windows systems, occurrences of ERROR_SHARING_VIOLATION due to
conflicting share modes between processes accessing the same file can
result in CreateFile failures.

mysys' my_open() already incorporates a workaround by implementing
wait/retry logic on Windows.

But this does not help if files are opened using shell redirection like
mysqltest traditionally did it, i.e via

--echo exec "some text" > output_file

In such cases, it is cmd.exe, that opens the output_file, and it
won't do any sharing-violation retries.

This commit addresses the issue by introducing a new built-in command,
'write_line', in mysqltest. This new command serves as a brief alternative
to 'write_file', with a single line output, that also resolves variables
like "exec" would.

Internally, this command will use my_open(), and therefore retry-on-error
logic.

Hopefully this will eliminate the very sporadic "can't open file because
it is used by another process" error on CI.
2024-04-17 16:52:37 +02:00

111 lines
3.4 KiB
Text

# ==== Purpose ====
#
# Test verifies that auto purging mechanism of relay logs works fine when the
# file extension grows beyond 999999.
#
# ==== Implementation ====
#
# Steps:
# 0 - In master-slave setup clear all the relay logs on the slave server.
# 1 - Start the slave so that new relay logs starting from
# 'slave-relay-bin.000001' are created.
# 2 - Get the active relay-log file name by using SHOW SLAVE STATUS.
# Shutdown the slave server.
# 3 - Rename active relay log to '999997' in both 'relay-log.info' and
# 'slave-relay-bin.index' files.
# 4 - Restart the slave server by configuring 'slave_parallel_threads=1'
# and 'max_relay_log_size=100K'.
# 5 - Generate load on master such that few relay logs are generated on
# slave. The relay log sequence number will change to 7 digits.
# 6 - Sync slave with master to ensure that relay logs are applied on
# slave. They should have been automatically purged.
# 7 - Assert that there is no 'slave-relay-bin.999999' file in
# 'relay-log.info'.
#
# ==== References ====
#
# MDEV-8134: The relay-log is not flushed after the slave-relay-log.999999
# showed
#
# MDEV-27721 rpl.rpl_relay_max_extension test is not FreeBSD-compatible
--source include/linux.inc
--source include/have_innodb.inc
--source include/have_binlog_format_row.inc
--let $rpl_topology=1->2
--source include/rpl_init.inc
--connection server_2
--source include/stop_slave.inc
RESET SLAVE;
--source include/start_slave.inc
--source include/stop_slave.inc
--let $relay_log=query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
--echo #
--echo # Stop slave server
--echo #
--let $datadir = `select @@datadir`
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--shutdown_server 10
--source include/wait_until_disconnected.inc
--exec sed -i "s/$relay_log/slave-relay-bin.999997/g" $datadir/relay-log.info
--exec sed -i "s/$relay_log/slave-relay-bin.999997/g" $datadir/slave-relay-bin.index
--echo #
--echo # Simulate file number get close to 999997
--echo # by renaming relay logs and modifying index/info files
--move_file $datadir/$relay_log $datadir/slave-relay-bin.999997
--echo #
--echo # Restart slave server
--echo #
--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
SET @save_slave_parallel_threads= @@GLOBAL.slave_parallel_threads;
SET @save_max_relay_log_size= @@GLOBAL.max_relay_log_size;
SET GLOBAL slave_parallel_threads=1;
SET GLOBAL max_relay_log_size=100 * 1024;
--source include/start_slave.inc
--connection server_1
create table t1 (i int, c varchar(1024));
--echo #
--echo # Insert some data to generate enough amount of binary logs
--echo #
--let $count = 1000
--disable_query_log
while ($count)
{
eval insert into t1 values (1001 - $count, repeat('a',1000));
dec $count;
}
--enable_query_log
--save_master_pos
--connection server_2
--sync_with_master
--let $relay_log=query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
--echo #
--echo # Assert that 'slave-relay-bin.999999' is purged.
--echo #
let SEARCH_FILE=$datadir/slave-relay-bin.index;
let SEARCH_PATTERN=slave-relay-bin.999999;
source include/search_pattern_in_file.inc;
--source include/stop_slave.inc
SET GLOBAL slave_parallel_threads= @save_slave_parallel_threads;
SET GLOBAL max_relay_log_size= @save_max_relay_log_size;
--source include/start_slave.inc
--connection server_1
DROP TABLE t1;
--source include/rpl_end.inc