1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-26 01:44:06 +03:00
Files
mariadb/mysql-test/suite/rpl/t/rpl_loadfile.test
Sven Sandberg 09c80e12c5 BUG#49978: Replication tests don't clean up replication state at the end
Major replication test framework cleanup. This does the following:
 - Ensure that all tests clean up the replication state when they
   finish, by making check-testcase check the output of SHOW SLAVE STATUS.
   This implies:
    - Slave must not be running after test finished. This is good
      because it removes the risk for sporadic errors in subsequent
      tests when a test forgets to sync correctly.
    - Slave SQL and IO errors must be cleared when test ends. This is
      good because we will notice if a test gets an unexpected error in
      the slave threads near the end.
    - We no longer have to clean up before a test starts.
 - Ensure that all tests that wait for an error in one of the slave
   threads waits for a specific error. It is no longer possible to
   source wait_for_slave_[sql|io]_to_stop.inc when there is an error
   in one of the slave threads. This is good because:
    - If a test expects an error but there is a bug that causes
      another error to happen, or if it stops the slave thread without
      an error, then we will notice.
    - When developing tests, wait_for_*_to_[start|stop].inc will fail
      immediately if there is an error in the relevant slave thread.
      Before this patch, we had to wait for the timeout.
 - Remove duplicated and repeated code for setting up unusual replication
   topologies. Now, there is a single file that is capable of setting
   up arbitrary topologies (include/rpl_init.inc, but
   include/master-slave.inc is still available for the most common
   topology). Tests can now end with include/rpl_end.inc, which will clean
   up correctly no matter what topology is used. The topology can be
   changed with include/rpl_change_topology.inc.
 - Improved debug information when tests fail. This includes:
    - debug info is printed on all servers configured by include/rpl_init.inc
    - User can set $rpl_debug=1, which makes auxiliary replication files
      print relevant debug info.
 - Improved documentation for all auxiliary replication files. Now they
   describe purpose, usage, parameters, and side effects.
 - Many small code cleanups:
    - Made have_innodb.inc output a sensible error message.
    - Moved contents of rpl000017-slave.sh into rpl000017.test
    - Added mysqltest variables that expose the current state of
      disable_warnings/enable_warnings and friends.
    - Too many to list here: see per-file comments for details.
2010-12-19 18:07:28 +01:00

116 lines
3.8 KiB
Plaintext

#############################################################################
# Original Author: JBM #
# Original Date: Aug/18/2005 #
#############################################################################
# TEST: To test the LOAD_FILE() in rbr #
#############################################################################
# Change Author: JBM
# Change Date: 2006-01-16
# Change: Added Order by for NDB
##########
# Includes
-- source include/master-slave.inc
-- source include/have_binlog_format_mixed_or_row.inc
-- source extra/rpl_tests/rpl_loadfile.test
# BUG#39701: Mixed binlog format does not switch to row mode on LOAD_FILE
#
# DESCRIPTION
#
# Problem: when using load_file string function and mixed binlogging format
# there was no switch to row based binlogging format. This leads
# to scenarios on which the slave replicates the statement and it
# will try to load the file from local file system, which in most
# likely it will not exist.
#
# Solution:
# Marking this function as unsafe for statement format, makes the
# statement using it to be logged in row based format. As such, data
# replicated from the master, becomes the content of the loaded file.
# Consequently, the slave receives the necessary data to complete
# the load_file instruction correctly.
#
# IMPLEMENTATION
#
# The test is implemented as follows:
#
# On Master,
# i) write to file the desired content.
# ii) create table and stored procedure with load_file
# iii) stop slave
# iii) execute load_file
# iv) remove file
#
# On Slave,
# v) start slave
# vi) sync it with master so that it gets the updates from binlog (which
# should have bin logged in row format).
#
# If the the binlog format does not change to row, then the assertion
# done in the following step fails. This happens because tables differ
# since the file does not exist anymore, meaning that when slave
# attempts to execute LOAD_FILE statement it inserts NULL on table
# instead of the same contents that the master loaded when it executed
# the procedure (which was executed when file existed).
#
# vii) assert that the contents of master and slave
# table are the same
--source include/rpl_reset.inc
connection master;
let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval SELECT repeat('x',20) INTO OUTFILE '$file'
disable_warnings;
DROP TABLE IF EXISTS t1;
enable_warnings;
CREATE TABLE t1 (t text);
DELIMITER |;
CREATE PROCEDURE p(file varchar(4096))
BEGIN
INSERT INTO t1 VALUES (LOAD_FILE(file));
END|
DELIMITER ;|
# stop slave before issuing the load_file on master
connection slave;
source include/stop_slave.inc;
connection master;
# test: check that logging falls back to rbr.
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--eval CALL p('$file')
# test: remove the file from the filesystem and assert that slave still
# gets the loaded file
remove_file $file;
# now that the file is removed it is safe (regarding what we want to test)
# to start slave
connection slave;
source include/start_slave.inc;
connection master;
sync_slave_with_master;
# assertion: assert that the slave got the updates even
# if the file was removed before the slave started,
# meaning that contents were indeed transfered
# through binlog (in row format)
let $diff_tables= master:t1, slave:t1;
source include/diff_tables.inc;
# CLEAN UP
--connection master
DROP TABLE t1;
DROP PROCEDURE p;
--source include/rpl_end.inc