mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Merged BUG#49978 from 5.1-bugteam to 5.5-bugteam.
This commit is contained in:
commit
1bd213aec3
831 changed files with 7924 additions and 6322 deletions
|
@ -8284,6 +8284,14 @@ int main(int argc, char **argv)
|
|||
var_set_int("$VIEW_PROTOCOL", view_protocol);
|
||||
var_set_int("$CURSOR_PROTOCOL", cursor_protocol);
|
||||
|
||||
var_set_int("$ENABLED_QUERY_LOG", 1);
|
||||
var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
|
||||
var_set_int("$ENABLED_RESULT_LOG", 1);
|
||||
var_set_int("$ENABLED_CONNECT_LOG", 0);
|
||||
var_set_int("$ENABLED_WARNINGS", 1);
|
||||
var_set_int("$ENABLED_INFO", 0);
|
||||
var_set_int("$ENABLED_METADATA", 0);
|
||||
|
||||
DBUG_PRINT("info",("result_file: '%s'",
|
||||
result_file_name ? result_file_name : ""));
|
||||
verbose_msg("Results saved in '%s'.",
|
||||
|
@ -8430,20 +8438,62 @@ int main(int argc, char **argv)
|
|||
case Q_DISCONNECT:
|
||||
case Q_DIRTY_CLOSE:
|
||||
do_close_connection(command); break;
|
||||
case Q_ENABLE_QUERY_LOG: disable_query_log=0; break;
|
||||
case Q_DISABLE_QUERY_LOG: disable_query_log=1; break;
|
||||
case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break;
|
||||
case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break;
|
||||
case Q_ENABLE_RESULT_LOG: disable_result_log=0; break;
|
||||
case Q_DISABLE_RESULT_LOG: disable_result_log=1; break;
|
||||
case Q_ENABLE_CONNECT_LOG: disable_connect_log=0; break;
|
||||
case Q_DISABLE_CONNECT_LOG: disable_connect_log=1; break;
|
||||
case Q_ENABLE_WARNINGS: disable_warnings=0; break;
|
||||
case Q_DISABLE_WARNINGS: disable_warnings=1; break;
|
||||
case Q_ENABLE_INFO: disable_info=0; break;
|
||||
case Q_DISABLE_INFO: disable_info=1; break;
|
||||
case Q_ENABLE_METADATA: display_metadata=1; break;
|
||||
case Q_DISABLE_METADATA: display_metadata=0; break;
|
||||
case Q_ENABLE_QUERY_LOG:
|
||||
disable_query_log= 0;
|
||||
var_set_int("$ENABLED_QUERY_LOG", 1);
|
||||
break;
|
||||
case Q_DISABLE_QUERY_LOG:
|
||||
disable_query_log= 1;
|
||||
var_set_int("$ENABLED_QUERY_LOG", 0);
|
||||
break;
|
||||
case Q_ENABLE_ABORT_ON_ERROR:
|
||||
abort_on_error= 1;
|
||||
var_set_int("$ENABLED_ABORT_ON_ERROR", 1);
|
||||
break;
|
||||
case Q_DISABLE_ABORT_ON_ERROR:
|
||||
abort_on_error= 0;
|
||||
var_set_int("$ENABLED_ABORT_ON_ERROR", 0);
|
||||
break;
|
||||
case Q_ENABLE_RESULT_LOG:
|
||||
disable_result_log= 0;
|
||||
var_set_int("$ENABLED_RESULT_LOG", 1);
|
||||
break;
|
||||
case Q_DISABLE_RESULT_LOG:
|
||||
disable_result_log=1;
|
||||
var_set_int("$ENABLED_RESULT_LOG", 0);
|
||||
break;
|
||||
case Q_ENABLE_CONNECT_LOG:
|
||||
disable_connect_log=0;
|
||||
var_set_int("$ENABLED_CONNECT_LOG", 1);
|
||||
break;
|
||||
case Q_DISABLE_CONNECT_LOG:
|
||||
disable_connect_log=1;
|
||||
var_set_int("$ENABLED_CONNECT_LOG", 0);
|
||||
break;
|
||||
case Q_ENABLE_WARNINGS:
|
||||
disable_warnings= 0;
|
||||
var_set_int("$ENABLED_WARNINGS", 1);
|
||||
break;
|
||||
case Q_DISABLE_WARNINGS:
|
||||
disable_warnings= 1;
|
||||
var_set_int("$ENABLED_WARNINGS", 0);
|
||||
break;
|
||||
case Q_ENABLE_INFO:
|
||||
disable_info= 0;
|
||||
var_set_int("$ENABLED_INFO", 1);
|
||||
break;
|
||||
case Q_DISABLE_INFO:
|
||||
disable_info= 1;
|
||||
var_set_int("$ENABLED_INFO", 0);
|
||||
break;
|
||||
case Q_ENABLE_METADATA:
|
||||
display_metadata= 1;
|
||||
var_set_int("$ENABLED_METADATA", 1);
|
||||
break;
|
||||
case Q_DISABLE_METADATA:
|
||||
display_metadata= 0;
|
||||
var_set_int("$ENABLED_METADATA", 0);
|
||||
break;
|
||||
case Q_SOURCE: do_source(command); break;
|
||||
case Q_SLEEP: do_sleep(command, 0); break;
|
||||
case Q_REAL_SLEEP: do_sleep(command, 1); break;
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
|
||||
# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986).
|
||||
####################################
|
||||
# Change Author: JBM
|
||||
# Change Date: 2006-01-11
|
||||
# Change: Split test per lars review
|
||||
####################################
|
||||
#"REQUIREMENT: A master DROP TABLE on a table with non-existing MYI
|
||||
# file must be correctly replicated to the slave"
|
||||
####################################
|
||||
|
@ -23,8 +19,5 @@ flush tables;
|
|||
let $MYSQLD_DATADIR= `select @@datadir`;
|
||||
remove_file $MYSQLD_DATADIR/test/t1.MYI ;
|
||||
drop table if exists t1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
#
|
||||
# Test of auto_increment with offset
|
||||
#
|
||||
#####################################
|
||||
# By: JBM
|
||||
# Date: 2006-02-10
|
||||
# Change: NDB does not support auto inc
|
||||
# in this usage. Currently there is no
|
||||
# plan to implment. Skipping test when
|
||||
# NDB is default engine.
|
||||
#####################################
|
||||
-- source include/not_ndb_default.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
|
@ -169,7 +161,7 @@ drop table t1;
|
|||
# auto_increment fields if the values of them are 0. There is an inconsistency
|
||||
# between slave and master. When MODE_NO_AUTO_VALUE_ON_ZERO are masters treat
|
||||
#
|
||||
source include/master-slave-reset.inc;
|
||||
source include/rpl_reset.inc;
|
||||
|
||||
connection master;
|
||||
--disable_warnings
|
||||
|
@ -210,12 +202,10 @@ INSERT INTO t2 VALUES(4);
|
|||
FLUSH LOGS;
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1= master:test.t1;
|
||||
let $diff_table_2= slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
let $diff_table_1= master:test.t2;
|
||||
let $diff_table_2= slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
@ -228,16 +218,16 @@ let $MYSQLD_DATADIR= `SELECT @@DATADIR`;
|
|||
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 | $MYSQL test
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1= master:test.t1;
|
||||
let $diff_table_2= slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
let $diff_table_1= master:test.t2;
|
||||
let $diff_table_2= slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
# End cleanup
|
||||
--connection master
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
SET SQL_MODE='';
|
||||
sync_slave_with_master;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -29,8 +29,7 @@ commit;
|
|||
sync_slave_with_master;
|
||||
--echo #Test if the results are consistent on master and slave
|
||||
--echo #for 'INSERT DATA INTO VIEW WHICH INVOKES TRIGGERS'
|
||||
let $diff_table_1=master:test.t3;
|
||||
let $diff_table_2=slave:test.t3;
|
||||
let $diff_tables= master:t3, slave:t3;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
|
|
@ -60,14 +60,11 @@ connection master;
|
|||
sync_slave_with_master;
|
||||
--echo #Test if the results are consistent on master and slave
|
||||
--echo #for 'INVOKES A TRIGGER with $trigger_action action'
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
let $diff_table_1=master:test.t4;
|
||||
let $diff_table_2=slave:test.t4;
|
||||
let $diff_tables= master:t4, slave:t4;
|
||||
source include/diff_tables.inc;
|
||||
let $diff_table_1=master:test.t6;
|
||||
let $diff_table_2=slave:test.t6;
|
||||
let $diff_tables= master:t6, slave:t6;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
|
|
@ -41,11 +41,9 @@ connection master;
|
|||
sync_slave_with_master;
|
||||
--echo #Test if the results are consistent on master and slave
|
||||
--echo #for 'CALLS A FUNCTION which INVOKES A TRIGGER with $insert_action action'
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
let $diff_table_1=master:test.t3;
|
||||
let $diff_table_2=slave:test.t3;
|
||||
let $diff_tables= master:t3, slave:t3;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
|
|
@ -62,7 +62,8 @@ eval INSERT INTO t2 (a, data) VALUES (2,
|
|||
--enable_query_log
|
||||
|
||||
# Incident event
|
||||
--let $slave_sql_errno=1590
|
||||
# 1590=ER_SLAVE_INCIDENT
|
||||
--let $slave_sql_errno= 1590
|
||||
--source include/wait_for_slave_sql_error_and_skip.inc
|
||||
|
||||
--disable_query_log
|
||||
|
@ -81,15 +82,13 @@ eval UPDATE t2, t1 SET t2.data = CONCAT($data, $data, $data, $data),
|
|||
t1.data = CONCAT($data, $data, $data, $data);
|
||||
--enable_query_log
|
||||
|
||||
# Incident event
|
||||
--let $slave_skip_counter=1
|
||||
if (`SELECT @@binlog_format = 'ROW'`)
|
||||
{
|
||||
--inc $slave_skip_counter
|
||||
}
|
||||
--let $slave_sql_errno=1590
|
||||
# 1590=ER_SLAVE_INCIDENT
|
||||
--let $slave_sql_errno= 1590
|
||||
--let $slave_skip_counter= `SELECT IF(@@binlog_format = 'ROW', 2, 1)`
|
||||
--source include/wait_for_slave_sql_error_and_skip.inc
|
||||
--let $slave_skip_counter=
|
||||
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 2 - BEGIN - IMPLICIT COMMIT by DDL
|
||||
|
@ -177,8 +176,9 @@ BEGIN;
|
|||
CREATE TABLE t5 (a int);
|
||||
--enable_query_log
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 3 - BEGIN - COMMIT
|
||||
|
@ -206,8 +206,9 @@ BEGIN;
|
|||
--enable_query_log
|
||||
COMMIT;
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 4 - BEGIN - ROLLBACK
|
||||
|
@ -235,8 +236,9 @@ BEGIN;
|
|||
--enable_query_log
|
||||
ROLLBACK;
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 5 - PROCEDURE
|
||||
|
@ -284,8 +286,9 @@ eval CALL p1($data);
|
|||
--enable_query_log
|
||||
ROLLBACK;
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 6 - XID
|
||||
|
@ -315,8 +318,9 @@ SAVEPOINT sv;
|
|||
ROLLBACK TO sv;
|
||||
COMMIT;
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################################
|
||||
--echo # 7 - NON-TRANS TABLE
|
||||
|
@ -358,8 +362,9 @@ BEGIN;
|
|||
--enable_query_log
|
||||
COMMIT;
|
||||
|
||||
let $diff_statement= SELECT * FROM t1;
|
||||
--source include/diff_master_slave.inc
|
||||
--sync_slave_with_master
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ########################################################################
|
||||
--echo # 8 - Bug#55375(Regression Bug) Transaction bigger than
|
||||
|
@ -409,7 +414,7 @@ while ($n)
|
|||
--enable_query_log
|
||||
COMMIT;
|
||||
|
||||
connection slave;
|
||||
--connection slave
|
||||
--let $slave_sql_errno= 1197
|
||||
if (`SELECT @@binlog_format = 'ROW'`)
|
||||
{
|
||||
|
@ -444,8 +449,10 @@ connection master;
|
|||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
DROP TABLE t3;
|
||||
# t4 exists only if binlog_format!=row, so so a warning is generated
|
||||
# if binog_format=row
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t4;
|
||||
DROP TABLE IF EXISTS t5;
|
||||
DROP TABLE IF EXISTS t6;
|
||||
--enable_warnings
|
||||
DROP TABLE t5;
|
||||
DROP PROCEDURE p1;
|
||||
source include/master-slave-end.inc;
|
||||
|
|
|
@ -2,11 +2,7 @@
|
|||
# This test will fail if the server/client does not support enough charsets.
|
||||
|
||||
source include/master-slave.inc;
|
||||
--disable_warnings
|
||||
set timestamp=1000000000;
|
||||
drop database if exists mysqltest2;
|
||||
drop database if exists mysqltest3;
|
||||
--enable_warnings
|
||||
|
||||
create database mysqltest2 character set latin2;
|
||||
set @@character_set_server=latin5;
|
||||
|
@ -149,6 +145,6 @@ eval create table `t1` (
|
|||
set @p=_latin1 'test';
|
||||
update t1 set pk='test' where pk=@p;
|
||||
drop table t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
#################################
|
||||
# Test updated to use a wrapper #
|
||||
#################################
|
||||
|
||||
eval CREATE TABLE t1 (a INT) ENGINE=$engine_type;
|
||||
|
||||
begin;
|
||||
insert into t1 values(1);
|
||||
flush tables with read lock;
|
||||
commit;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
# cleanup
|
||||
connection master;
|
||||
unlock tables;
|
||||
|
|
|
@ -91,11 +91,13 @@ if (`SELECT @@global.binlog_format != 'ROW' OR @@global.slave_exec_mode = 'STRIC
|
|||
# key error, and stops the SQL thread.
|
||||
let $slave_sql_errno= 1062; # ER_DUP_ENTRY
|
||||
source include/wait_for_slave_sql_error.inc;
|
||||
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
|
||||
|
||||
--let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1)
|
||||
--replace_regex /end_log_pos [0-9]+/end_log_pos END_LOG_POS/
|
||||
--disable_query_log
|
||||
--eval SELECT "$err" as 'Last_SQL_Error (expected "duplicate key" error)'
|
||||
--enable_query_log
|
||||
|
||||
SELECT * FROM t1;
|
||||
|
||||
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
|
||||
|
@ -142,8 +144,13 @@ if (`SELECT @@global.binlog_format = 'ROW' AND @@global.slave_exec_mode = 'STRIC
|
|||
--echo ---- Wait until slave stops with an error ----
|
||||
let $slave_sql_errno= 1032; # ER_KEY_NOT_FOUND
|
||||
source include/wait_for_slave_sql_error.inc;
|
||||
let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
|
||||
--echo Last_SQL_Error = $err (expected "can't find record" error)
|
||||
|
||||
--let $err= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1)
|
||||
--replace_regex /end_log_pos [0-9]+/end_log_pos END_LOG_POS/
|
||||
--disable_query_log
|
||||
--eval SELECT "$err" as 'Last_SQL_Error (expected "duplicate key" error)'
|
||||
--enable_query_log
|
||||
|
||||
SELECT * FROM t1;
|
||||
|
||||
--echo ---- Resolve the conflict on the slave and restart SQL thread ----
|
||||
|
@ -168,4 +175,4 @@ connection master;
|
|||
DROP TABLE t1;
|
||||
|
||||
--echo [on slave]
|
||||
sync_slave_with_master;
|
||||
--sync_slave_with_master
|
||||
|
|
|
@ -136,14 +136,6 @@ sync_slave_with_master;
|
|||
connection master;
|
||||
SET AUTOCOMMIT = 1;
|
||||
#
|
||||
# 1. DROP all objects, which probably already exist, but must be created here
|
||||
#
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mysqltest1;
|
||||
DROP DATABASE IF EXISTS mysqltest2;
|
||||
DROP DATABASE IF EXISTS mysqltest3;
|
||||
--enable_warnings
|
||||
#
|
||||
# 2. CREATE all objects needed
|
||||
# working database is mysqltest1
|
||||
# working table (transactional!) is mysqltest1.t1
|
||||
|
@ -619,6 +611,3 @@ connection master;
|
|||
DROP DATABASE mysqltest1;
|
||||
# mysqltest2 was alreday DROPPED some tests before.
|
||||
DROP DATABASE mysqltest3;
|
||||
--enable_warnings
|
||||
|
||||
-- source include/master-slave-end.inc
|
||||
|
|
|
@ -131,3 +131,4 @@ sync_slave_with_master;
|
|||
SET global max_relay_log_size= @my_max_relay_log_size;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
#############################################################
|
||||
# Author: Chuck
|
||||
#############################################################
|
||||
# Purpose: To test having extra columns on the master WL#3915
|
||||
# engine inspecific sourced part
|
||||
#############################################################
|
||||
# Change Author: Jeb
|
||||
# Change: Cleanup and extend testing
|
||||
#############################################################
|
||||
# TODO: partition specific
|
||||
# -- source include/have_partition.inc
|
||||
# Note: Will be done in different test due to NDB using this
|
||||
# test case.
|
||||
############################################################
|
||||
|
||||
########### Clean up ################
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t10,t11,t12,t13,t14,t15,t16,t17,t18,t31;
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
#
|
||||
# Setup differently defined tables on master and slave
|
||||
|
@ -1025,8 +1008,3 @@ SELECT c1,hex(c4),c5 FROM t5 ORDER BY c1;
|
|||
connection master;
|
||||
DROP TABLE t5;
|
||||
sync_slave_with_master;
|
||||
--echo
|
||||
|
||||
# END of 5.1 tests case
|
||||
|
||||
|
|
@ -1,19 +1,10 @@
|
|||
#################################################
|
||||
# Author: Jeb
|
||||
# Date: 2006-09-07
|
||||
# Purpose: To test having extra columns on the slave.
|
||||
##################################################
|
||||
|
||||
# Some tests in here requre partitioning
|
||||
-- source include/have_partition.inc
|
||||
|
||||
########### Clean up ################
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
#################################################
|
||||
############ Different Table Def Test ###########
|
||||
#################################################
|
||||
|
@ -286,16 +277,14 @@ connection slave;
|
|||
--let $slave_sql_errno= 1677
|
||||
--let $show_slave_sql_error= 1
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=3;
|
||||
#START SLAVE;
|
||||
|
||||
--echo *** Drop t6 ***
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
connection master;
|
||||
DROP TABLE t6;
|
||||
connection slave;
|
||||
DROP TABLE t6;
|
||||
START SLAVE;
|
||||
#sync_slave_with_master;
|
||||
--sync_slave_with_master
|
||||
|
||||
|
||||
--echo **** Diff Table Def End ****
|
||||
|
@ -453,9 +442,9 @@ if ($engine_type != NDB)
|
|||
}
|
||||
|
||||
#--echo *** Drop t9 ***
|
||||
#connection master;
|
||||
#DROP TABLE t9;
|
||||
#sync_slave_with_master;
|
||||
connection master;
|
||||
DROP TABLE t9;
|
||||
sync_slave_with_master;
|
||||
|
||||
############################################
|
||||
# More columns in slave at middle of table #
|
||||
|
@ -730,6 +719,10 @@ sync_slave_with_master;
|
|||
--replace_column 5 CURRENT_TIMESTAMP
|
||||
SELECT * FROM t14a ORDER BY c1;
|
||||
|
||||
--connection master
|
||||
DROP TABLE t14a;
|
||||
--sync_slave_with_master
|
||||
|
||||
####################################################
|
||||
# - Alter Master Dropping columns from the middle. #
|
||||
# Expect: columns dropped #
|
||||
|
@ -917,17 +910,3 @@ connection slave;
|
|||
connection master;
|
||||
DROP TABLE t17;
|
||||
sync_slave_with_master;
|
||||
|
||||
#### Clean Up ####
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
connection master;
|
||||
DROP TABLE IF EXISTS t1, t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t14a,t15,t16,t17;
|
||||
sync_slave_with_master;
|
||||
connection master;
|
||||
--enable_query_log
|
||||
--enable_warnings
|
||||
|
||||
# END 5.1 Test Case
|
||||
|
||||
|
|
@ -22,4 +22,5 @@ connection master;
|
|||
select * from t1;
|
||||
commit;
|
||||
drop table t1;
|
||||
-- sync_slave_with_master
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -54,7 +54,6 @@ unlock tables;
|
|||
connection master;
|
||||
drop table t3, t4, t5;
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -59,6 +59,4 @@ select count(*) from t1 /* must be zero */;
|
|||
connection master;
|
||||
drop table t2,t1;
|
||||
|
||||
sync_slave_with_master;
|
||||
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -40,26 +40,16 @@ if (!$debug_sync_action)
|
|||
}
|
||||
|
||||
# Restart slave
|
||||
--disable_warnings
|
||||
stop slave;
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
--source include/stop_slave.inc
|
||||
|
||||
eval SET @@global.debug= "+d,$dbug_sync_point";
|
||||
|
||||
start slave;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
--source include/start_slave.inc
|
||||
--echo slave is going to hang in get_master_version_and_clock
|
||||
|
||||
connection master;
|
||||
# Write file to make mysql-test-run.pl expect the "crash", but don't start
|
||||
# it until it's told to
|
||||
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_stop_server.inc
|
||||
|
||||
# Send shutdown to the connected server and give
|
||||
# it 10 seconds to die before zapping it
|
||||
shutdown_server 10;
|
||||
|
||||
connection slave;
|
||||
--echo slave is unblocked
|
||||
|
||||
eval SET DEBUG_SYNC=$debug_sync_action;
|
||||
|
@ -74,6 +64,7 @@ connection slave;
|
|||
# '1040' ER_CON_COUNT_ERROR
|
||||
# '1053' ER_SERVER_SHUTDOWN
|
||||
let $slave_io_errno= 1040, 1053, 2002, 2003, 2006, 2013;
|
||||
--let $slave_io_error_is_nonfatal= 1
|
||||
source include/wait_for_slave_io_error.inc;
|
||||
|
||||
# deactivate the sync point of get_master_version_and_clock()
|
||||
|
@ -82,19 +73,12 @@ source include/wait_for_slave_io_error.inc;
|
|||
# unset.
|
||||
eval set @@global.debug = "-d,$dbug_sync_point";
|
||||
|
||||
# Write file to make mysql-test-run.pl start up the server again
|
||||
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
|
||||
connection master;
|
||||
# Turn on reconnect
|
||||
--enable_reconnect
|
||||
|
||||
# Call script that will poll the server waiting for it to be back online again
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
# Turn off reconnect again
|
||||
--disable_reconnect
|
||||
|
||||
connection slave;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_start_server.inc
|
||||
|
||||
# We don't source include/wait_for_slave_io_to_start.inc, because the
|
||||
# IO thread has an error and wait_for_slave_io_to_start.inc fails if
|
||||
# the IO thread has an error.
|
||||
--let $slave_param= Slave_IO_Running
|
||||
--let $slave_param_value= Yes
|
||||
--source include/wait_for_slave_param.inc
|
||||
|
|
|
@ -649,8 +649,7 @@ SET AUTOCOMMIT= 1;
|
|||
--echo ###################################################################################
|
||||
--sync_slave_with_master
|
||||
|
||||
--let $diff_table_1= master:test.tt_1
|
||||
--let $diff_table_2= slave:test.tt_1
|
||||
--let $diff_tables= master:tt_1,slave:tt_1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--echo ###################################################################################
|
||||
|
|
|
@ -180,5 +180,3 @@ DROP TABLE t1;
|
|||
DROP TABLE t3;
|
||||
|
||||
--echo End of 6.0 tests
|
||||
|
||||
--source include/master-slave-end.inc
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
###########################################################
|
||||
# 2006-02-01: By JBM: Added 1022, ORDER BY
|
||||
###########################################################
|
||||
# See if queries that use both auto_increment and LAST_INSERT_ID()
|
||||
# are replicated well
|
||||
############################################################
|
||||
|
@ -9,17 +7,10 @@
|
|||
# column and index but without primary key.
|
||||
##############################################################
|
||||
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
|
||||
--echo #
|
||||
--echo # Setup
|
||||
--echo #
|
||||
|
||||
use test;
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
--enable_warnings
|
||||
|
||||
--echo #
|
||||
--echo # See if queries that use both auto_increment and LAST_INSERT_ID()
|
||||
--echo # are replicated well
|
||||
|
@ -30,6 +21,13 @@ drop table if exists t1, t2, t3;
|
|||
-- source include/master-slave.inc
|
||||
#should work for both SBR and RBR
|
||||
|
||||
--disable_query_log
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
--connection slave
|
||||
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
--enable_query_log
|
||||
|
||||
|
||||
# If concurrent inserts are on, it is not guaranteed that the rows
|
||||
# inserted by INSERT are immediately accessible by SELECT in another
|
||||
# thread. This would cause problems near the line 'connection master1'
|
||||
|
@ -44,9 +42,7 @@ eval create table t2(b int auto_increment, c int, key(b)) engine=$engine_type;
|
|||
insert into t1 values (1),(2),(3);
|
||||
insert into t1 values (null);
|
||||
insert into t2 values (null,last_insert_id());
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
connection master;
|
||||
|
@ -65,9 +61,7 @@ insert into t1 values (null),(null),(null);
|
|||
insert into t2 values (5,0);
|
||||
insert into t2 values (null,last_insert_id());
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
connection master;
|
||||
|
@ -85,17 +79,13 @@ insert into t1 values (null),(null),(null);
|
|||
insert into t2 values (5,0);
|
||||
insert into t2 (c) select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
connection master;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
|
||||
--echo #
|
||||
--echo # Bug#8412: Error codes reported in binary log for CHARACTER SET,
|
||||
|
@ -215,9 +205,7 @@ call foo();
|
|||
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
connection master;
|
||||
|
@ -562,4 +550,5 @@ drop table t1, t2;
|
|||
drop procedure foo;
|
||||
SET @@global.concurrent_insert= @old_concurrent_insert;
|
||||
set @@session.sql_auto_is_null=default;
|
||||
sync_slave_with_master;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
###########################################################
|
||||
# 2006-02-08: By JBM:
|
||||
###########################################################
|
||||
# See if queries that use both auto_increment and LAST_INSERT_ID()
|
||||
# are replicated well
|
||||
############################################################
|
||||
|
@ -14,15 +12,12 @@
|
|||
-- source include/master-slave.inc
|
||||
#should work for both SBR and RBR
|
||||
|
||||
connection master;
|
||||
create table t1(a int auto_increment, primary key(a));
|
||||
create table t2(b int auto_increment, c int, primary key(b));
|
||||
insert into t1 values (1),(2),(3);
|
||||
insert into t1 values (null);
|
||||
insert into t2 values (null,last_insert_id());
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
connection master;
|
||||
|
@ -41,9 +36,7 @@ insert into t1 values (null),(null),(null);
|
|||
insert into t2 values (5,0);
|
||||
insert into t2 values (null,last_insert_id());
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
connection master;
|
||||
|
@ -59,17 +52,13 @@ insert into t1 values (null),(null),(null);
|
|||
insert into t2 values (5,0);
|
||||
insert into t2 (c) select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from t1 ORDER BY a;
|
||||
select * from t2 ORDER BY b;
|
||||
connection master;
|
||||
drop table t1;
|
||||
drop table t2;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
|
||||
#
|
||||
# Bug#8412: Error codes reported in binary log for CHARACTER SET,
|
||||
|
@ -85,5 +74,7 @@ INSERT INTO t1 VALUES (1),(1);
|
|||
sync_slave_with_master;
|
||||
connection master;
|
||||
drop table t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -11,13 +11,10 @@
|
|||
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
|
||||
# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
|
||||
|
||||
-- source include/have_binlog_format_statement.inc
|
||||
-- source include/master-slave.inc
|
||||
source include/have_innodb.inc;
|
||||
|
||||
connection slave;
|
||||
reset master;
|
||||
connection master;
|
||||
|
||||
--disable_query_log
|
||||
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
--enable_query_log
|
||||
|
@ -48,9 +45,7 @@ create table t3 (day date,id int(9),category enum('a','b','c'),name varchar(60))
|
|||
insert into t3 select * from t2;
|
||||
--enable_warnings
|
||||
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
|
||||
select * from t1;
|
||||
select * from t3;
|
||||
|
@ -62,9 +57,7 @@ drop table t2;
|
|||
drop table t3;
|
||||
create table t1(a int, b int, unique(b));
|
||||
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
|
||||
# See if slave stops when there's a duplicate entry for key error in LOAD DATA
|
||||
|
||||
|
@ -75,21 +68,16 @@ eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
|
|||
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
# The SQL slave thread should be stopped now.
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
# 1062 = ER_DUP_ENTRY
|
||||
--let $slave_sql_errno= 1062
|
||||
--source include/wait_for_slave_sql_error_and_skip.inc
|
||||
|
||||
# Skip the bad event and see if error is cleared in SHOW SLAVE STATUS by START
|
||||
# SLAVE, even though we are not executing any event (as sql_slave_skip_counter
|
||||
# takes us directly to the end of the relay log).
|
||||
|
||||
set global sql_slave_skip_counter=1;
|
||||
start slave;
|
||||
sync_with_master;
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
|
||||
echo Last_SQL_Errno=$last_error;
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
|
||||
echo Last_SQL_Error;
|
||||
echo $last_error;
|
||||
--source include/check_slave_no_error.inc
|
||||
|
||||
# Trigger error again to test CHANGE MASTER
|
||||
|
||||
|
@ -103,17 +91,15 @@ connection slave;
|
|||
# The SQL slave thread should be stopped now.
|
||||
# Exec_Master_Log_Pos should point to the start of Execute event
|
||||
# for last load data.
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
# 1062 = ER_DUP_ENTRY
|
||||
--let $slave_sql_errno= 1062
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
# CHANGE MASTER and see if error is cleared in SHOW SLAVE STATUS.
|
||||
stop slave;
|
||||
--source include/stop_slave_io.inc
|
||||
change master to master_user='test';
|
||||
change master to master_user='root';
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
|
||||
echo Last_SQL_Errno=$last_error;
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
|
||||
echo Last_SQL_Error;
|
||||
echo $last_error;
|
||||
--source include/check_slave_no_error.inc
|
||||
|
||||
# Trigger error again to test RESET SLAVE
|
||||
|
||||
|
@ -128,16 +114,14 @@ eval $lower_stmt_head infile '../../std_data/rpl_loaddata.dat' into table t1;
|
|||
save_master_pos;
|
||||
connection slave;
|
||||
# The SQL slave thread should be stopped now.
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
# 1062 = ER_DUP_ENTRY
|
||||
--let $slave_sql_errno= 1062
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
|
||||
# RESET SLAVE and see if error is cleared in SHOW SLAVE STATUS.
|
||||
stop slave;
|
||||
reset slave;
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
|
||||
echo Last_SQL_Errno=$last_error;
|
||||
let $last_error= query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1);
|
||||
echo Last_SQL_Error;
|
||||
echo $last_error;
|
||||
--source include/check_slave_no_error.inc
|
||||
|
||||
# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
|
||||
|
||||
|
@ -166,9 +150,13 @@ eval $lower_stmt_head infile '../../std_data/rpl_loaddata2.dat' into table t2 fi
|
|||
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
|
||||
'\n##\n' starting by '>' ignore 1 lines;
|
||||
connection slave;
|
||||
|
||||
if (`SELECT @@global.binlog_format != 'ROW'`)
|
||||
{
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
# Query causes error on master but not on slave. This causes the slave to
|
||||
# stop with error code 0 (which is wrong: see BUG#57287)
|
||||
--let $slave_sql_errno= 0
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
drop table t1, t2;
|
||||
}
|
||||
connection master;
|
||||
|
@ -180,11 +168,12 @@ CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=INNODB;
|
|||
--error ER_DUP_ENTRY
|
||||
eval $UPPER_STMT_HEAD INFILE "../../std_data/words.dat" INTO TABLE t1;
|
||||
|
||||
DROP TABLE IF EXISTS t1;
|
||||
DROP TABLE t1;
|
||||
|
||||
# BUG#48297: Schema name is ignored when LOAD DATA is written into binlog,
|
||||
# replication aborts
|
||||
-- source include/master-slave-reset.inc
|
||||
-- let $rpl_only_running_threads= 1
|
||||
-- source include/rpl_reset.inc
|
||||
|
||||
-- let $db1= b48297_db1
|
||||
-- let $db2= b42897_db2
|
||||
|
@ -245,8 +234,7 @@ connect (conn2,localhost,root,,*NO-ONE*);
|
|||
-- sync_slave_with_master
|
||||
-- eval use $db1
|
||||
|
||||
let $diff_table_1=master:$db1.t1;
|
||||
let $diff_table_2=slave:$db1.t1;
|
||||
let $diff_tables= master:$db1.t1, slave:$db1.t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
-- connection master
|
||||
|
@ -257,7 +245,7 @@ source include/diff_tables.inc;
|
|||
-- sync_slave_with_master
|
||||
|
||||
# BUG#49479: LOAD DATA INFILE is binlogged without escaping field names
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
-- connection master
|
||||
use test;
|
||||
CREATE TABLE t1 (`key` TEXT, `text` TEXT);
|
||||
|
@ -268,6 +256,5 @@ SELECT * FROM t1;
|
|||
-- sync_slave_with_master
|
||||
-- connection master
|
||||
DROP TABLE t1;
|
||||
-- sync_slave_with_master
|
||||
|
||||
# End of 4.1 tests
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -126,7 +126,7 @@ DROP TABLE t3;
|
|||
|
||||
# Reset binlog so that show binlog events will not show the tests
|
||||
# above.
|
||||
source include/master-slave-reset.inc;
|
||||
source include/rpl_reset.inc;
|
||||
connection master;
|
||||
|
||||
create table t1(a int auto_increment primary key, b int);
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
# Requires statement logging
|
||||
-- source include/master-slave.inc
|
||||
|
||||
# We have to sync with master, to ensure slave had time to start properly
|
||||
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log.
|
||||
sync_slave_with_master;
|
||||
connection slave;
|
||||
stop slave;
|
||||
connection master;
|
||||
|
@ -117,3 +114,4 @@ set global max_binlog_size= @my_max_binlog_size;
|
|||
--echo #
|
||||
--echo # End of 4.1 tests
|
||||
--echo #
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -7,9 +7,6 @@
|
|||
# PS doesn't support multi-statements
|
||||
--disable_ps_protocol
|
||||
-- source include/master-slave.inc
|
||||
--disable_warnings
|
||||
drop database if exists mysqltest;
|
||||
--enable_warnings
|
||||
create database mysqltest;
|
||||
|
||||
delimiter /;
|
||||
|
@ -25,4 +22,5 @@ select * from mysqltest.t1;
|
|||
connection master;
|
||||
source include/show_binlog_events.inc;
|
||||
drop database mysqltest;
|
||||
sync_slave_with_master;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -19,12 +19,11 @@ SELECT * FROM t1 ORDER BY a;
|
|||
SELECT * FROM t2 ORDER BY a;
|
||||
|
||||
UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
connection master;
|
||||
drop table t1, t2;
|
||||
sync_slave_with_master;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -230,7 +230,7 @@ connection master;
|
|||
|
||||
# Reset both slave and master
|
||||
# This should reset binlog to #1
|
||||
--source include/master-slave-reset.inc
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo
|
||||
|
||||
|
|
|
@ -71,12 +71,10 @@ INSERT INTO t4(a) VALUES (5);
|
|||
sync_slave_with_master;
|
||||
|
||||
--echo TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--echo TABLES t2 and t3 must be different.
|
||||
|
@ -101,8 +99,7 @@ REPLACE INTO t1(a,b,c) VALUES (2, NULL, 300);
|
|||
sync_slave_with_master;
|
||||
|
||||
--echo TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--echo ************* CLEANING *************
|
||||
|
@ -154,8 +151,7 @@ REPLACE INTO t1(a,b,c) VALUES (2, NULL, b'00');
|
|||
--echo ************* SHOWING THE RESULT SETS WITH UPDATES and REPLACES *************
|
||||
--echo TABLES t1 and t2 must be equal otherwise an error will be thrown.
|
||||
sync_slave_with_master;
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
@ -273,7 +269,7 @@ sync_slave_with_master;
|
|||
# SELECT * FROM t3 ORDER BY a;
|
||||
# connection slave;
|
||||
# SELECT * FROM t3 ORDER BY a;
|
||||
# --source include/reset_master_and_slave.inc
|
||||
# --source include/rpl_reset.inc
|
||||
#
|
||||
# connection master;
|
||||
#
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
-- echo ## case #1 - last_null_bit_pos==0 in record_compare without X bit
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
-- connection master
|
||||
|
||||
-- eval CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bigint(20) DEFAULT 0, c3 bigint(20) DEFAULT 0, c4 varchar(1) DEFAULT '', c5 bigint(20) DEFAULT 0, c6 bigint(20) DEFAULT 0, c7 bigint(20) DEFAULT 0, c8 bigint(20) DEFAULT 0) ENGINE=$engine DEFAULT CHARSET=latin1
|
||||
|
@ -16,8 +16,7 @@ UPDATE t1 SET c5 = 'a';
|
|||
-- enable_warnings
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1= master:test.t1
|
||||
-- let $diff_table_2= slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
--connection master
|
||||
|
@ -26,7 +25,7 @@ DROP TABLE t1;
|
|||
|
||||
-- echo ## case #1.1 - last_null_bit_pos==0 in record_compare with X bit
|
||||
-- echo ## (1 column less and no varchar)
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
-- connection master
|
||||
|
||||
-- eval CREATE TABLE t1 (c1 bigint(20) DEFAULT 0, c2 bigint(20) DEFAULT 0, c3 bigint(20) DEFAULT 0, c4 bigint(20) DEFAULT 0, c5 bigint(20) DEFAULT 0, c6 bigint(20) DEFAULT 0, c7 bigint(20) DEFAULT 0) ENGINE=$engine DEFAULT CHARSET=latin1
|
||||
|
@ -38,8 +37,7 @@ UPDATE t1 SET c5 = 'a';
|
|||
-- enable_warnings
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1= master:test.t1
|
||||
-- let $diff_table_2= slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
--connection master
|
||||
|
@ -48,7 +46,7 @@ DROP TABLE t1;
|
|||
|
||||
-- echo ## case #2 - X bit is wrongly set.
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
-- connection master
|
||||
|
||||
-- eval CREATE TABLE t1 (c1 int, c2 varchar(1) default '') ENGINE=$engine DEFAULT CHARSET= latin1
|
||||
|
@ -57,8 +55,7 @@ INSERT INTO t1(c1) VALUES (NULL);
|
|||
UPDATE t1 SET c1= 0;
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1= master:test.t1
|
||||
-- let $diff_table_2= slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
-- connection master
|
||||
|
|
|
@ -55,9 +55,9 @@ source include/check_slave_no_error.inc;
|
|||
change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
let $slave_io_errno= 1045;
|
||||
source include/wait_for_slave_io_error.inc;
|
||||
--source include/wait_for_slave_io_error.inc
|
||||
--source include/stop_slave_sql.inc
|
||||
|
||||
stop slave;
|
||||
change master to master_user='root';
|
||||
source include/start_slave.inc;
|
||||
source include/check_slave_no_error.inc;
|
||||
|
@ -70,8 +70,12 @@ stop slave;
|
|||
change master to master_user='impossible_user_name';
|
||||
start slave;
|
||||
let $slave_io_errno= 1045;
|
||||
source include/wait_for_slave_io_error.inc;
|
||||
--source include/wait_for_slave_io_error.inc
|
||||
--source include/stop_slave_sql.inc
|
||||
|
||||
stop slave;
|
||||
reset slave;
|
||||
source include/check_slave_no_error.inc;
|
||||
change master to master_user='root';
|
||||
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -75,5 +75,3 @@ diff_files $MYSQLTEST_VARDIR/tmp/rpl_row_UUID_master.sql $MYSQLTEST_VARDIR/tmp/r
|
|||
# this cleanup as no other test will use these files and they'll
|
||||
# be removed at next testsuite run.
|
||||
|
||||
# End of 5.0 test case
|
||||
-- source include/master-slave-end.inc
|
||||
|
|
|
@ -158,8 +158,8 @@ SELECT * FROM t5,t2,t3 WHERE t5.C2='Q' AND t2.c12='R' AND t3.C3 ='S' ORDER BY t5
|
|||
#
|
||||
|
||||
if (`select char_length('$bit_field_special') > 0`) {
|
||||
SET @saved_slave_type_conversions = @@SLAVE_TYPE_CONVERSIONS;
|
||||
connection slave;
|
||||
SET @saved_slave_type_conversions = @@SLAVE_TYPE_CONVERSIONS;
|
||||
eval SET GLOBAL SLAVE_TYPE_CONVERSIONS = '$bit_field_special';
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ DELETE FROM t1;
|
|||
sync_slave_with_master;
|
||||
|
||||
# Just to get a clean binary log
|
||||
source include/reset_master_and_slave.inc;
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
|
@ -368,8 +368,7 @@ INSERT INTO t1 VALUES (1, "", 1);
|
|||
INSERT INTO t1 VALUES (2, repeat(_utf8'a', 16), 2);
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--echo [expecting slave to replicate correctly]
|
||||
|
@ -378,20 +377,14 @@ INSERT INTO t2 VALUES (1, "", 1);
|
|||
INSERT INTO t2 VALUES (2, repeat(_utf8'a', 16), 2);
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection slave;
|
||||
SET GLOBAL SLAVE_TYPE_CONVERSIONS = @saved_slave_type_conversions;
|
||||
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo [expecting slave to replicate correctly]
|
||||
connection master;
|
||||
|
@ -399,8 +392,7 @@ INSERT INTO t4 VALUES (1, "", 1);
|
|||
INSERT INTO t4 VALUES (2, repeat(_utf8'a', 128), 2);
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t4;
|
||||
let $diff_table_2=slave:test.t4;
|
||||
let $diff_tables= master:t4, slave:t4;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--echo [expecting slave to stop]
|
||||
|
@ -413,13 +405,8 @@ connection slave;
|
|||
--let $slave_sql_errno= 1677
|
||||
--let $show_slave_sql_error= 1
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo [expecting slave to stop]
|
||||
connection master;
|
||||
|
@ -431,13 +418,8 @@ connection slave;
|
|||
--let $slave_sql_errno= 1677
|
||||
--let $show_slave_sql_error= 1
|
||||
--source include/wait_for_slave_sql_error.inc
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
connection slave;
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
START SLAVE;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo [expecting slave to replicate correctly]
|
||||
connection master;
|
||||
|
@ -445,8 +427,7 @@ INSERT INTO t7 VALUES (1, "", 1);
|
|||
INSERT INTO t7 VALUES (2, repeat(_utf8'a', 255), 2);
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t7;
|
||||
let $diff_table_2=slave:test.t7;
|
||||
let $diff_tables= master:t7, slave:t7;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
@ -466,8 +447,7 @@ UPDATE t1 SET a = 10;
|
|||
INSERT INTO t1 VALUES (4);
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
@ -545,8 +525,7 @@ UPDATE t1 SET `int_key` = 4 ORDER BY `pk` LIMIT 6;
|
|||
--sync_slave_with_master
|
||||
--echo *** results: t2 must be consistent ****
|
||||
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=master:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--connection master
|
||||
|
@ -584,8 +563,7 @@ UPDATE t1 SET a = 8 WHERE a < 5;
|
|||
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
@ -604,8 +582,8 @@ connection master;
|
|||
|
||||
# Since t1 contain a bit field, we have to do this trick to handle InnoDB
|
||||
if (`select char_length('$bit_field_special') > 0`) {
|
||||
SET @saved_slave_type_conversions = @@SLAVE_TYPE_CONVERSIONS;
|
||||
connection slave;
|
||||
SET @saved_slave_type_conversions = @@SLAVE_TYPE_CONVERSIONS;
|
||||
eval SET GLOBAL SLAVE_TYPE_CONVERSIONS = '$bit_field_special';
|
||||
}
|
||||
|
||||
|
@ -659,8 +637,7 @@ if (`select char_length('$bit_field_special') > 0`) {
|
|||
SET GLOBAL SLAVE_TYPE_CONVERSIONS = @saved_slave_type_conversions;
|
||||
}
|
||||
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
|
|
@ -14,9 +14,8 @@ flush tables;
|
|||
SELECT * FROM t1 ORDER BY a;
|
||||
sync_slave_with_master;
|
||||
|
||||
connection master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM t1 ORDER BY a;
|
||||
connection master;
|
||||
drop table t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#############################################################################
|
||||
# This test is being created to test out the non deterministic items with #
|
||||
# row based replication. #
|
||||
# Original Author: JBM #
|
||||
# Original Date: Aug/09/2005 #
|
||||
# Updated: Aug/29/2005 #
|
||||
#############################################################################
|
||||
# Test: Contains two stored procedures test one that insert data into tables#
|
||||
# and use the LAST_INSERTED_ID() on tables with FOREIGN KEY(a) #
|
||||
|
@ -13,9 +10,6 @@
|
|||
# the table depending on the CASE outcome. The test uses this SP in a#
|
||||
# transaction first rolling back and then commiting, #
|
||||
#############################################################################
|
||||
# Mod Date: 08/22/2005 #
|
||||
# TEST: Added test to include UPDATE CASCADE on table with FK per Trudy #
|
||||
#############################################################################
|
||||
|
||||
|
||||
|
||||
|
@ -23,19 +17,6 @@
|
|||
-- source include/have_binlog_format_row.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
|
||||
# Begin clean up test section
|
||||
connection master;
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS test.p1;
|
||||
DROP PROCEDURE IF EXISTS test.p2;
|
||||
DROP PROCEDURE IF EXISTS test.p3;
|
||||
DROP TABLE IF EXISTS test.t3;
|
||||
DROP TABLE IF EXISTS test.t1;
|
||||
DROP TABLE IF EXISTS test.t2;
|
||||
--enable_warnings
|
||||
# End of cleanup
|
||||
|
||||
# Begin test section 1
|
||||
|
||||
eval CREATE TABLE test.t1 (a INT AUTO_INCREMENT KEY, t CHAR(6)) ENGINE=$engine_type;
|
||||
|
@ -71,9 +52,7 @@ SELECT * FROM test.t2;
|
|||
|
||||
let $message=< -- test 1 select slave after p1 -- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
SELECT * FROM test.t2;
|
||||
|
||||
|
@ -86,9 +65,7 @@ SELECT * FROM test.t2;
|
|||
|
||||
let $message=< -- test 1 select slave after p2 -- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
SELECT * FROM test.t2;
|
||||
|
||||
|
@ -136,9 +113,7 @@ SELECT * FROM test.t2;
|
|||
|
||||
let $message=< -- test 2 select Slave after p1 -- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
SELECT * FROM test.t2;
|
||||
|
||||
|
@ -153,9 +128,7 @@ SELECT * FROM test.t2;
|
|||
|
||||
let $message=< -- test 1 select Slave after p2 -- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
SELECT * FROM test.t2;
|
||||
|
||||
|
@ -195,9 +168,7 @@ while ($n)
|
|||
|
||||
ROLLBACK;
|
||||
select * from test.t3;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from test.t3;
|
||||
|
||||
connection master;
|
||||
|
@ -216,9 +187,7 @@ while ($n)
|
|||
|
||||
COMMIT;
|
||||
select * from test.t3;
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
select * from test.t3;
|
||||
|
||||
connection master;
|
||||
|
@ -228,12 +197,12 @@ connection master;
|
|||
# First lets cleanup
|
||||
SET AUTOCOMMIT=1;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
DROP PROCEDURE IF EXISTS test.p3;
|
||||
DROP PROCEDURE IF EXISTS test.p1;
|
||||
DROP PROCEDURE IF EXISTS test.p2;
|
||||
DROP TABLE IF EXISTS test.t1;
|
||||
DROP TABLE IF EXISTS test.t2;
|
||||
DROP TABLE IF EXISTS test.t3;
|
||||
sync_slave_with_master;
|
||||
DROP PROCEDURE test.p3;
|
||||
DROP PROCEDURE test.p1;
|
||||
DROP PROCEDURE test.p2;
|
||||
DROP TABLE test.t1;
|
||||
DROP TABLE test.t2;
|
||||
DROP TABLE test.t3;
|
||||
|
||||
# End of 5.0 test case
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
#############################################################################
|
||||
# Original Author: JBM #
|
||||
# Original Date: Aug/15/2005 #
|
||||
# Updated: 08/29/2005 Remove sleeps #
|
||||
#############################################################################
|
||||
# TEST: SP that creates table, starts tranaction inserts. Save point, insert#
|
||||
# rollback to save point and then commits. #
|
||||
#############################################################################
|
||||
|
@ -10,14 +6,6 @@
|
|||
-- source include/have_binlog_format_row.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
# Begin clean up test section
|
||||
connection master;
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS test.p1;
|
||||
DROP TABLE IF EXISTS test.t1;
|
||||
--enable_warnings
|
||||
# End of cleanup
|
||||
|
||||
# Begin test section 1
|
||||
delimiter |;
|
||||
eval CREATE PROCEDURE test.p1(IN i INT)
|
||||
|
@ -42,9 +30,7 @@ SELECT * FROM test.t1;
|
|||
|
||||
let $message=< ---- Slave selects-- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
|
||||
let $message=< ---- Master selects-- >;
|
||||
|
@ -55,16 +41,15 @@ SELECT * FROM test.t1;
|
|||
|
||||
let $message=< ---- Slave selects-- >;
|
||||
--source include/show_msg.inc
|
||||
save_master_pos;
|
||||
connection slave;
|
||||
sync_with_master;
|
||||
sync_slave_with_master;
|
||||
SELECT * FROM test.t1;
|
||||
|
||||
connection master;
|
||||
#show binlog events;
|
||||
|
||||
|
||||
DROP PROCEDURE IF EXISTS test.p1;
|
||||
DROP TABLE IF EXISTS test.t1;
|
||||
DROP PROCEDURE test.p1;
|
||||
DROP TABLE test.t1;
|
||||
|
||||
# End of 5.0 test case
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
# BUG#49481: RBR: MyISAM and bit fields may cause slave to stop on
|
||||
# delete cant find record
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
|
||||
-- connection master
|
||||
-- eval CREATE TABLE t1 (c1 BIT, c2 INT) Engine=$engine
|
||||
|
@ -37,8 +37,7 @@ INSERT INTO `t1` VALUES ( 1, 1 );
|
|||
UPDATE t1 SET c1=NULL where c2=1;
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1=master:test.t1
|
||||
-- let $diff_table_2=slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
-- connection master
|
||||
|
@ -46,15 +45,14 @@ UPDATE t1 SET c1=NULL where c2=1;
|
|||
DELETE FROM t1 WHERE c2=1 LIMIT 1;
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1=master:test.t1
|
||||
-- let $diff_table_2=slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
-- connection master
|
||||
DROP TABLE t1;
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
-- source include/rpl_reset.inc
|
||||
|
||||
-- connection master
|
||||
|
||||
|
@ -68,8 +66,7 @@ SELECT * FROM t1;
|
|||
UPDATE t1 SET c1=NULL WHERE c1='w';
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1=master:test.t1
|
||||
-- let $diff_table_2=slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
-- connection master
|
||||
|
@ -77,8 +74,7 @@ UPDATE t1 SET c1=NULL WHERE c1='w';
|
|||
DELETE FROM t1 LIMIT 2;
|
||||
-- sync_slave_with_master
|
||||
|
||||
-- let $diff_table_1=master:test.t1
|
||||
-- let $diff_table_2=slave:test.t1
|
||||
-- let $diff_tables= master:t1, slave:t1
|
||||
-- source include/diff_tables.inc
|
||||
|
||||
-- connection master
|
||||
|
|
|
@ -177,5 +177,3 @@ UNLOCK TABLES;
|
|||
--connection master
|
||||
DROP TABLE t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of tests
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
# Requires binlog_format=statement format since query involving
|
||||
# get_lock() is logged in row format if binlog_format=mixed or row.
|
||||
-- source include/have_binlog_format_statement.inc
|
||||
-- source include/master-slave.inc
|
||||
|
||||
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
||||
|
||||
# Load some data into t1
|
||||
create table t1 (word char(20) not null);
|
||||
load data infile '../../std_data/words.dat' into table t1;
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
|
||||
select * from t1 limit 10;
|
||||
|
||||
#
|
||||
# Test slave with wrong password
|
||||
#
|
||||
sync_slave_with_master;
|
||||
stop slave;
|
||||
connection master;
|
||||
set password for root@"localhost" = password('foo');
|
||||
connection slave;
|
||||
start slave;
|
||||
connection master;
|
||||
#
|
||||
# Give slave time to do at last one failed connect retry
|
||||
# This one must be short so that the slave will not stop retrying
|
||||
real_sleep 2;
|
||||
set password for root@"localhost" = password('');
|
||||
# Give slave time to connect (will retry every second)
|
||||
sleep 2;
|
||||
|
||||
create table t3(n int);
|
||||
insert into t3 values(1),(2);
|
||||
sync_slave_with_master;
|
||||
select * from t3;
|
||||
select sum(length(word)) from t1;
|
||||
connection master;
|
||||
drop table t1,t3;
|
||||
sync_slave_with_master;
|
||||
|
||||
# Test if the slave SQL thread can be more than 16K behind the slave
|
||||
# I/O thread (> IO_SIZE)
|
||||
|
||||
connection master;
|
||||
# we'll use table-level locking to delay slave SQL thread
|
||||
eval create table t1 (n int) engine=$engine_type;
|
||||
sync_slave_with_master;
|
||||
connection master;
|
||||
reset master;
|
||||
connection slave;
|
||||
stop slave;
|
||||
reset slave;
|
||||
|
||||
connection master;
|
||||
let $1=5000;
|
||||
# Generate 16K of relay log
|
||||
disable_query_log;
|
||||
while ($1)
|
||||
{
|
||||
eval insert into t1 values($1);
|
||||
dec $1;
|
||||
}
|
||||
enable_query_log;
|
||||
|
||||
# Try to cause a large relay log lag on the slave by locking t1
|
||||
connection slave;
|
||||
lock tables t1 read;
|
||||
start slave;
|
||||
connection master;
|
||||
--source include/sync_slave_io_with_master.inc
|
||||
unlock tables;
|
||||
|
||||
#test handling of aborted connection in the middle of update
|
||||
|
||||
connection master;
|
||||
create table t2(id int);
|
||||
insert into t2 values(connection_id());
|
||||
|
||||
connection master1;
|
||||
# Avoid generating result
|
||||
create temporary table t3(n int);
|
||||
--disable_warnings
|
||||
insert into t3 select get_lock('crash_lock%20C', 1) from t2;
|
||||
--enable_warnings
|
||||
|
||||
connection master;
|
||||
send update t1 set n = n + get_lock('crash_lock%20C', 2);
|
||||
connection master1;
|
||||
sleep 3;
|
||||
select (@id := id) - id from t2;
|
||||
kill @id;
|
||||
# We don't drop t3 as this is a temporary table
|
||||
drop table t2;
|
||||
connection master;
|
||||
# The get_lock function causes warning for unsafe statement.
|
||||
--disable_warnings
|
||||
--error 1317,2013
|
||||
reap;
|
||||
--enable_warnings
|
||||
connection slave;
|
||||
# The SQL slave thread should now have stopped because the query was killed on
|
||||
# the master (so it has a non-zero error code in the binlog).
|
||||
--source include/wait_for_slave_sql_to_stop.inc
|
||||
|
||||
# The following test can't be done because the result of Pos will differ
|
||||
# on different computers
|
||||
# --replace_result $MASTER_MYPORT MASTER_PORT
|
||||
# show slave status;
|
||||
|
||||
set global sql_slave_skip_counter=1;
|
||||
start slave;
|
||||
select count(*) from t1;
|
||||
connection master1;
|
||||
drop table t1;
|
||||
create table t1 (n int);
|
||||
insert into t1 values(3456);
|
||||
insert into mysql.user (Host, User, Password)
|
||||
VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
|
||||
select select_priv,user from mysql.user where user = _binary'blafasel2';
|
||||
update mysql.user set Select_priv = "Y" where User= _binary"blafasel2";
|
||||
select select_priv,user from mysql.user where user = _binary'blafasel2';
|
||||
sync_slave_with_master;
|
||||
select n from t1;
|
||||
select select_priv,user from mysql.user where user = _binary'blafasel2';
|
||||
connection master1;
|
||||
drop table t1;
|
||||
delete from mysql.user where user="blafasel2";
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
|
@ -30,6 +30,11 @@ let $errno= query_get_value(SHOW SLAVE STATUS, Last_SQL_Errno, 1);
|
|||
--echo Error: "$error" (expected different error codes on master and slave)
|
||||
--echo Errno: "$errno" (expected 0)
|
||||
drop table t1;
|
||||
--source include/stop_slave.inc
|
||||
# Clear error messages.
|
||||
RESET SLAVE;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/rpl_end.inc
|
||||
|
|
268
mysql-test/extra/rpl_tests/rpl_stm_create_if_not_exists.test
Normal file
268
mysql-test/extra/rpl_tests/rpl_stm_create_if_not_exists.test
Normal file
|
@ -0,0 +1,268 @@
|
|||
--echo
|
||||
--echo
|
||||
connection master;
|
||||
|
||||
if ($is_temporary)
|
||||
{
|
||||
--let $_temporary=TEMPORARY
|
||||
}
|
||||
|
||||
CREATE TABLE t2(c1 INT, c2 char(10));
|
||||
INSERT INTO t2 VALUES(1, 'abc'), (2, 'abc');
|
||||
|
||||
--echo
|
||||
--echo # The original query should be binlogged if the table does not exist.
|
||||
--echo # ------------------------------------------------------------------
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1 (c1 INT , c2 INT, c3 char(10), c4 INT KEY)
|
||||
SELECT 'abc' AS c3, 1 AS c4;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # The statement should be binlogged as two events. one is
|
||||
--echo # 'CREATE $_temporary TABLE IF NOT EXISTS ..', another one is
|
||||
--echo # 'INSERT ... SELECT'.
|
||||
--echo # ------------------------------------------------------------------
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
SELECT 'abc', 2;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # Verify if it can be binlogged with right database name when the table
|
||||
--echo # is not in the default database
|
||||
--echo
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS db1;
|
||||
--enable_warnings
|
||||
CREATE DATABASE db1;
|
||||
USE db1;
|
||||
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS test.t1
|
||||
SELECT 'abc', 20;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:test.t1,slave:test.t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
USE test;
|
||||
DROP DATABASE db1;
|
||||
|
||||
--echo
|
||||
--echo # It should be binlogged as 'REPLACE ... SELECT'
|
||||
--echo # if the original statement has option REPLACE
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
REPLACE SELECT '123', 2;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # It should be binlogged as 'INSERT IGNORE... SELECT'
|
||||
--echo # if the original statement has option IGNORE
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
IGNORE SELECT '123', 2;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # Nothing should be binlogged if error happens and no any row is inserted
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
--error ER_DUP_ENTRY
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
SELECT '123', 2;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # Verify it can binlog well when there are some braces('(')
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
(SELECT '123', 3) UNION (SELECT '123', 4);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
REPLACE (SELECT 'abc', 3) UNION (SELECT 'abc', 4);
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
IGNORE (SELECT '123', 3) UNION (SELECT '123', 4);
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--echo
|
||||
--echo # Throw a warning that table already exists and don't insert anything
|
||||
--echo
|
||||
CREATE VIEW t3 AS SELECT * FROM t2;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS t3
|
||||
SELECT '123', 2;
|
||||
source include/show_binlog_events.inc;
|
||||
DROP VIEW t3;
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # The statement can be binlogged correctly when it is in a SP/EVENT/TRIGGER
|
||||
--echo
|
||||
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS p1;
|
||||
--enable_warnings
|
||||
eval CREATE PROCEDURE p1(IN a INT)
|
||||
CREATE $_temporary TABLE IF NOT EXISTS t1 SELECT '123', a;
|
||||
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
call p1(500);
|
||||
call p1(600);
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
DROP PROCEDURE p1;
|
||||
|
||||
--echo
|
||||
--echo # The statement can be binlogged correctly when it is in a prepared statement
|
||||
--echo
|
||||
eval PREPARE stm FROM "CREATE $_temporary TABLE IF NOT EXISTS t1 SELECT '123', ?";
|
||||
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
SET @a= 700;
|
||||
EXECUTE stm USING @a;
|
||||
SET @a= 800;
|
||||
EXECUTE stm USING @a;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
--echo
|
||||
--echo # The statement can be binlogged correctly when it is in a conditional comment
|
||||
--echo
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo # The whole statement in a conditional comment
|
||||
eval /*!CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
SELECT 'abc', 900*/;
|
||||
source include/show_binlog_events.inc;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo
|
||||
--echo # There is an long comment before SELECT
|
||||
eval /*!CREATE $_temporary /*blabla*/ TABLE IF NOT EXISTS t1
|
||||
SELECT 'abc', 901*/;
|
||||
source include/show_binlog_events.inc;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo
|
||||
--echo # Conditional comment starts just from SELECT
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
/*!SELECT 'abc',*/ 902;
|
||||
source include/show_binlog_events.inc;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo
|
||||
--echo # Only SELECT keyword is in the conditional comment
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
/*!SELECT*/ /*!'abc',*/ 904;
|
||||
source include/show_binlog_events.inc;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo
|
||||
--echo # Conditional comment is after SELECT keyword
|
||||
eval CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
SELECT /*!'abc',*/ 903;
|
||||
source include/show_binlog_events.inc;
|
||||
let binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
|
||||
--echo
|
||||
--echo # Conditional comment ends just before SELECT keyword
|
||||
eval /*!CREATE $_temporary TABLE IF NOT EXISTS t1
|
||||
*/SELECT 'abc', 905;
|
||||
source include/show_binlog_events.inc;
|
||||
|
||||
--sync_slave_with_master
|
||||
--connection master
|
||||
|
||||
if (!$is_temporary)
|
||||
{
|
||||
--let $diff_tables= master:t1,slave:t1
|
||||
--source include/diff_tables.inc
|
||||
}
|
||||
|
||||
DROP TABLE t2;
|
||||
eval DROP $_temporary TABLE t1;
|
||||
|
|
@ -139,9 +139,10 @@ set @@global.debug="-d";
|
|||
# clean-up
|
||||
#
|
||||
|
||||
# the sql thread has an error, so reset replication state
|
||||
--let $rpl_only_running_threads= 1
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
connection master;
|
||||
drop table tm, ti;
|
||||
|
||||
connection slave; # slave SQL thread is stopped
|
||||
source include/stop_slave.inc;
|
||||
drop table tm, ti;
|
||||
--sync_slave_with_master
|
||||
|
|
|
@ -52,9 +52,8 @@ source include/wait_for_slave_sql_to_stop.inc;
|
|||
|
||||
--echo # Slave should stop after the transaction has committed.
|
||||
--echo # So t1 on master is same to t1 on slave.
|
||||
let diff_table_1=master:test.t1;
|
||||
let diff_table_2=slave:test.t1;
|
||||
source include/diff_tables.inc;
|
||||
--let $diff_tables= master:t1, slave:t1
|
||||
--source include/diff_tables.inc
|
||||
|
||||
connection slave;
|
||||
START SLAVE SQL_THREAD;
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
####################
|
||||
# Change Author: JBM
|
||||
# Change Date: 2006-01-17
|
||||
# Change: Added order by in select
|
||||
####################
|
||||
# Change Date: 2006-02-02
|
||||
# Change: renamed to make bettre sense,
|
||||
# and wrapped per Engine test
|
||||
############################
|
||||
source include/master-slave.inc;
|
||||
|
||||
#
|
||||
|
@ -30,6 +21,5 @@ sync_slave_with_master;
|
|||
SELECT * FROM t1 ORDER BY id;
|
||||
connection master;
|
||||
DROP TABLE t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
# End of 4.1 tests
|
||||
--source include/rpl_end.inc
|
||||
|
|
86
mysql-test/extra/rpl_tests/rpl_test_framework.inc
Normal file
86
mysql-test/extra/rpl_tests/rpl_test_framework.inc
Normal file
|
@ -0,0 +1,86 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Auxiliary file used by suite/rpl/t/rpl_test_framework.test
|
||||
#
|
||||
# The purpose is to check that the sync chain generated in
|
||||
# rpl_change_topology.inc (invoked from rpl_init.inc) is correct. This
|
||||
# is done in two ways:
|
||||
# (1) Print the sync chain.
|
||||
# (2) Execute a statement and verify that it replicates to all slaves.
|
||||
#
|
||||
#
|
||||
# ==== Implementation ====
|
||||
#
|
||||
# Does this:
|
||||
# (1) Set up a given replication topology (rpl_init.inc)
|
||||
# (2) Print $rpl_sync_chain
|
||||
# (3) Execute "DELETE FROM t1" and then "INSERT INTO t1" on the master
|
||||
# (4) Sync and compare all servers.
|
||||
# (5) Clean up the replication topology (rpl_end.inc)
|
||||
#
|
||||
# (Technical detail: Since DELETE FROM t1 is not executed at the end,
|
||||
# some servers may have rows left in t1 from a previous invocation of
|
||||
# rpl_test_framework.inc. Therefore, this file will only work in
|
||||
# statement mode where "DELETE FROM t1" removes rows that exist on
|
||||
# slave but not on master.)
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_server_count= <number>
|
||||
# --let $rpl_topology= <topology specification>
|
||||
# --let $masters= <list of masters>
|
||||
# [--let $rpl_diff_servers= <list of servers>]
|
||||
# --source extra/rpl_tests/rpl_test_framework.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $next_number
|
||||
# The INSERT statement will insert $next_number into t1, and
|
||||
# $next_number will increase by 1.
|
||||
#
|
||||
# $rpl_server_count, $rpl_topology:
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# $masters
|
||||
# This should be a list of numbers, each identifying a server.
|
||||
# The DELETE and INSERT statements will be executed on all servers
|
||||
# in the list.
|
||||
#
|
||||
# $rpl_diff_servers
|
||||
# See include/rpl_diff.inc
|
||||
|
||||
--source include/rpl_init.inc
|
||||
--source include/rpl_generate_sync_chain.inc
|
||||
--echo rpl_sync_chain= '$rpl_sync_chain'
|
||||
|
||||
--inc $next_number
|
||||
|
||||
# Iterate over masters
|
||||
while ($masters)
|
||||
{
|
||||
--let $master_i= `SELECT SUBSTRING_INDEX('$masters', ',', 1)`
|
||||
--let $masters= `SELECT SUBSTRING('$masters', LENGTH('$master_i') + 2)`
|
||||
|
||||
# Connect to master and execute statement
|
||||
--let $rpl_connection_name= server_$master_i
|
||||
--source include/rpl_connection.inc
|
||||
DELETE FROM t1;
|
||||
--eval INSERT INTO t1 VALUES ($next_number)
|
||||
}
|
||||
|
||||
--source include/rpl_sync.inc
|
||||
|
||||
# Compare all servers.
|
||||
--let $diff_tables= server_$rpl_server_count:t1
|
||||
--let $server_i= $rpl_server_count
|
||||
--dec $server_i
|
||||
while ($server_i)
|
||||
{
|
||||
--let $diff_tables= server_$server_i:t1,$diff_tables
|
||||
--dec $server_i
|
||||
}
|
||||
--source include/diff_tables.inc
|
||||
|
||||
--let $diff_servers=
|
||||
--let $masters=
|
||||
--source include/rpl_end.inc
|
|
@ -1,11 +1,6 @@
|
|||
#
|
||||
# Copyright 2006 MySQL. All rights reserved.
|
||||
#
|
||||
# Test to check for the different version of truncating a table.
|
||||
# The statements are "TRUNCATE tbl" and "DELETE FROM tbl". We check
|
||||
# the behaviour of each possible value for BINLOG_FORMAT.
|
||||
#
|
||||
# Author(s): Mats Kindahl
|
||||
|
||||
--source include/master-slave.inc
|
||||
|
||||
|
@ -14,3 +9,5 @@ let $trunc_stmt = TRUNCATE TABLE;
|
|||
|
||||
let $trunc_stmt = DELETE FROM;
|
||||
--source extra/rpl_tests/rpl_truncate_helper.test
|
||||
|
||||
--source include/rpl_end.inc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
source include/reset_master_and_slave.inc;
|
||||
--source include/rpl_reset.inc
|
||||
|
||||
--echo **** On Master ****
|
||||
connection master;
|
||||
|
@ -10,8 +10,7 @@ connection master;
|
|||
eval $trunc_stmt t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t1;
|
||||
let $diff_table_2=slave:test.t1;
|
||||
let $diff_tables= master:t1, slave:t1;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
--echo ==== Test using a table with delete triggers ====
|
||||
|
@ -26,8 +25,7 @@ connection master;
|
|||
eval $trunc_stmt t1;
|
||||
sync_slave_with_master;
|
||||
|
||||
let $diff_table_1=master:test.t2;
|
||||
let $diff_table_2=slave:test.t2;
|
||||
let $diff_tables= master:t2, slave:t2;
|
||||
source include/diff_tables.inc;
|
||||
|
||||
connection master;
|
||||
|
|
|
@ -876,7 +876,5 @@ let $can_convert = $if_is_lossy;
|
|||
source extra/rpl_tests/check_type.inc;
|
||||
|
||||
|
||||
disable_warnings;
|
||||
source include/reset_master_and_slave.inc;
|
||||
enable_warnings;
|
||||
--source include/rpl_reset.inc
|
||||
enable_query_log;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
SHOW PROCESSLIST;
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# This is an auxiliary file that mysqltest executes when
|
||||
# sync_slave_with_master or sync_with_master fails. The purpose is to
|
||||
# print debug information.
|
||||
|
||||
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
|
||||
eval SHOW BINLOG EVENTS IN '$binlog_name';
|
||||
|
||||
exit;
|
||||
--let $rpl_server_count= 0
|
||||
--let $rpl_only_current_connection= 1
|
||||
--source include/show_rpl_debug_info.inc
|
||||
|
|
175
mysql-test/include/assert.inc
Normal file
175
mysql-test/include/assert.inc
Normal file
|
@ -0,0 +1,175 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Check if a condition holds, fail with debug info if not.
|
||||
#
|
||||
# The condition is parsed before executed. The following constructs
|
||||
# are supported:
|
||||
#
|
||||
# [SQL_STATEMENT, COLUMN, ROW]
|
||||
# The square bracket is replaced by the result from SQL_STATEMENT,
|
||||
# in the given COLUMN and ROW.
|
||||
#
|
||||
# Optionally, SQL_STATEMENT may have the form:
|
||||
# connection:SQL_STATEMENT
|
||||
# In this case, SQL_STATEMENT is executed on the named connection.
|
||||
# All other queries executed by this script will be executed on
|
||||
# the connection that was in use when this script was started.
|
||||
# The current connection will also be restored at the end of this
|
||||
# script.
|
||||
#
|
||||
# Nested sub-statements on this form are not allowed.
|
||||
#
|
||||
# <1>
|
||||
# This is a shorthand for the result of the first executed square
|
||||
# bracket. <2> is a shorthand for the second executed square
|
||||
# bracket, and so on.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $assert_text= Relay_Log_Pos must be between min_pos and max_pos
|
||||
# --let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] >= $min_pos AND <1> <= $max_pos
|
||||
# [--let $assert_quiet= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/assert.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# $assert_text
|
||||
# Text that describes what is being checked. This text is written to
|
||||
# the query log so it should not contain non-deterministic elements.
|
||||
#
|
||||
# $assert_cond
|
||||
# Condition to check. See above for details about the format. The
|
||||
# condition will be executed as `SELECT $assert_cond`.
|
||||
#
|
||||
# Both $assert_cond and the result from any substatement on the
|
||||
# form [SQL_STATEMENT, COLUMN, ROW] will be used in SQL statements,
|
||||
# inside single quotes (as in '$assert_text'). So any single quotes
|
||||
# in these texts must be escaped or replaced by double quotes.
|
||||
#
|
||||
# $rpl_debug
|
||||
# Print extra debug info.
|
||||
|
||||
|
||||
--let $include_filename= assert.inc [$assert_text]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: assert_text='$assert_text' assert_cond='$assert_cond'
|
||||
}
|
||||
|
||||
# Sanity-check input
|
||||
if (!$assert_text)
|
||||
{
|
||||
--die ERROR IN TEST: the mysqltest variable rpl_test must be set
|
||||
}
|
||||
|
||||
--let $_assert_old_connection= $CURRENT_CONNECTION
|
||||
|
||||
# Evaluate square brackets in cond.
|
||||
--let $_assert_substmt_number= 1
|
||||
--let $_assert_cond_interp= '$assert_cond'
|
||||
--let $_assert_lbracket= `SELECT LOCATE('[', $_assert_cond_interp)`
|
||||
while ($_assert_lbracket)
|
||||
{
|
||||
# Get position of right bracket
|
||||
--let $_assert_rbracket= `SELECT LOCATE(']', $_assert_cond_interp)`
|
||||
if (!$_assert_rbracket)
|
||||
{
|
||||
--echo BUG IN TEST: Mismatching square brackets in assert_cond.
|
||||
--echo Original assert_cond='$assert_cond'
|
||||
--echo Interpolated assert_cond=$_assert_cond_interp
|
||||
--die BUG IN TEST: Mismatching square brackets in $assert_cond
|
||||
}
|
||||
|
||||
# Get sub-statement from statement. Preserve escapes for single quotes.
|
||||
--let $_assert_full_substmt= `SELECT QUOTE(SUBSTRING($_assert_cond_interp, $_assert_lbracket + 1, $_assert_rbracket - $_assert_lbracket - 1))`
|
||||
|
||||
# Get connection from sub-statement
|
||||
--let $_assert_colon= `SELECT IF($_assert_full_substmt REGEXP '^[a-zA-Z_][a-zA-Z_0-9]*:', LOCATE(':', $_assert_full_substmt), 0)`
|
||||
--let $_assert_connection=
|
||||
--let $_assert_substmt= $_assert_full_substmt
|
||||
if ($_assert_colon)
|
||||
{
|
||||
--let $_assert_connection= `SELECT SUBSTRING($_assert_substmt, 1, $_assert_colon - 1)`
|
||||
# Preserve escapes for single quotes.
|
||||
--let $_assert_substmt= `SELECT QUOTE(SUBSTRING($_assert_substmt, $_assert_colon + 1))`
|
||||
}
|
||||
|
||||
# Interpolate escapes before using condition outside string context.
|
||||
--let $_assert_substmt_interp= `SELECT $_assert_substmt`
|
||||
|
||||
# Execute and get result from sub-statement
|
||||
if ($_assert_connection)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: connection='$_assert_connection' sub-statement=$_assert_substmt
|
||||
}
|
||||
--let $rpl_connection_name= $_assert_connection
|
||||
--source include/rpl_connection.inc
|
||||
--let $_assert_substmt_result= query_get_value($_assert_substmt_interp)
|
||||
--let $rpl_connection_name= $_assert_old_connection
|
||||
--source include/rpl_connection.inc
|
||||
}
|
||||
if (!$_assert_connection)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: old connection, sub-statement=$_assert_substmt
|
||||
}
|
||||
--let $_assert_substmt_result= query_get_value($_assert_substmt_interp)
|
||||
}
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: result of sub-statement='$_assert_substmt_result'
|
||||
}
|
||||
|
||||
# Replace sub-statement by its result
|
||||
--let $_assert_cond_interp= `SELECT QUOTE(REPLACE($_assert_cond_interp, CONCAT('[', $_assert_full_substmt, ']'), '$_assert_substmt_result'))`
|
||||
# Replace result references by result
|
||||
--let $_assert_cond_interp= `SELECT QUOTE(REPLACE($_assert_cond_interp, '<$_assert_substmt_number>', '$_assert_substmt_result'))`
|
||||
|
||||
--let $_assert_lbracket= `SELECT LOCATE('[', $_assert_cond_interp)`
|
||||
|
||||
--inc $_assert_substmt_number
|
||||
}
|
||||
|
||||
# Interpolate escapes before using condition outside string context.
|
||||
--let $_assert_cond_interp= `SELECT $_assert_cond_interp`
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: interpolated_cond='$_assert_cond_interp'
|
||||
}
|
||||
|
||||
# Execute.
|
||||
--let $_assert_result= `SELECT $_assert_cond_interp`
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # debug: result='$_assert_result'
|
||||
}
|
||||
|
||||
# Check.
|
||||
if (!$_assert_result)
|
||||
{
|
||||
--echo ######## Test assertion failed: $assert_text ########
|
||||
--echo Dumping debug info:
|
||||
if ($rpl_inited)
|
||||
{
|
||||
--source include/show_rpl_debug_info.inc
|
||||
}
|
||||
--echo Assertion text: '$assert_text'
|
||||
--echo Assertion condition: '$assert_cond'
|
||||
--echo Assertion condition, interpolated: '$_assert_cond_interp'
|
||||
--echo Assertion result: '$_assert_result'
|
||||
--die Test assertion failed in assertion.inc
|
||||
}
|
||||
|
||||
--let $include_filename= assert.inc [$assert_text]
|
||||
--source include/end_include_file.inc
|
||||
|
||||
--let $assert_text=
|
||||
--let $assert_cond=
|
83
mysql-test/include/begin_include_file.inc
Normal file
83
mysql-test/include/begin_include_file.inc
Normal file
|
@ -0,0 +1,83 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# This is an auxiliary file that facilitates writing include/*.inc
|
||||
# files. It has three purposes:
|
||||
#
|
||||
# 1. Store mtr's state at the beginning of the .inc file and restore
|
||||
# the state at the end. The following status is restored:
|
||||
#
|
||||
# disable_warnings
|
||||
# disable_query_log
|
||||
# disable_result_log
|
||||
# disable_abort_on_errors
|
||||
# Current connection
|
||||
#
|
||||
# 2. This file also prints the name of the .inc file that sources
|
||||
# it. Only the name of the top-level .inc file is printed: if
|
||||
# file_1.inc sources file_2.inc, then this file only prints
|
||||
# file_1.inc.
|
||||
#
|
||||
# 3. If the mysqltest variable $rpl_debug is set, then
|
||||
# this file will print:
|
||||
#
|
||||
# ==== BEGIN include/<filename> ====
|
||||
#
|
||||
# and end_include_file.inc will print
|
||||
#
|
||||
# ==== END include/<filename> ====
|
||||
#
|
||||
# These printouts are indented to make it easier to read the
|
||||
# result log.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# # At the beginning of include/my_file.inc:
|
||||
# --let $include_filename= my_file.inc
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/begin_include_file.inc
|
||||
#
|
||||
# # At the end of include/my_file.inc:
|
||||
# --let $include_filename= my_file.inc
|
||||
# --source include/end_include_file.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $include_filename
|
||||
# The basename of the file: a file named /path/to/my_file.inc
|
||||
# should set $include_filename=my_file.inc. This parameter
|
||||
# must be provided both for begin_include_file.inc and
|
||||
# end_include_file.inc.
|
||||
#
|
||||
# $rpl_debug
|
||||
# If set, this script will print the following text:
|
||||
# ==== BEGIN include/$include_filename.inc ====
|
||||
|
||||
|
||||
# Print 'include/$include_filename', but only when invoked from
|
||||
# the top-level. We don't want to print
|
||||
# 'include/$include_filename' from all files included
|
||||
# recursively.
|
||||
if (!$_include_file_depth)
|
||||
{
|
||||
--echo include/$include_filename
|
||||
--let $_include_file_depth= 0
|
||||
}
|
||||
--inc $_include_file_depth
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo $_include_file_indent==== BEGIN include/$include_filename ====
|
||||
}
|
||||
|
||||
--let $_include_file_enabled_warnings= $ENABLED_WARNINGS$_include_file_enabled_warnings
|
||||
--let $_include_file_enabled_query_log= $ENABLED_QUERY_LOG$_include_file_enabled_query_log
|
||||
--let $_include_file_enabled_result_log= $ENABLED_RESULT_LOG$_include_file_enabled_result_log
|
||||
--let $_include_file_enabled_abort_on_error= $ENABLED_ABORT_ON_ERROR$_include_file_enabled_abort_on_error
|
||||
--let $_include_file_connection= $CURRENT_CONNECTION,$_include_file_connection
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo $_include_file_indent con='$CURRENT_CONNECTION' warn='$ENABLED_WARNINGS' qlog='$ENABLED_QUERY_LOG' rlog='$ENABLED_RESULT_LOG' aborterr='$ENABLED_ABORT_ON_ERROR'
|
||||
}
|
||||
|
||||
--let $include_filename=
|
||||
--let $_include_file_indent= .$_include_file_indent
|
|
@ -1,15 +1,73 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# This test is executed twice for each test case. Before every
|
||||
# testcase it is run with mysqltest in record mode and will thus
|
||||
# produce an output file that can be compared to output from after the
|
||||
# tescase. In that way, it is possible to check that a testcase does
|
||||
# not have any unwanted side affects.
|
||||
|
||||
#
|
||||
# This test is executed twice for each test case if mysql-test-run is passed
|
||||
# the flag --check-testcase. Before every testcase it is run with mysqltest
|
||||
# in record mode and will thus produce an output file that can be compared
|
||||
# to output from after the tescase.
|
||||
# In that way its possible to check that a testcase does not have
|
||||
# any unwanted side affects.
|
||||
#
|
||||
--disable_query_log
|
||||
|
||||
# We want to ensure all slave configuration is restored. But SHOW
|
||||
# SLAVE STATUS returns nothing for servers not configured as slaves,
|
||||
# and (after BUG#28796 was fixed) there is no way to de-configure a
|
||||
# slave. Hence, it's impossible to clean up the replication state at
|
||||
# the end. But we want to check that the slave is stopped, there is
|
||||
# no error, and a few other invariants. So we issue SHOW SLAVE
|
||||
# STATUS, and if it returns no rows we fake the result.
|
||||
--let $tmp= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1)
|
||||
--let $tmp= `SELECT '$tmp' = 'No such row'`
|
||||
if ($tmp)
|
||||
{
|
||||
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
|
||||
--echo Slave_IO_State
|
||||
--echo Master_Host 127.0.0.1
|
||||
--echo Master_User root
|
||||
--echo Master_Port #
|
||||
--echo Connect_Retry #
|
||||
--echo Master_Log_File #
|
||||
--echo Read_Master_Log_Pos #
|
||||
--echo Relay_Log_File #
|
||||
--echo Relay_Log_Pos #
|
||||
--echo Relay_Master_Log_File #
|
||||
--echo Slave_IO_Running No
|
||||
--echo Slave_SQL_Running No
|
||||
--echo Replicate_Do_DB #
|
||||
--echo Replicate_Ignore_DB #
|
||||
--echo Replicate_Do_Table #
|
||||
--echo Replicate_Ignore_Table #
|
||||
--echo Replicate_Wild_Do_Table #
|
||||
--echo Replicate_Wild_Ignore_Table #
|
||||
--echo Last_Errno 0
|
||||
--echo Last_Error
|
||||
--echo Skip_Counter 0
|
||||
--echo Exec_Master_Log_Pos #
|
||||
--echo Relay_Log_Space #
|
||||
--echo Until_Condition #
|
||||
--echo Until_Log_File #
|
||||
--echo Until_Log_Pos #
|
||||
--echo Master_SSL_Allowed No
|
||||
--echo Master_SSL_CA_File
|
||||
--echo Master_SSL_CA_Path
|
||||
--echo Master_SSL_Cert
|
||||
--echo Master_SSL_Cipher
|
||||
--echo Master_SSL_Key
|
||||
--echo Seconds_Behind_Master NULL
|
||||
--echo Master_SSL_Verify_Server_Cert No
|
||||
--echo Last_IO_Errno 0
|
||||
--echo Last_IO_Error
|
||||
--echo Last_SQL_Errno 0
|
||||
--echo Last_SQL_Error
|
||||
--echo Replicate_Ignore_Server_Ids
|
||||
--echo Master_Server_Id #
|
||||
}
|
||||
if (!$tmp) {
|
||||
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
|
||||
--replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 #
|
||||
query_vertical
|
||||
SHOW SLAVE STATUS;
|
||||
}
|
||||
|
||||
call mtr.check_testcase();
|
||||
--enable_query_log
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,25 +2,29 @@
|
|||
#
|
||||
# Assert that the slave threads are running and don't have any errors.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --source include/check_slave_running.inc
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/check_slave_is_running.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
--echo Checking that both slave threads are running.
|
||||
|
||||
--let $running= 1
|
||||
--let $slave_sql_running = query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1)
|
||||
--let $slave_io_running = query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1)
|
||||
--let $include_filename= check_slave_is_running.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
if ($slave_sql_running != Yes) {
|
||||
--let $running= 0
|
||||
}
|
||||
if ($slave_io_running != Yes) {
|
||||
--let $running= 0
|
||||
}
|
||||
|
||||
if (!$running) {
|
||||
--echo Slave not running: Slave_SQL_Running = $slave_sql_running Slave_IO_Running = $slave_io_running
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--die Expected slave to be running, but it was not running.
|
||||
}
|
||||
--let $slave_param= Slave_IO_Running
|
||||
--let $slave_param_value= Yes
|
||||
--source include/check_slave_param.inc
|
||||
|
||||
--let $slave_param= Slave_SQL_Running
|
||||
--let $slave_param_value= Yes
|
||||
--source include/check_slave_param.inc
|
||||
|
||||
|
||||
--let $include_filename= check_slave_is_running.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Assert that Slave_SQL_Error and Slave_IO_Error are empty.
|
||||
# Assert that Slave_SQL_Errno = Slave_IO_Errno = 0 in the output from
|
||||
# SHOW SLAVE STATUS.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $slave_param= Exec_Master_Log_Pos
|
||||
# --let $slave_param_value= 4711
|
||||
# --source include/check_slave_running.inc
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/check_slave_no_error.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= check_slave_no_error.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
--let $slave_param= Last_SQL_Errno
|
||||
--let $slave_param_value= 0
|
||||
|
@ -15,3 +25,7 @@
|
|||
--let $slave_param= Last_IO_Errno
|
||||
--let $slave_param_value= 0
|
||||
--source include/check_slave_param.inc
|
||||
|
||||
|
||||
--let $include_filename= check_slave_no_error.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
|
@ -4,13 +4,33 @@
|
|||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $slave_param= Exec_Master_Log_Pos
|
||||
# --let $slave_param_value= 4711
|
||||
# --let $slave_param= COLUMN_NAME
|
||||
# --let $slave_param_value= VALUE
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/check_slave_param.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $slave_param, $slave_param_value
|
||||
# Column name in output of SHOW SLAVE STATUS that should be checked,
|
||||
# and the expected value. Example:
|
||||
# --let $slave_param= Exec_Master_Log_Pos
|
||||
# --let $slave_param_value= 4711
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= check_slave_param.inc [$slave_param]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
--let $_param_value= query_get_value(SHOW SLAVE STATUS, $slave_param, 1)
|
||||
if ($_param_value != $slave_param_value) {
|
||||
--echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value'
|
||||
if (`SELECT '$_param_value' != '$slave_param_value'`) {
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value'
|
||||
--die Wrong value for slave parameter
|
||||
}
|
||||
|
||||
|
||||
--let $include_filename= check_slave_param.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
|
@ -1,130 +0,0 @@
|
|||
#############################################################
|
||||
#
|
||||
# Author: Serge Kozlov <skozlov@mysql.com>
|
||||
# Date: 03/11/2008
|
||||
# Purpose: Set up circular replication based on schema
|
||||
# A->B->C->D->A
|
||||
#
|
||||
# Notes:
|
||||
# 1. --slave-num=3 must be added to *-master.opt file
|
||||
# 2. Even the test uses new names for servers but file names
|
||||
# of log files are still old:
|
||||
# master_a -> master.[log|err]
|
||||
# master_b -> slave.[log|err]
|
||||
# master_c -> slave1.[log|err]
|
||||
# master_d -> slave2.[log|err]
|
||||
#
|
||||
#############################################################
|
||||
--source include/master-slave.inc
|
||||
|
||||
#
|
||||
# Set up circular ring by schema A->B->C->D->A
|
||||
#
|
||||
|
||||
--connection slave
|
||||
STOP SLAVE;
|
||||
RESET SLAVE;
|
||||
|
||||
# master a
|
||||
--connection master
|
||||
--disconnect master
|
||||
connect (master_a,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
RESET MASTER;
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--enable_warnings
|
||||
RESET SLAVE;
|
||||
SET auto_increment_increment = 4;
|
||||
SET auto_increment_offset = 1;
|
||||
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
|
||||
|
||||
# master b
|
||||
--connection slave
|
||||
--disconnect slave
|
||||
connect (master_b,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
RESET MASTER;
|
||||
RESET SLAVE;
|
||||
--replace_result $MASTER_MYPORT MASTER_A_PORT $_binlog_file MASTER_A_LOG_FILE
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
|
||||
SET auto_increment_increment = 4;
|
||||
SET auto_increment_offset = 2;
|
||||
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
|
||||
|
||||
# master c
|
||||
--connection slave1
|
||||
--disconnect slave1
|
||||
connect (master_c,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
|
||||
RESET MASTER;
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--enable_warnings
|
||||
RESET SLAVE;
|
||||
--replace_result $SLAVE_MYPORT MASTER_B_PORT $_binlog_file MASTER_B_LOG_FILE
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT,master_user='root',MASTER_LOG_FILE='$_binlog_file'
|
||||
SET auto_increment_increment = 4;
|
||||
SET auto_increment_offset = 3;
|
||||
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
|
||||
|
||||
# master d
|
||||
connect (master_d,127.0.0.1,root,,test,$SLAVE_MYPORT2,);
|
||||
RESET MASTER;
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--enable_warnings
|
||||
RESET SLAVE;
|
||||
--replace_result $SLAVE_MYPORT1 MASTER_C_PORT $_binlog_file MASTER_C_LOG_FILE
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root',MASTER_LOG_FILE='$_binlog_file'
|
||||
SET auto_increment_increment = 4;
|
||||
SET auto_increment_offset = 4;
|
||||
let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1);
|
||||
|
||||
# master a
|
||||
--connection master_a
|
||||
--replace_result $SLAVE_MYPORT2 MASTER_D_PORT $_binlog_file MASTER_D_LOG_FILE
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT2,master_user='root',MASTER_LOG_FILE='$_binlog_file'
|
||||
|
||||
|
||||
|
||||
# Check server_ids: they should be different
|
||||
--connection master_a
|
||||
let $_id_a= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
|
||||
SHOW VARIABLES LIKE 'auto_increment_%';
|
||||
--connection master_b
|
||||
let $_id_b= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
|
||||
SHOW VARIABLES LIKE 'auto_increment_%';
|
||||
--connection master_c
|
||||
let $_id_c= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
|
||||
SHOW VARIABLES LIKE 'auto_increment_%';
|
||||
--connection master_d
|
||||
let $_id_d= query_get_value(SHOW VARIABLES LIKE 'server_id', Value, 1);
|
||||
SHOW VARIABLES LIKE 'auto_increment_%';
|
||||
--connection master_a
|
||||
let $_compared_ids= (($_id_a <> $_id_b) AND ($_id_a <> $_id_c) AND ($_id_a <> $_id_d) AND ($_id_b <> $_id_c) AND ($_id_b <> $_id_d) AND ($_id_c <> $_id_d)) AS a;
|
||||
let $_compared_ids_result= query_get_value(SELECT $_compared_ids, a, 1);
|
||||
--echo $_compared_ids_result
|
||||
|
||||
# Start ring
|
||||
--connection master_a
|
||||
connect(slave,127.0.0.1,root,,test,$MASTER_MYPORT);
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
--disconnect slave
|
||||
|
||||
--connection master_b
|
||||
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT1);
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
--disconnect slave
|
||||
|
||||
--connection master_c
|
||||
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT);
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
--disconnect slave
|
||||
|
||||
--connection master_d
|
||||
connect(slave,127.0.0.1,root,,test,$SLAVE_MYPORT2);
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
--disconnect slave
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#############################################################
|
||||
#
|
||||
# Author: Serge Kozlov <skozlov@mysql.com>
|
||||
# Date: 03/11/2008
|
||||
# Purpose: Sync all hosts for circular replication based on
|
||||
# schema A->B->C->D->A
|
||||
#
|
||||
# Notes: see include/circular_rpl_for_4_hosts_init.inc
|
||||
#
|
||||
#############################################################
|
||||
|
||||
# Make the full loop of sync
|
||||
--connection master_a
|
||||
--disable_query_log
|
||||
--sync_slave_with_master master_b
|
||||
--sync_slave_with_master master_c
|
||||
--sync_slave_with_master master_d
|
||||
--sync_slave_with_master master_a
|
||||
--sync_slave_with_master master_b
|
||||
--sync_slave_with_master master_c
|
||||
--save_master_pos
|
||||
--connection master_a
|
||||
--enable_query_log
|
|
@ -1,17 +1,28 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Clean up files create by setup_fake_relay_log.inc.
|
||||
# Clean up files created by setup_fake_relay_log.inc.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# See setup_fake_relay_log.inc
|
||||
|
||||
--echo Cleaning up after setup_fake_relay_log.inc
|
||||
--let $include_filename= cleanup_fake_relay_log.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
--disable_query_log
|
||||
--disable_warnings
|
||||
STOP SLAVE SQL_THREAD;
|
||||
RESET SLAVE;
|
||||
|
||||
# Assert that the fake relay log files are gone (RESET SLAVE should
|
||||
# have removed them).
|
||||
--let $file_does_not_exist= $_fake_relay_log
|
||||
--source include/file_does_not_exist.inc
|
||||
|
||||
# Revert variables.
|
||||
eval SET @@global.relay_log_purge= $_fake_relay_log_purge;
|
||||
--enable_warnings
|
||||
--enable_query_log
|
||||
|
||||
eval CHANGE MASTER TO MASTER_HOST = '$_fake_old_master_host';
|
||||
|
||||
|
||||
--let $include_filename= cleanup_fake_relay_log.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Diff the output of a statement on master and slave
|
||||
#
|
||||
# ==== Usage =====
|
||||
#
|
||||
# let $diff_statement= SELECT * FROM t1 WHERE a < 100;
|
||||
# source include/diff_master_slave.inc;
|
||||
|
||||
--echo source include/diff_master_slave.inc;
|
||||
disable_query_log;
|
||||
disable_result_log;
|
||||
|
||||
exec $MYSQL test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_master.out;
|
||||
sync_slave_with_master;
|
||||
exec $MYSQL_SLAVE test -e "$diff_statement" > $MYSQLTEST_VARDIR/tmp/diff_slave.out;
|
||||
|
||||
diff_files $MYSQLTEST_VARDIR/tmp/diff_master.out $MYSQLTEST_VARDIR/tmp/diff_slave.out;
|
||||
|
||||
enable_result_log;
|
||||
enable_query_log;
|
|
@ -1,35 +1,41 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Check if the two given tables (possibly residing on different
|
||||
# master/slave servers) are equal.
|
||||
# Check if all tables in the given list are equal. The tables may have
|
||||
# different names, exist in different connections, and/or reside in
|
||||
# different databases.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# The tables to check are given by the test language variables
|
||||
# $diff_table_1 and $diff_table_2. They must be of the
|
||||
# following form:
|
||||
# --let $diff_tables= [con1:][db1.]t1, [con2:][db2.]t2, ... , [conN:][dbN.]tN
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/diff_tables.inc
|
||||
#
|
||||
# [master:|slave:]database.table
|
||||
# Parameters:
|
||||
# $diff_tables
|
||||
# Comma-separated list of tables to compare. Each table has the form
|
||||
#
|
||||
# [CONNECTION:][DATABASE.]table
|
||||
#
|
||||
# If CONNECTION is given, then that connection is used. If
|
||||
# CONNECTION is not given, then the connection of the previous
|
||||
# table is used (or the current connection, if this is the first
|
||||
# table). If DATABASE is given, the table is read in that
|
||||
# database. If DATABASE is not given, the table is read in the
|
||||
# connection's current database.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# I.e., both database and table must be speicified. Optionally, you
|
||||
# can prefix the name with 'master:' (to read the table on master) or
|
||||
# with 'slave:' (to read the table on slave). If no prefix is given,
|
||||
# reads the table from the current connection. If one of these
|
||||
# variables has a prefix, both should have a prefix.
|
||||
#
|
||||
# ==== Side effects ====
|
||||
#
|
||||
# - Prints "Comparing tables $diff_table_1 and $diff_tables_2".
|
||||
# - Prints "include/diff_tables.inc [$diff_tables]".
|
||||
#
|
||||
# - If the tables are different, prints the difference in a
|
||||
# system-specific format (unified diff if supported) and generates
|
||||
# an error.
|
||||
#
|
||||
# - If $diff_table_1 or $diff_table_2 begins with 'master:' or
|
||||
# 'slave:', it will stay connected to one of those hosts after
|
||||
# execution. The host is only guaranteed to remain unchanged if
|
||||
# none of $diff_table_1 or $diff_table_2 begins with 'master:' or
|
||||
# 'slave:'.
|
||||
#
|
||||
# ==== Bugs ====
|
||||
#
|
||||
|
@ -50,70 +56,135 @@
|
|||
# by character case.
|
||||
|
||||
|
||||
--let $include_filename= diff_tables.inc [$diff_tables]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
|
||||
# Check sanity
|
||||
if (`SELECT LOCATE(',', '$diff_tables') = 0`)
|
||||
{
|
||||
--die ERROR IN TEST: $diff_tables must contain at least two tables (separated by comma)
|
||||
}
|
||||
|
||||
|
||||
# ==== Save both tables to file ====
|
||||
|
||||
--echo Comparing tables $diff_table_1 and $diff_table_2
|
||||
disable_query_log;
|
||||
# Trim off whitespace
|
||||
--let $_dt_tables= `SELECT REPLACE('$diff_tables', ' ', '')`
|
||||
|
||||
--error 0,1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_1
|
||||
--error 0,1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_2
|
||||
# Iterate over all tables
|
||||
--let $_dt_outfile=
|
||||
--let $_dt_prev_outfile=
|
||||
while (`SELECT '$_dt_tables' != ''`)
|
||||
{
|
||||
--let $_dt_table= `SELECT SUBSTRING_INDEX('$_dt_tables', ',', 1)`
|
||||
--let $_dt_tables= `SELECT SUBSTRING('$_dt_tables', LENGTH('$_dt_table') + 2)`
|
||||
|
||||
|
||||
let $_diff_table=$diff_table_2;
|
||||
let $_diff_i=2;
|
||||
while ($_diff_i) {
|
||||
|
||||
# Parse out any leading "master:" or "slave:" from the table specification
|
||||
# and connect the appropriate server.
|
||||
let $_pos= `SELECT LOCATE(':', '$_diff_table')`;
|
||||
let $_diff_conn=`SELECT SUBSTR('$_diff_table', 1, $_pos-1)`;
|
||||
if ($_diff_conn) {
|
||||
let $_diff_table=`SELECT SUBSTR('$_diff_table', $_pos+1)`;
|
||||
connection $_diff_conn;
|
||||
# Parse connection, if any
|
||||
--let $_dt_colon_index= `SELECT LOCATE(':', '$_dt_table')`
|
||||
if ($_dt_colon_index)
|
||||
{
|
||||
--let $_dt_connection= `SELECT SUBSTRING('$_dt_table', 1, $_dt_colon_index - 1)`
|
||||
--let $_dt_table= `SELECT SUBSTRING('$_dt_table', $_dt_colon_index + 1)`
|
||||
--let $rpl_connection_name= $_dt_connection
|
||||
--source include/rpl_connection.inc
|
||||
}
|
||||
|
||||
# Sanity-check the input.
|
||||
let $_diff_error= `SELECT '$_diff_table' NOT LIKE '_%._%'`;
|
||||
if ($_diff_error) {
|
||||
--echo !!!ERROR IN TEST: \$diff_table_$_diff_i='$_diff_table' is not in the form database.table
|
||||
exit;
|
||||
# Parse database name, if any
|
||||
--let $_dt_database_index= `SELECT LOCATE('.', '$_dt_table')`
|
||||
if ($_dt_database_index)
|
||||
{
|
||||
--let $_dt_database= `SELECT SUBSTRING('$_dt_table', 1, $_dt_database_index - 1)`
|
||||
--let $_dt_table= `SELECT SUBSTRING('$_dt_table', $_dt_database_index + 1)`
|
||||
}
|
||||
if (!$_dt_database_index)
|
||||
{
|
||||
--let $_dt_database= `SELECT DATABASE()`
|
||||
}
|
||||
|
||||
# We need the output files to be sorted (so that diff_files does not
|
||||
# think the files are different just because they are differently
|
||||
# ordered). To this end, we first generate a query that sorts the
|
||||
# table by all columns. Since ORDER BY accept column indices, we
|
||||
# just generate a comma-separated list of all numbers from 1 to the
|
||||
# number of columns in the table.
|
||||
let $_diff_column_index=`SELECT MAX(ordinal_position)
|
||||
FROM information_schema.columns
|
||||
WHERE CONCAT(table_schema, '.', table_name) =
|
||||
'$_diff_table'`;
|
||||
let $_diff_column_list=$_diff_column_index;
|
||||
dec $_diff_column_index;
|
||||
while ($_diff_column_index) {
|
||||
let $_diff_column_list=$_diff_column_index, $_diff_column_list;
|
||||
dec $_diff_column_index;
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo con='$_dt_connection' db='$_dt_database' table='$_dt_table'
|
||||
--echo rest of tables='$_dt_tables'
|
||||
}
|
||||
|
||||
# We need to sort the output files so that diff_files does not think
|
||||
# the tables are different just because the rows are differently
|
||||
# ordered. To this end, we first generate a string containing a
|
||||
# comma-separated list of all column names. This is used in the
|
||||
# ORDER BY clause of the following SELECT statement. We get the
|
||||
# column names from INFORMATION_SCHEMA.COLUMNS, and we concatenate
|
||||
# them with GROUP_CONCAT. Since GROUP_CONCAT is limited by the
|
||||
# @@SESSION.group_concat_max_len, which is only 1024 by default, we
|
||||
# first compute the total size of all columns and then increase this
|
||||
# limit if needed. We restore the limit afterwards so as not to
|
||||
# interfere with the test case.
|
||||
|
||||
# Compute length of ORDER BY clause.
|
||||
let $_dt_order_by_length=
|
||||
`SELECT SUM(LENGTH(column_name) + 3) FROM information_schema.columns
|
||||
WHERE table_schema = '$_dt_database' AND table_name = '$_dt_table'`;
|
||||
if (!$_dt_order_by_length)
|
||||
{
|
||||
--echo ERROR IN TEST: table $_dt_database.$_dt_table not found in INFORMATION_SCHEMA.COLUMNS. Did you misspell it?
|
||||
--die ERROR IN TEST: table not found in INFORMATION_SCHEMA. Did you misspell it?
|
||||
}
|
||||
--let $_dt_old_group_concat_max_len=
|
||||
# Increase group_concat_max_len if needed.
|
||||
if (`SELECT $_dt_order_by_length > @@SESSION.group_concat_max_len`)
|
||||
{
|
||||
--let $_dt_old_group_concat_max_len= `SELECT @@SESSION.group_concat_max_len`
|
||||
--eval SET SESSION group_concat_max_len = $_dt_order_by_length;
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # increasing group_concat_max_len from $_dt_old_group_concat_max_len to $_dt_order_by_length
|
||||
}
|
||||
}
|
||||
# Generate ORDER BY clause.
|
||||
# It would be better to do GROUP_CONCAT(CONCAT('`', column_name, '`')) but
|
||||
# BUG#58087 prevents us from returning strings that begin with backticks.
|
||||
let $_dt_column_list=
|
||||
`SELECT GROUP_CONCAT(column_name ORDER BY ORDINAL_POSITION SEPARATOR '`,`')
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = '$_dt_database' AND table_name = '$_dt_table'`;
|
||||
# Restore group_concat_max_len.
|
||||
if ($_dt_old_group_concat_max_len)
|
||||
{
|
||||
--let $_dt_dummy= `SET SESSION group_concat_max_len = $_dt_old_group_concat_max_len
|
||||
}
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo using ORDER BY clause '`$_dt_column_list`'
|
||||
}
|
||||
|
||||
# Now that we have the comma-separated list of columns, we can write
|
||||
# the table to a file.
|
||||
eval SELECT * FROM $_diff_table ORDER BY $_diff_column_list
|
||||
INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/diff_table_$_diff_i';
|
||||
--let $_dt_outfile= `SELECT @@datadir`
|
||||
--let $_dt_outfile= $_dt_outfile/diff_table-$_dt_connection-$_dt_database-$_dt_table
|
||||
eval SELECT * FROM $_dt_database.$_dt_table ORDER BY `$_dt_column_list` INTO OUTFILE '$_dt_outfile';
|
||||
|
||||
# Do the same for $diff_table_1.
|
||||
dec $_diff_i;
|
||||
let $_diff_table=$diff_table_1;
|
||||
# Compare files.
|
||||
if ($_dt_prev_outfile)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo # diffing $_dt_prev_outfile vs $_dt_outfile
|
||||
}
|
||||
--diff_files $_dt_prev_outfile $_dt_outfile
|
||||
# Remove previous outfile. Keep current file for comparison with next table.
|
||||
--remove_file $_dt_prev_outfile
|
||||
}
|
||||
--let $_dt_prev_outfile= $_dt_outfile
|
||||
}
|
||||
|
||||
--remove_file $_dt_prev_outfile
|
||||
|
||||
# ==== Compare the generated files ====
|
||||
|
||||
diff_files $MYSQLTEST_VARDIR/tmp/diff_table_1 $MYSQLTEST_VARDIR/tmp/diff_table_2;
|
||||
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_1
|
||||
--remove_file $MYSQLTEST_VARDIR/tmp/diff_table_2
|
||||
|
||||
enable_query_log;
|
||||
--let $include_filename= diff_tables.inc [$diff_tables]
|
||||
--source include/end_include_file.inc
|
||||
|
|
79
mysql-test/include/end_include_file.inc
Normal file
79
mysql-test/include/end_include_file.inc
Normal file
|
@ -0,0 +1,79 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# See include/begin_include_file.inc
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# # At the end of include/my_file.inc:
|
||||
# --let $include_filename= my_file.inc
|
||||
# [--let $skip_restore_connection= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/begin_include_file.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $include_filename
|
||||
# Name of file that sources this file.
|
||||
#
|
||||
# $skip_restore_connection
|
||||
# By default, this script restores the connection that was active
|
||||
# when begin_include_file.inc was sourced. If
|
||||
# $skip_restore_connection is set, then this step is skipped and
|
||||
# end_include_file.inc leaves the connection as it was before
|
||||
# end_include_file.inc was sourced.
|
||||
|
||||
--let $_tmp= `SELECT SUBSTRING('$_include_file_enabled_warnings', 1, 1)`
|
||||
--let $_include_file_enabled_warnings= `SELECT SUBSTRING('$_include_file_enabled_warnings', 2)`
|
||||
if ($_tmp) {
|
||||
--enable_warnings
|
||||
}
|
||||
if (!$_tmp) {
|
||||
--disable_warnings
|
||||
}
|
||||
|
||||
--let $_tmp= `SELECT SUBSTRING('$_include_file_enabled_query_log', 1, 1)`
|
||||
--let $_include_file_enabled_query_log= `SELECT SUBSTRING('$_include_file_enabled_query_log', 2)`
|
||||
if ($_tmp) {
|
||||
--enable_query_log
|
||||
}
|
||||
if (!$_tmp) {
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
--let $_tmp= `SELECT SUBSTRING('$_include_file_enabled_result_log', 1, 1)`
|
||||
--let $_include_file_enabled_result_log= `SELECT SUBSTRING('$_include_file_enabled_result_log', 2)`
|
||||
if ($_tmp) {
|
||||
--enable_result_log
|
||||
}
|
||||
if (!$_tmp) {
|
||||
--disable_result_log
|
||||
}
|
||||
|
||||
--let $_tmp= `SELECT SUBSTRING('$_include_file_enabled_abort_on_error', 1, 1)`
|
||||
--let $_include_file_enabled_abort_on_error= `SELECT SUBSTRING('$_include_file_enabled_abort_on_error', 2)`
|
||||
if ($_tmp) {
|
||||
--enable_abort_on_error
|
||||
}
|
||||
if (!$_tmp) {
|
||||
--disable_abort_on_error
|
||||
}
|
||||
|
||||
--let $_include_file_rpl_connection_name= `SELECT SUBSTRING_INDEX('$_include_file_connection', ',', 1)`
|
||||
--let $_include_file_connection= `SELECT SUBSTRING('$_include_file_connection', LENGTH('$_include_file_rpl_connection_name') + 2)`
|
||||
if (!$skip_restore_connection)
|
||||
{
|
||||
--let $rpl_connection_name= $_include_file_rpl_connection_name
|
||||
--source include/rpl_connection.inc
|
||||
}
|
||||
--let $skip_restore_connection= 0
|
||||
|
||||
|
||||
--dec $_include_file_depth
|
||||
--let $_include_file_indent= `SELECT REPEAT('.', $_include_file_depth)`
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo $_include_file_indent==== END include/$include_filename ====
|
||||
--echo $_include_file_indent con='$CURRENT_CONNECTION' warn='$ENABLED_WARNINGS' qlog='$ENABLED_QUERY_LOG' rlog='$ENABLED_RESULT_LOG' aborterr='$ENABLED_ABORT_ON_ERROR'
|
||||
}
|
||||
--let $include_filename=
|
17
mysql-test/include/file_does_not_exist.inc
Normal file
17
mysql-test/include/file_does_not_exist.inc
Normal file
|
@ -0,0 +1,17 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Checks that a given file does not exist. If the file exists, the
|
||||
# test fails.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $file_does_not_exist= /path/to/file
|
||||
# --source include/file_does_not_exist.inc
|
||||
|
||||
# Will fail if file exists.
|
||||
--write_file $file_does_not_exist
|
||||
tmp
|
||||
EOF
|
||||
|
||||
# Remove file again.
|
||||
--remove_file $file_does_not_exist
|
17
mysql-test/include/force_restart.inc
Normal file
17
mysql-test/include/force_restart.inc
Normal file
|
@ -0,0 +1,17 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Tell mtr that all servers must be restarted after the test has
|
||||
# finished.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --source include/force_restart.inc
|
||||
#
|
||||
# ==== See also ====
|
||||
#
|
||||
# include/force_restart_if_skipped.inc
|
||||
|
||||
--let $_force_restart_datadir= `SELECT @@datadir`
|
||||
--append_file $_force_restart_datadir/mtr/force_restart
|
||||
1
|
||||
EOF
|
17
mysql-test/include/force_restart_if_skipped.inc
Normal file
17
mysql-test/include/force_restart_if_skipped.inc
Normal file
|
@ -0,0 +1,17 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Tell mtr that all servers must be restarted in case the test is
|
||||
# skipped.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --source include/force_restart_if_skipped.inc
|
||||
#
|
||||
# ==== See also ====
|
||||
#
|
||||
# include/force_restart.inc
|
||||
|
||||
--let $_force_restart_datadir= `SELECT @@datadir`
|
||||
--append_file $_force_restart_datadir/mtr/force_restart_if_skipped
|
||||
1
|
||||
EOF
|
|
@ -1,4 +1,4 @@
|
|||
disable_query_log;
|
||||
--require r/true.require
|
||||
select (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') as `TRUE` from information_schema.engines where engine = 'innodb';
|
||||
enable_query_log;
|
||||
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
|
||||
{
|
||||
--skip Test requires InnoDB.
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ SET @old_debug=@@global.debug;
|
|||
-- eval SET GLOBAL debug="+d,$io_thd_injection_fault_flag"
|
||||
|
||||
START SLAVE io_thread;
|
||||
-- source include/wait_for_slave_io_to_stop.inc
|
||||
-- source include/wait_for_slave_io_error.inc
|
||||
|
||||
-- eval SET GLOBAL debug="-d,$io_thd_injection_fault_flag"
|
||||
SET GLOBAL debug=@old_debug;
|
||||
|
||||
# restart because slave is in bad shape
|
||||
-- source include/restart_mysqld.inc
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_restart_server.inc
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
# connection <CONNECTION>;
|
||||
# let $connection_name=<CONNECTION>
|
||||
# let $connection_id=`SELECT CONNECTION_ID()`;
|
||||
# let $diff_statement=<SQL COMMAND>;
|
||||
# let $rpl_diff_statement=<SQL COMMAND>;
|
||||
# send <SQL COMMAND>;
|
||||
# source include/kill_query_and_diff_master_slave.inc;
|
||||
#
|
||||
# Note: <CONNECTION> must not be 'master'.
|
||||
#
|
||||
# See also kill_query.inc and diff_master_slave.inc for more
|
||||
# See also kill_query.inc and rpl_diff.inc for more
|
||||
# information
|
||||
|
||||
source include/kill_query.inc;
|
||||
|
||||
# Release the debug lock if used, so that the statements in
|
||||
# diff_master_slave.inc will not be blocked.
|
||||
# rpl_diff.inc will not be blocked.
|
||||
connection master;
|
||||
disable_query_log;
|
||||
disable_result_log;
|
||||
|
@ -32,7 +32,7 @@ if ($debug_lock)
|
|||
enable_result_log;
|
||||
enable_query_log;
|
||||
|
||||
source include/diff_master_slave.inc;
|
||||
--source include/rpl_diff.inc
|
||||
|
||||
# Acquire the debug lock again if used
|
||||
connection master;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
--connection master
|
||||
--sync_slave_with_master
|
||||
--connection slave
|
||||
--disable_query_log
|
||||
STOP SLAVE;
|
||||
--enable_query_log
|
|
@ -1,75 +0,0 @@
|
|||
# Reset the master and the slave to start fresh.
|
||||
#
|
||||
# It is necessary to execute RESET MASTER and RESET SLAVE on both
|
||||
# master and slave since the replication setup might be circular.
|
||||
#
|
||||
# Since we expect STOP SLAVE to produce a warning as the slave is
|
||||
# stopped (the server was started with skip-slave-start), we disable
|
||||
# warnings when doing STOP SLAVE.
|
||||
#
|
||||
# $no_change_master If true, no change master will be done nor any reset slave.
|
||||
# This is to avoid touching the relay-log.info file allowing
|
||||
# the test to create one itself.
|
||||
# $skip_slave_start If true, the slave will not be started
|
||||
|
||||
connection slave;
|
||||
|
||||
#we expect STOP SLAVE to produce a warning as the slave is stopped
|
||||
#(the server was started with skip-slave-start)
|
||||
--disable_warnings
|
||||
stop slave;
|
||||
--disable_query_log
|
||||
if (!$no_change_master) {
|
||||
eval CHANGE MASTER TO MASTER_USER='root',
|
||||
MASTER_CONNECT_RETRY=1,
|
||||
MASTER_HOST='127.0.0.1',
|
||||
MASTER_PORT=$MASTER_MYPORT;
|
||||
}
|
||||
--enable_query_log
|
||||
source include/wait_for_slave_to_stop.inc;
|
||||
--enable_warnings
|
||||
|
||||
connection master;
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
use test;
|
||||
--enable_query_log
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
reset master;
|
||||
|
||||
--disable_query_log
|
||||
if (!$no_change_master) {
|
||||
reset slave;
|
||||
}
|
||||
--enable_query_log
|
||||
connection slave;
|
||||
|
||||
--disable_warnings
|
||||
# the first RESET SLAVE may produce a warning about non-existent
|
||||
# 'ndb_apply_status' table, because this table is created
|
||||
# asynchronously at the server startup and may not exist yet
|
||||
# if RESET SLAVE comes too soon after the server startup
|
||||
if (!$no_change_master) {
|
||||
reset slave;
|
||||
}
|
||||
--enable_warnings
|
||||
|
||||
# Clean up old test tables
|
||||
--disable_warnings
|
||||
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
|
||||
--disable_query_log
|
||||
#eval CHANGE MASTER TO MASTER_USER='root',
|
||||
# MASTER_CONNECT_RETRY=1,
|
||||
# MASTER_HOST='127.0.0.1',
|
||||
# MASTER_PORT=$MASTER_MYPORT;
|
||||
reset master;
|
||||
--enable_query_log
|
||||
|
||||
if (!$skip_slave_start) {
|
||||
start slave;
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
}
|
||||
|
|
@ -1,19 +1,63 @@
|
|||
# Replication tests need binlog
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# $skip_slave_start If true, the slave will not be started
|
||||
source include/have_log_bin.inc;
|
||||
# Configure two servers to be replication master and slave.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_server_count= N]
|
||||
# [--let $rpl_check_server_ids= 1]
|
||||
# [--let $rpl_skip_reset_master_and_slave= 1]
|
||||
# [--let $rpl_skip_change_master= 1]
|
||||
# [--let $rpl_skip_start_slave= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/master-slave.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_check_server_ids, $rpl_skip_reset_master_and_slave,
|
||||
# $rpl_skip_change_master, $rpl_skip_start_slave, $rpl_debug,
|
||||
# $slave_timeout
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# $rpl_server_count
|
||||
# By default, two servers are configured. You can configure more
|
||||
# servers (servers 3, 4, etc are neither masters nor slaves) by
|
||||
# setting this variable. See also include/rpl_init.inc
|
||||
|
||||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
|
||||
if (!$skip_slave_start) {
|
||||
connection master;
|
||||
sync_slave_with_master;
|
||||
--let $include_filename= master-slave.inc
|
||||
if ($rpl_server_count)
|
||||
{
|
||||
--let $include_filename= master-slave.inc [rpl_server_count=$rpl_server_count]
|
||||
}
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
# Set the default connection to 'master'
|
||||
connection master;
|
||||
|
||||
--let $rpl_topology= 1->2
|
||||
--source include/rpl_init.inc
|
||||
|
||||
--let $rpl_connection_name= master
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--let $rpl_connection_name= master1
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--let $rpl_connection_name= slave
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--let $rpl_connection_name= slave1
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
|
||||
--let $include_filename= master-slave.inc
|
||||
--source include/end_include_file.inc
|
||||
|
||||
|
||||
# Set the default connection to 'master'. Do this after
|
||||
# end_include_file.inc, so that it gets printed to the query log.
|
||||
--let $rpl_connection_name= master
|
||||
--source include/rpl_connection.inc
|
||||
|
|
|
@ -57,13 +57,3 @@ BEGIN
|
|||
mysql.user;
|
||||
|
||||
END||
|
||||
|
||||
--
|
||||
-- Procedure used by test case used to force all
|
||||
-- servers to restart after testcase and thus skipping
|
||||
-- check test case after test
|
||||
--
|
||||
CREATE DEFINER=root@localhost PROCEDURE force_restart()
|
||||
BEGIN
|
||||
SELECT 1 INTO OUTFILE 'force_restart';
|
||||
END||
|
||||
|
|
|
@ -41,8 +41,7 @@ eval ALTER TABLE $table_name RENAME to $orig_table_name;
|
|||
--echo # Compare original and recreated tables
|
||||
--echo # Recreated table: $table_name
|
||||
--echo # Original table: $orig_table_name
|
||||
let $diff_table_1 = $table_name;
|
||||
let $diff_table_2 = $orig_table_name;
|
||||
let $diff_tables = $table_name, $orig_table_name;
|
||||
--source include/diff_tables.inc
|
||||
--echo # Cleanup
|
||||
--remove_file $mysqldumpfile
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
# Replication tests need binlog
|
||||
source include/have_log_bin.inc;
|
||||
|
||||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
--source include/master-slave.inc
|
||||
|
||||
connection slave;
|
||||
# Check that server is compiled and started with support for NDB
|
||||
|
@ -14,7 +8,5 @@ select (support = 'YES' or support = 'DEFAULT') as `TRUE` from information_schem
|
|||
--source include/ndb_not_readonly.inc
|
||||
enable_query_log;
|
||||
|
||||
-- source include/master-slave-reset.inc
|
||||
|
||||
# Set the default connection to 'master'
|
||||
connection master;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#############################################################
|
||||
# Author: Serge Kozlov <skozlov@mysql.com>
|
||||
# Date: 03/17/2008
|
||||
# Purpose: Set up circular cluster replication where each
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# Set up circular cluster replication where each
|
||||
# cluster has two mysqlds and replication directions are
|
||||
# following:
|
||||
# master ---> slave
|
||||
|
@ -9,128 +8,60 @@
|
|||
# cluster A cluster B
|
||||
# \ /
|
||||
# master1 <--- slave1
|
||||
#############################################################
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_server_count= N]
|
||||
# [--let $rpl_skip_check_server_ids= 1]
|
||||
# [--let $rpl_skip_reset_master_and_slave= 1]
|
||||
# [--let $rpl_skip_change_master= 1]
|
||||
# [--let $rpl_skip_start_slave= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/ndb_master-slave_2ch.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_server_count, $rpl_skip_check_server_ids,
|
||||
# $rpl_skip_reset_master_and_slave, $rpl_skip_change_master,
|
||||
# $rpl_skip_start_slave, $rpl_debug, $slave_timeout
|
||||
# See include/master-slave.inc
|
||||
|
||||
--source include/have_log_bin.inc
|
||||
--let $rpl_topology= 1->2,4->3
|
||||
--let $rpl_skip_check_server_ids= 1
|
||||
--source include/rpl_init.inc
|
||||
|
||||
# Make connections to mysqlds
|
||||
|
||||
connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,);
|
||||
connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT1,);
|
||||
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
|
||||
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT1,);
|
||||
--let $rpl_connection_name= master
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
# Check that all mysqld compiled with ndb support
|
||||
--let $rpl_connection_name= master1
|
||||
--let $rpl_server_number= 1
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--connection master
|
||||
--disable_query_log
|
||||
--require r/true.require
|
||||
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
|
||||
--source include/ndb_not_readonly.inc
|
||||
--enable_query_log
|
||||
--let $rpl_connection_name= slave
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--connection master1
|
||||
--disable_query_log
|
||||
--require r/true.require
|
||||
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
|
||||
--source include/ndb_not_readonly.inc
|
||||
--enable_query_log
|
||||
--let $rpl_connection_name= slave1
|
||||
--let $rpl_server_number= 2
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
--connection slave
|
||||
--disable_query_log
|
||||
--require r/true.require
|
||||
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
|
||||
--source include/ndb_not_readonly.inc
|
||||
--enable_query_log
|
||||
|
||||
--connection slave1
|
||||
--disable_query_log
|
||||
--require r/true.require
|
||||
SELECT (support = 'YES' or support = 'DEFAULT') AS `TRUE` FROM information_schema.engines WHERE engine = 'ndbcluster';
|
||||
--source include/ndb_not_readonly.inc
|
||||
--enable_query_log
|
||||
|
||||
# Stop slaves
|
||||
|
||||
--connection master
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--wait_for_slave_to_stop
|
||||
--enable_warnings
|
||||
|
||||
--connection master1
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--wait_for_slave_to_stop
|
||||
--enable_warnings
|
||||
|
||||
--connection slave
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--wait_for_slave_to_stop
|
||||
--enable_warnings
|
||||
|
||||
--connection slave1
|
||||
--disable_warnings
|
||||
STOP SLAVE;
|
||||
--wait_for_slave_to_stop
|
||||
--enable_warnings
|
||||
|
||||
# Reset masters
|
||||
|
||||
--connection master
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
USE test;
|
||||
--enable_query_log
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
RESET MASTER;
|
||||
|
||||
--connection master1
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
USE test;
|
||||
--enable_query_log
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
RESET MASTER;
|
||||
|
||||
--connection slave
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
USE test;
|
||||
--enable_query_log
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
RESET MASTER;
|
||||
|
||||
--connection slave1
|
||||
--disable_warnings
|
||||
--disable_query_log
|
||||
USE test;
|
||||
--enable_query_log
|
||||
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9;
|
||||
--enable_warnings
|
||||
RESET MASTER;
|
||||
|
||||
# Start slaves
|
||||
|
||||
--connection slave
|
||||
RESET SLAVE;
|
||||
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$MASTER_MYPORT,master_user='root'
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
|
||||
--connection master1
|
||||
RESET SLAVE;
|
||||
--replace_result $SLAVE_MYPORT1 SLAVE_MYPORT1
|
||||
--eval CHANGE MASTER TO master_host='127.0.0.1',master_port=$SLAVE_MYPORT1,master_user='root'
|
||||
START SLAVE;
|
||||
--source include/wait_for_slave_to_start.inc
|
||||
# Check that all mysqld are compiled with ndb support
|
||||
--let $_rpl_server= 4
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--connection server_$_rpl_server
|
||||
if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'ndbcluster' AND (support = 'YES' OR support = 'DEFAULT')`)
|
||||
{
|
||||
--skip Test requires NDB.
|
||||
}
|
||||
--source include/ndb_not_readonly.inc
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
|
||||
# Set the default connection to 'master' (cluster A)
|
||||
connection master;
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#
|
||||
# wait for server to connect properly to cluster
|
||||
#
|
||||
|
||||
--disable_query_log
|
||||
|
||||
set @saved_log = @@sql_log_bin;
|
||||
set sql_log_bin = 0;
|
||||
--error 0,ER_NO_SUCH_TABLE,ER_OPEN_AS_READONLY,ER_GET_ERRMSG,ER_KEY_NOT_FOUND
|
||||
|
@ -25,6 +28,9 @@ while ($mysql_errno)
|
|||
}
|
||||
delete from mysql.ndb_apply_status where server_id=0;
|
||||
set sql_log_bin = @saved_log;
|
||||
|
||||
--enable_query_log
|
||||
|
||||
#
|
||||
# connected
|
||||
#
|
||||
|
|
|
@ -9,4 +9,4 @@ show engines;
|
|||
show variables;
|
||||
--echo ===== STOP =====
|
||||
--enable_query_log
|
||||
exit;
|
||||
exit;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
--echo **** Resetting master and slave ****
|
||||
connection slave;
|
||||
source include/stop_slave.inc;
|
||||
RESET SLAVE;
|
||||
connection master;
|
||||
RESET MASTER;
|
||||
connection slave;
|
||||
source include/start_slave.inc;
|
|
@ -1,4 +1,12 @@
|
|||
|
||||
if ($rpl_inited)
|
||||
{
|
||||
if (!$allow_rpl_inited)
|
||||
{
|
||||
--die ERROR IN TEST: When using the replication test framework (master-slave.inc, rpl_init.inc etc), use rpl_restart_server.inc instead of restart_mysqld.inc. If you know what you are doing and you really have to use restart_mysqld.inc, set allow_rpl_inited=1 before you source restart_mysqld.inc
|
||||
}
|
||||
}
|
||||
|
||||
# Write file to make mysql-test-run.pl expect the "crash", but don't start
|
||||
# it until it's told to
|
||||
--let $_server_id= `SELECT @@server_id`
|
||||
|
|
250
mysql-test/include/rpl_change_topology.inc
Normal file
250
mysql-test/include/rpl_change_topology.inc
Normal file
|
@ -0,0 +1,250 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Changes replication topology. This file is normally sourced from
|
||||
# include/rpl_init.inc, but test cases can also source it if they
|
||||
# need to change topology after they have sourced include/rpl_init.inc
|
||||
#
|
||||
# This file sets up variables needed by include/rpl_sync.inc and many
|
||||
# other replication scripts in the include/ directory. It also issues
|
||||
# CHANGE MASTER on all servers where the configuration changes from
|
||||
# what it was before. It does not issue START SLAVE (use
|
||||
# include/rpl_start_slaves.inc for that).
|
||||
#
|
||||
# Note: it is not currently possible to change the number of servers
|
||||
# after the rpl_init.inc, without first calling rpl_end.inc. So the
|
||||
# test has to set $rpl_server_count to the total number of servers
|
||||
# that the test uses, before it sources include/rpl_init.inc. After
|
||||
# that, $rpl_server_count must not change until after next time the
|
||||
# test sources include/rpl_end.inc.
|
||||
#
|
||||
# Note: Since this script issues CHANGE MASTER, the test case must
|
||||
# ensure that all slaves where the configuration changes have stopped
|
||||
# both the IO thread and the SQL thread before this script is sourced.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_server_count= 7]
|
||||
# --let $rpl_topology= 1->2->3->1->4, 2->5, 6->7
|
||||
# [--let $rpl_skip_change_master= 1]
|
||||
# [--let $rpl_master_log_file= 1:master-bin.000001,3:master-bin.000003]
|
||||
# [--let $rpl_master_log_pos= 1:4711,3:107]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_change_topology.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_master_log_file
|
||||
# By default, CHANGE MASTER is executed with MASTER_LOG_FILE set
|
||||
# to the name of the last binlog file on the master (retrieved by
|
||||
# executing SHOW MASTER STATUS). This variable can be set to
|
||||
# specify another filename. This variable should be a
|
||||
# comma-separated list of the following form:
|
||||
#
|
||||
# SERVER_NUMBER_1:FILE_NAME_1,SERVER_NUMBER_2:FILE_NAME_2,...
|
||||
#
|
||||
# Before CHANGE MASTER is executed on server N, this script checks
|
||||
# if $rpl_master_log_file contains the text N:FILE_NAME. If it
|
||||
# does, then MASTER_LOG_FILE is set to FILE_NAME. Otherwise,
|
||||
# MASTER_LOG_FILE is set to the last binlog on the master. For
|
||||
# example, to specify that server_1 should start replicate from
|
||||
# master-bin.000007 and server_5 should start replicate from
|
||||
# master-bin.012345, do:
|
||||
# --let $rpl_master_log_file= 1:master-bin.000007,5:master-bin.012345
|
||||
#
|
||||
# $rpl_master_log_pos
|
||||
# By default, CHANGE MASTER is executed without specifying the
|
||||
# MASTER_LOG_POS parameter. This variable can be set to set a
|
||||
# specific position. It has the same form as $rpl_master_log_file
|
||||
# (see above). For example, to specify that server_3 should start
|
||||
# replicate from position 4711 of its master, do:
|
||||
# --let $rpl_master_log_pos= 3:4711
|
||||
#
|
||||
# $rpl_server_count, $rpl_topology, $rpl_debug, $rpl_skip_change_master
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
#
|
||||
# ==== Internal variables configured by this file ====
|
||||
#
|
||||
# This file sets up the following variables, which are used by other
|
||||
# low-level replication files such as:
|
||||
# include/rpl_sync.inc
|
||||
# include/rpl_start_slaves.inc
|
||||
# include/rpl_stop_slaves.inc
|
||||
# include/rpl_end.inc
|
||||
#
|
||||
# $rpl_server_count_length:
|
||||
# Set to LENGTH($rpl_server_count). So if $rpl_server_count < 10,
|
||||
# then $rpl_server_count_length = 1; if 10 <= $rpl_server_count <
|
||||
# 100, then $rpl_server_count_length = 2, etc.
|
||||
#
|
||||
# $rpl_master_list
|
||||
# Set to a string consisting of $rpl_server_count numbers, each one
|
||||
# whitespace-padded to $rpl_server_count_length characters. If
|
||||
# server N is a slave, then the N'th number is the master of server
|
||||
# N. If server N is not a slave, then the N'th number is just spaces
|
||||
# (so in fact it is not a number). For example, if $rpl_topology is
|
||||
# '1->2,2->3,3->1,2->4,5->6', then $rpl_master_list is '3122 6'.
|
||||
#
|
||||
# $rpl_sync_chain_dirty
|
||||
# This variable is set to 1. This tells include/rpl_sync.inc to
|
||||
# compute a new value for $rpl_sync_chain next time that
|
||||
# include/rpl_sync.inc is sourced. See
|
||||
# include/rpl_generate_sync_chain.inc and include/rpl_sync.inc for
|
||||
# details.
|
||||
|
||||
|
||||
# Remove whitespace from $rpl_topology
|
||||
--let $rpl_topology= `SELECT REPLACE('$rpl_topology', ' ', '')`
|
||||
|
||||
--let $include_filename= rpl_change_topology.inc [new topology=$rpl_topology]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Check input ----
|
||||
}
|
||||
|
||||
|
||||
if (`SELECT '$rpl_topology' = '' OR '$rpl_server_count' = ''`)
|
||||
{
|
||||
--die You must set $rpl_topology and $rpl_server_count before you source rpl_change_topology.inc. If you really want to change to the empty topology, set $rpl_topology= none
|
||||
}
|
||||
--let $_rpl_topology= $rpl_topology
|
||||
if (`SELECT '$_rpl_topology' = 'none'`)
|
||||
{
|
||||
--let $_rpl_topology=
|
||||
}
|
||||
if (`SELECT '!$rpl_master_list!' = '!!'`)
|
||||
{
|
||||
--die You must source include/rpl_init.inc before you source include/rpl_change_topology.inc
|
||||
}
|
||||
--let $_rpl_old_master_list= $rpl_master_list
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo \$rpl_server_count='$rpl_server_count'
|
||||
--echo \$rpl_server_count_length='$rpl_server_count_length'
|
||||
--echo new \$rpl_topology='$_rpl_topology'
|
||||
--echo old \$rpl_master_list='$rpl_master_list'
|
||||
--echo old \$rpl_sync_chain='$rpl_sync_chain'
|
||||
}
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Generate \$rpl_server_count_length and \$rpl_master_list ----
|
||||
}
|
||||
|
||||
--let $rpl_server_count_length= `SELECT LENGTH('$rpl_server_count')`
|
||||
--let $rpl_master_list=
|
||||
--let $_rpl_no_server= `SELECT REPEAT(' ', $rpl_server_count_length)`
|
||||
--let $rpl_master_list= `SELECT REPEAT('$_rpl_no_server', $rpl_server_count)`
|
||||
while ($_rpl_topology)
|
||||
{
|
||||
# Get 's1->s2' from 's1->s2->s3->...' or from 's1->s2,s3->s4,...'
|
||||
--let $_rpl_master_slave= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX('$_rpl_topology', ',', 1), '->', 2)`
|
||||
# Modify $_rpl_topology as follows:
|
||||
# - If it starts with 's1->s2,', remove 's1->s2,'
|
||||
# - If it starts with 's1->s2->', remove 's1->'
|
||||
# - If it is equal to 's1->s2', remove 's1->s2'
|
||||
--let $_rpl_topology= `SELECT SUBSTR('$_rpl_topology', IF(SUBSTR('$_rpl_topology', LENGTH('$_rpl_master_slave') + 1, 2) != '->', LENGTH('$_rpl_master_slave'), LOCATE('->', '$_rpl_master_slave')) + 2)`
|
||||
# Get 's1' from 's1->s2'
|
||||
--let $_rpl_master= `SELECT SUBSTRING_INDEX('$_rpl_master_slave', '->', 1)`
|
||||
# Get 's2' from 's1->s2'
|
||||
--let $_rpl_slave= `SELECT SUBSTRING('$_rpl_master_slave', LENGTH('$_rpl_master') + 3)`
|
||||
# Check that s2 does not have another master.
|
||||
if (`SELECT SUBSTR('$rpl_master_list', 1 + ($_rpl_slave - 1) * $rpl_server_count_length, $rpl_server_count_length) != '$_rpl_no_server'`)
|
||||
{
|
||||
--echo ERROR IN TEST: Server '$_rpl_slave' has more than one master in topology '$rpl_topology'
|
||||
--die ERROR IN TEST: found a server with more than one master in the $rpl_topology variable
|
||||
}
|
||||
# Save 's1' at position 's2' in $rpl_master_list
|
||||
--let $rpl_master_list= `SELECT INSERT('$rpl_master_list', 1 + ($_rpl_slave - 1) * $rpl_server_count_length, $rpl_server_count_length, RPAD('$_rpl_master', $rpl_server_count_length, ' '))`
|
||||
}
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo new \$rpl_server_count_length = '$rpl_server_count_length'
|
||||
--echo new \$rpl_master_list = '$rpl_master_list'
|
||||
}
|
||||
|
||||
if (!$rpl_skip_change_master)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Execute CHANGE MASTER on all servers ----
|
||||
}
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
while ($_rpl_server)
|
||||
{
|
||||
# The following statement evaluates to:
|
||||
# 0, if server_$_rpl_server has the same master as before.
|
||||
# The master's server, if server_$_rpl_server is a slave.
|
||||
# The empty string, if server_$_rpl_server is not a slave.
|
||||
--let $_rpl_master= `SELECT TRIM(IFNULL(NULLIF(SUBSTRING('$rpl_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length), SUBSTRING('$_rpl_old_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length)), 0))`
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo \$_rpl_server='$_rpl_server' \$_rpl_master='$_rpl_master'
|
||||
}
|
||||
if ($_rpl_master)
|
||||
{
|
||||
# Get port number
|
||||
--let $_rpl_port= \$SERVER_MYPORT_$_rpl_master
|
||||
# Get MASTER_LOG_FILE
|
||||
--let $_rpl_master_log_file_index= `SELECT LOCATE('$_rpl_server:', '$rpl_master_log_file')`
|
||||
if ($_rpl_master_log_file_index)
|
||||
{
|
||||
# Get text from after ':' and before ',', starting at
|
||||
# $_rpl_master_log_file
|
||||
--let $_rpl_master_log_file= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$rpl_master_log_file', $_rpl_master_log_file_index), ',', 1), ':', -1)`
|
||||
}
|
||||
if (!$_rpl_master_log_file_index)
|
||||
{
|
||||
--let $rpl_connection_name= server_$_rpl_master
|
||||
--source include/rpl_connection.inc
|
||||
--let $_rpl_master_log_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
||||
}
|
||||
# Change connection.
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connection.inc
|
||||
# Get MASTER_LOG_POS
|
||||
--let $_rpl_master_log_pos_index= `SELECT LOCATE('$_rpl_server:', '$rpl_master_log_pos')`
|
||||
if ($_rpl_master_log_pos_index)
|
||||
{
|
||||
--let $_rpl_master_log_pos= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$rpl_master_log_pos', $_rpl_master_log_pos_index), ',', 1), ':', -1)`
|
||||
--let $_rpl_master_log_pos= , MASTER_LOG_POS = $_rpl_master_log_pos
|
||||
}
|
||||
if (!$_rpl_master_log_pos_index)
|
||||
{
|
||||
--let $_rpl_master_log_pos=
|
||||
}
|
||||
eval CHANGE MASTER TO MASTER_HOST = '127.0.0.1', MASTER_PORT = $_rpl_port, MASTER_USER = 'root', MASTER_LOG_FILE = '$_rpl_master_log_file'$_rpl_master_log_pos, MASTER_CONNECT_RETRY = 1;
|
||||
}
|
||||
if (!$_rpl_master)
|
||||
{
|
||||
if (`SELECT '$_rpl_master' = ''`)
|
||||
{
|
||||
# This un-configures the server so that it's not a slave.
|
||||
# After BUG#28796, such configuration is not possible any more.
|
||||
#--let $rpl_connection_name= server_$_rpl_server
|
||||
#--source include/rpl_connection.inc
|
||||
#CHANGE MASTER TO MASTER_HOST = '';
|
||||
}
|
||||
}
|
||||
--dec $_rpl_server
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
--let $rpl_sync_chain_dirty= 1
|
||||
|
||||
|
||||
--let $include_filename= rpl_change_topology.inc
|
||||
--source include/end_include_file.inc
|
58
mysql-test/include/rpl_connect.inc
Normal file
58
mysql-test/include/rpl_connect.inc
Normal file
|
@ -0,0 +1,58 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Create a connection to a given numbered server.
|
||||
#
|
||||
# This script is normally used internally by rpl_init.inc and
|
||||
# master-slave.inc, but it can also be used in test cases that need to
|
||||
# create more connections or re-create connections after disconnect.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_connection_name= <connection_name>
|
||||
# --let $rpl_server_number= <server_number>
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_connect.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_connection_name
|
||||
# The name of the connection to create.
|
||||
#
|
||||
# $rpl_server_number
|
||||
# The number of the server to connect to.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_connect.inc [creating $rpl_connection_name]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_server_number)
|
||||
{
|
||||
--die ERROR IN TEST: You must set $rpl_server_number before sourcing include/rpl_connect.inc
|
||||
}
|
||||
if (`SELECT '$rpl_connection_name' = ''`)
|
||||
{
|
||||
--die ERROR IN TEST: You must set $rpl_connection_name before sourcing include/rpl_connect.inc
|
||||
}
|
||||
|
||||
# Get port number
|
||||
--let $_rpl_port= \$SERVER_MYPORT_$rpl_server_number
|
||||
if (!$_rpl_port)
|
||||
{
|
||||
--echo Bug in test case: '\$SERVER_MYPORT_$rpl_server_number' not initialized. Check the test's .cfg file.
|
||||
--die Not all SERVER_MYPORT_* environment variables are setup correctly.
|
||||
}
|
||||
|
||||
# Create connection.
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo connect ($rpl_connection_name,127.0.0.1,root,,test,$_rpl_port,)
|
||||
}
|
||||
--connect ($rpl_connection_name,127.0.0.1,root,,test,$_rpl_port,)
|
||||
|
||||
|
||||
--let $include_filename= rpl_connect.inc
|
||||
--source include/end_include_file.inc
|
47
mysql-test/include/rpl_connection.inc
Normal file
47
mysql-test/include/rpl_connection.inc
Normal file
|
@ -0,0 +1,47 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# The same as 'connection $rpl_connection_name', but it can also
|
||||
# prints the connection name. The connection is printed if $rpl_debug
|
||||
# is set, or if rpl_connection.inc is not called between two
|
||||
# invocations of begin_include_file.inc/end_include_file.inc.
|
||||
# Otherwise the connection name is not printed.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_connection_name= master
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_connection.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_connection_name
|
||||
# Name of the connection to connect to.
|
||||
#
|
||||
# $rpl_debug
|
||||
# By default, the connection name is printed only when this file
|
||||
# is sourced from a top-level test script. If $rpl_debug is set,
|
||||
# the connection name is also printed whenever auxiliary files
|
||||
# like rpl_init.inc change connection.
|
||||
|
||||
|
||||
if (!$rpl_connection_name)
|
||||
{
|
||||
--die ERROR IN TEST: you must set $rpl_connection_name before sourcing rpl_connection.inc
|
||||
}
|
||||
|
||||
# This is the same as "if (!$_rpl_include_file_depth || $rpl_debug)",
|
||||
# but the mysqltest language doesn't have boolean operations.
|
||||
|
||||
if (!$_include_file_depth)
|
||||
{
|
||||
--echo [connection $rpl_connection_name]
|
||||
}
|
||||
if ($_include_file_depth)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo [connection $rpl_connection_name]
|
||||
}
|
||||
}
|
||||
--connection $rpl_connection_name
|
||||
--let $rpl_connection_name=
|
118
mysql-test/include/rpl_diff.inc
Normal file
118
mysql-test/include/rpl_diff.inc
Normal file
|
@ -0,0 +1,118 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Diff the output of a statement on all configured servers (usually
|
||||
# master and slave).
|
||||
#
|
||||
#
|
||||
# ==== Usage =====
|
||||
#
|
||||
# --let $rpl_diff_statement= SELECT * FROM t1 WHERE a < 100
|
||||
# [--let $rpl_diff_servers= <server1>,<server2>,...<serverN>]
|
||||
# --source include/rpl_diff.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_diff_statement
|
||||
# Statement to check. For each compared server, this script will
|
||||
# start a new client and pass this statement to the client.
|
||||
# Note: This string will be evaluated as a single-quote-escaped
|
||||
# SQL string and hence must be quoted as such. In particular, any
|
||||
# single quotes in this string must be escaped.
|
||||
#
|
||||
# $rpl_diff_servers
|
||||
# By default, this file compares all servers configured by
|
||||
# rpl_init.inc. You can set $diff_servers to a comma-separated
|
||||
# list of numbers: only the servers identified by these numbers
|
||||
# will be compared.
|
||||
#
|
||||
# $rpl_diff_database
|
||||
# By default, the statement will be executed on the database
|
||||
# 'test'. If $rpl_diff_database is set, the statement will be
|
||||
# executed on the database named $rpl_diff_database instead.
|
||||
|
||||
|
||||
--let $include_filename= rpl_diff.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_diff_statement)
|
||||
{
|
||||
--die ERROR IN TEST: you must set $rpl_diff_statement before you source include/rpl_diff.inc
|
||||
}
|
||||
|
||||
|
||||
# Sync.
|
||||
--source include/rpl_sync.inc
|
||||
|
||||
|
||||
# Get database name.
|
||||
--let $_rpl_diff_database= $rpl_diff_database
|
||||
if (`SELECT '$_rpl_diff_database' = ''`)
|
||||
{
|
||||
--let $_rpl_diff_database= test
|
||||
}
|
||||
|
||||
|
||||
# Generate list of servers.
|
||||
--let $_rpl_diff_servers= $rpl_diff_servers
|
||||
if (!$_rpl_diff_servers)
|
||||
{
|
||||
--let $_rpl_server_i= $rpl_server_count
|
||||
--let $_rpl_diff_servers=
|
||||
while ($_rpl_server_i)
|
||||
{
|
||||
--let $_rpl_diff_servers= $_rpl_server_i,$_rpl_diff_servers
|
||||
--dec $_rpl_server_i
|
||||
}
|
||||
}
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo \$rpl_diff_servers= '$_rpl_diff_servers'
|
||||
}
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
|
||||
# Generate file containing $rpl_diff_statement. We don't pass the
|
||||
# statement on the command line, because it would be subject to shell
|
||||
# substitutions.
|
||||
--let $write_to_file= GENERATE
|
||||
--let $write_var= $rpl_diff_statement
|
||||
--source include/write_var_to_file.inc
|
||||
--let $_rpl_diff_statement_file= $write_to_file
|
||||
|
||||
|
||||
# Compare all servers.
|
||||
--let $_rpl_diff_first= 1
|
||||
while ($_rpl_diff_servers)
|
||||
{
|
||||
# Set $_rpl_diff_server_i to the first number in the list
|
||||
--let $_rpl_diff_server_i= `SELECT SUBSTRING_INDEX('$_rpl_diff_servers', ',', 1)`
|
||||
# Remove $_rpl_diff_server_i from the list
|
||||
--let $_rpl_diff_servers= `SELECT SUBSTRING('$_rpl_diff_servers', LENGTH('$_rpl_diff_server_i') + 2)`
|
||||
|
||||
# Execute statement
|
||||
--let $_rpl_diff_file= $MYSQLTEST_VARDIR/tmp/_rpl_diff_server-$_rpl_diff_server_i.tmp
|
||||
--exec $MYSQL --defaults-group-suffix=.$_rpl_diff_server_i $_rpl_diff_database < $_rpl_diff_statement_file > $_rpl_diff_file
|
||||
|
||||
# Compare
|
||||
if (!$_rpl_diff_first)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo diffing $_rpl_diff_file and $_rpl_diff_prev_file
|
||||
}
|
||||
--diff_files $_rpl_diff_file $_rpl_diff_prev_file
|
||||
--remove_file $_rpl_diff_prev_file
|
||||
}
|
||||
--let $_rpl_diff_prev_file= $_rpl_diff_file
|
||||
--let $_rpl_diff_first= 0
|
||||
}
|
||||
--remove_file $_rpl_diff_prev_file
|
||||
|
||||
|
||||
--let $include_filename= rpl_diff.inc
|
||||
--source include/end_include_file.inc
|
|
@ -1,35 +0,0 @@
|
|||
# #############################################################################
|
||||
# Check whether the given table is consistent between different master and
|
||||
# slaves
|
||||
#
|
||||
# Usage:
|
||||
# --let $diff_table= test.t1
|
||||
# --let $diff_server_list= master, slave, slave2
|
||||
# --source include/rpl_diff_tables.inc
|
||||
# #############################################################################
|
||||
|
||||
if (!$diff_table)
|
||||
{
|
||||
--die diff_table is null.
|
||||
}
|
||||
|
||||
--let $_servers= master, slave
|
||||
if ($diff_server_list)
|
||||
{
|
||||
--let $_servers= $diff_server_list
|
||||
}
|
||||
|
||||
--let $_master= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)`
|
||||
--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_master') + 2))`
|
||||
connection $_master;
|
||||
while ($_servers)
|
||||
{
|
||||
--let $_slave= `SELECT SUBSTRING_INDEX('$_servers', ',', 1)`
|
||||
--let $_servers= `SELECT LTRIM(SUBSTRING('$_servers', LENGTH('$_slave') + 2))`
|
||||
|
||||
--sync_slave_with_master $_slave
|
||||
--let $diff_table_1= $_master:$diff_table
|
||||
--let $diff_table_2= $_slave:$diff_table
|
||||
--source include/diff_tables.inc
|
||||
connection $_slave;
|
||||
}
|
103
mysql-test/include/rpl_end.inc
Normal file
103
mysql-test/include/rpl_end.inc
Normal file
|
@ -0,0 +1,103 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Shut down replication initialized by include/rpl_init.inc.
|
||||
#
|
||||
# This syncs all servers, executes STOP SLAVE on all servers, executes
|
||||
# CHANGE MASTER on all servers, and disconnects all connections
|
||||
# configured by rpl_init.inc.
|
||||
#
|
||||
# It does not execute RESET MASTER or RESET SLAVE, because that would
|
||||
# remove binlogs which are possibly useful debug information in case
|
||||
# the test case later fails with a result mismatch. If you need that,
|
||||
# source include/rpl_reset.inc before you source this file.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_only_running_threads= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_end.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_only_running_threads
|
||||
# If one or both of the IO and SQL threads is stopped, sync and
|
||||
# stop only the threads that are running. See
|
||||
# include/rpl_sync.inc and include/stop_slave.inc for details.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# Note:
|
||||
# This script will fail if Last_SQL_Error or Last_IO_Error is
|
||||
# nonempty. If you expect an error in the SQL thread, you should
|
||||
# normally call this script as follows:
|
||||
#
|
||||
# --source include/wait_for_slave_sql_error.inc
|
||||
# --source include/stop_slave_io.inc
|
||||
# RESET SLAVE;
|
||||
# --let $rpl_only_running_threads= 1
|
||||
# --source include/rpl_end.inc
|
||||
#
|
||||
#
|
||||
# ==== Side effects ====
|
||||
#
|
||||
# Changes the current connection to 'default'.
|
||||
|
||||
|
||||
--let $include_filename= rpl_end.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_inited)
|
||||
{
|
||||
--die ERROR IN TEST: rpl_end.inc was sourced when replication was not configured. Most likely, rpl_end.inc was sourced twice or rpl_init.inc has not been sourced.
|
||||
}
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Check that no slave thread has an error ----
|
||||
}
|
||||
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connection.inc
|
||||
|
||||
# Only check slave threads for error on hosts that were at some
|
||||
# point configured as slave.
|
||||
--let $_tmp= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
|
||||
if (`SELECT '$_tmp' != 'No such row'`)
|
||||
{
|
||||
--source include/check_slave_no_error.inc
|
||||
}
|
||||
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
--source include/rpl_sync.inc
|
||||
--source include/rpl_stop_slaves.inc
|
||||
|
||||
# mtr configures server 2 to be a slave before it runs the test. We
|
||||
# have to restore that state now, so we change topology to 1->2.
|
||||
--let $rpl_topology= none
|
||||
--source include/rpl_change_topology.inc
|
||||
|
||||
|
||||
--connection default
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
--let $_rpl_one= _1
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--disconnect server_$_rpl_server
|
||||
--disconnect server_$_rpl_server$_rpl_one
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
--let $rpl_inited= 0
|
||||
|
||||
# Do not restore connection, because we have disconnected it.
|
||||
--let $skip_restore_connection= 1
|
||||
--let $include_filename= rpl_end.inc
|
||||
--source include/end_include_file.inc
|
39
mysql-test/include/rpl_for_each_slave.inc
Normal file
39
mysql-test/include/rpl_for_each_slave.inc
Normal file
|
@ -0,0 +1,39 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Execute a .inc file once for each server that was configured as a
|
||||
# slave by rpl_init.inc
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_source_file
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_for_each_slave.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_source_file
|
||||
# The file that will be sourced.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_for_each_file.inc [$rpl_source_file]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--let $_rpl_has_master= `SELECT SUBSTRING('$rpl_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length) != ''`
|
||||
if ($_rpl_has_master)
|
||||
{
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connection.inc
|
||||
--source $rpl_source_file
|
||||
}
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
|
||||
--let $include_filename= rpl_for_each_file.inc [$rpl_source_file]
|
||||
--source include/end_include_file.inc
|
122
mysql-test/include/rpl_generate_sync_chain.inc
Normal file
122
mysql-test/include/rpl_generate_sync_chain.inc
Normal file
|
@ -0,0 +1,122 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Setup $rpl_sync_chain, which is used by rpl_sync.inc. You normally
|
||||
# don't need to source this file, it should only be sourced by
|
||||
# rpl_sync.inc.
|
||||
#
|
||||
# $rpl_sync_chain is set to a string that specifies in what order
|
||||
# servers should be synchronized in include/rpl_sync.inc. This has the
|
||||
# form of a sequence of "chains" (with no separator between two
|
||||
# chains). Each chain begins with $rpl_server_count_length space
|
||||
# characters, followed by a sequence of numbers, each number
|
||||
# whitespace-padded to $rpl_server_count_length characters. Each
|
||||
# number in the sequence denotes a server, and the N'th server is a
|
||||
# master of the (N+1)'th server. For example, if $rpl_topology is
|
||||
# '1->2,2->3,3->1,2->4,5->6', then $rpl_sync_chain is ' 56 123124'.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_generate_sync_chain.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_generate_sync_chain.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
# Algorithm:
|
||||
# 0. Mark all servers as unseen and unsynced.
|
||||
# 1. Let S be a server that is marked unseen.
|
||||
# 2. Append S to the list of seen servers.
|
||||
# 3. Check how S is marked:
|
||||
# 3.1. If S has no master: append the list of seen servers (in
|
||||
# order from grand-master to grand-slave) to the end of
|
||||
# $rpl_sync_chain. Go to 3.
|
||||
# 3.2. Elseif S is marked as synced: append the list of seen
|
||||
# servers (in order from grand-master to grand-slave) to the
|
||||
# end of $rpl_sync_chain. Go to 3.
|
||||
# 3.3. Elseif S is marked as unsynced but seen: This means that the
|
||||
# graph of visited servers has a "6-shape": it is a loop with
|
||||
# a tail, such as 1->2->3->1->4->5. We should first sync the
|
||||
# loop, and then the tail. To ensure all servers in the loop
|
||||
# are synced, we must sync the loop two turns minus two
|
||||
# servers. For example, the loop 1->2->3->4->5->1 is fully
|
||||
# synced by this sequence of 1-step synchronizations:
|
||||
# 1->2->3->4->5->1->2->3->4. Hence we do this: in the list of
|
||||
# traversed servers (in order from grand-master to
|
||||
# grand-slave), find the first occurrence of S. Take the
|
||||
# sub-list starting at the 3rd server and ending at the first
|
||||
# occurrence of S. Append this sub-list it to the end of
|
||||
# $rpl_sync_chain. Then append the entire list of traversed
|
||||
# servers (in order from grand-master to grand-slave) to
|
||||
# $rpl_sync_chain. Go to 3.
|
||||
# 3.4. Else (i.e., S has a master and is not marked as seen or
|
||||
# synced): Mark S as seen. Set S=master(S) and go back to 2.
|
||||
# 4. For each server that is marked as seen, mark it as synced.
|
||||
# 5. If there are unseen servers, go back to 1.
|
||||
|
||||
# $_rpl_server_marks holds the marks of all servers. The i'th character
|
||||
# corresponds to the mark of server i:
|
||||
# '0' = unseen & unmarked, '1' = seen & unsynced, '2' = seen & synced.
|
||||
--let $_rpl_server_marks= `SELECT REPEAT('0', $rpl_server_count)`
|
||||
--let $_rpl_start_server= $rpl_server_count
|
||||
--let $rpl_sync_chain=
|
||||
while ($_rpl_start_server)
|
||||
{
|
||||
--let $_rpl_server= `SELECT RPAD('$_rpl_start_server', $rpl_server_count_length, ' ')`
|
||||
--let $_rpl_seen_list=
|
||||
--let $_rpl_continue_loop= 1
|
||||
while ($_rpl_continue_loop)
|
||||
{
|
||||
--let $_rpl_master= `SELECT SUBSTRING('$rpl_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length)`
|
||||
# We need to delimit elements of $_rpl_seen_list with commas, so
|
||||
# that LOCATE() below will not find spurious matches that begin in
|
||||
# the middle of one element and end in the middle of next element.
|
||||
--let $_rpl_seen_list= $_rpl_server,$_rpl_seen_list
|
||||
# If server is marked seen or synced, or has no master
|
||||
if (`SELECT SUBSTRING('$_rpl_server_marks', $_rpl_server, 1) != 0 OR '$_rpl_master' = ''`)
|
||||
{
|
||||
# If server is marked seen but not synced.
|
||||
if (`SELECT SUBSTRING('$_rpl_server_marks', $_rpl_server, 1) = 1`)
|
||||
{
|
||||
# Get sub-list of servers to prepend to server list.
|
||||
# E.g., if topology is 1->2->3->4->1->5, then at this point
|
||||
# $_rpl_seen_list='1,2,3,4,1,5,' and we have to prepend '4,3,'
|
||||
# to it. Hence, the sub-list starts at position
|
||||
# 1+2*($rpl_server_count_length+1) and ends at the first
|
||||
# occurrence of ',1,' in the list.
|
||||
--let $_rpl_extra_list= `SELECT SUBSTRING('$_rpl_seen_list', 1 + 2 * ($rpl_server_count_length + 1), LOCATE(',$_rpl_server,', '$_rpl_seen_list') - 2 * ($rpl_server_count_length + 1))`
|
||||
--let $_rpl_seen_list= $_rpl_extra_list$_rpl_seen_list
|
||||
}
|
||||
# Append the seen servers. Only need to append if the list
|
||||
# contains at least two elements.
|
||||
if (`SELECT LENGTH('$_rpl_seen_list') > $rpl_server_count_length + 1`)
|
||||
{
|
||||
--let $rpl_sync_chain= $rpl_sync_chain$_rpl_no_server$_rpl_seen_list
|
||||
}
|
||||
--let $_rpl_continue_loop= 0
|
||||
}
|
||||
--let $_rpl_server_marks= `SELECT INSERT('$_rpl_server_marks', $_rpl_server, 1, '1')`
|
||||
--let $_rpl_server= $_rpl_master
|
||||
}
|
||||
# Mark seen servers as synced
|
||||
--let $_rpl_server_marks= `SELECT REPLACE('$_rpl_server_marks', '1', '2')`
|
||||
# Get highest-numbered unmarked server.
|
||||
--let $_rpl_start_server= `SELECT IFNULL(NULLIF($rpl_server_count + 1 - LOCATE('0', REVERSE('$_rpl_server_marks')), $rpl_server_count + 1), 0)`
|
||||
}
|
||||
# Strip commas: they were only needed temporarily.
|
||||
--let $rpl_sync_chain= `SELECT REPLACE('$rpl_sync_chain', ',', '')`
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo Generated \$rpl_sync_chain = '$rpl_sync_chain'
|
||||
}
|
||||
|
||||
|
||||
--let $include_filename= rpl_generate_sync_chain.inc
|
||||
--source include/end_include_file.inc
|
242
mysql-test/include/rpl_init.inc
Normal file
242
mysql-test/include/rpl_init.inc
Normal file
|
@ -0,0 +1,242 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Set up replication on several servers in a specified topology.
|
||||
#
|
||||
# By default, this script does the following:
|
||||
# - Creates the connections server_1, server_2, ..., server_N, as
|
||||
# well as extra connections server_1_1, server_2_1, ...,
|
||||
# server_N_1. server_I and server_I_1 are connections to the same
|
||||
# server.
|
||||
# - Sets up @@auto_increment_increment and @@auto_increment_increment.
|
||||
# - Verifies that @@server_id of all servers are different.
|
||||
# - Calls RESET MASTER, RESET SLAVE, USE test, CHANGE MASTER, START SLAVE.
|
||||
# - Sets the connection to server_1 before exiting.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# 1. If you are going to use more than two servers, create
|
||||
# rpl_test.cfg with the following contents:
|
||||
#
|
||||
# !include ../my.cnf
|
||||
# [mysqld.1]
|
||||
# log-slave-updates
|
||||
# [mysqld.2]
|
||||
# log-slave-updates
|
||||
# ...
|
||||
# [mysqld.N]
|
||||
# log-slave-updates
|
||||
#
|
||||
# [ENV]
|
||||
# SERVER_MYPORT_3= @mysqld.3.port
|
||||
# SERVER_MYPORT_4= @mysqld.4.port
|
||||
# SERVER_MYPORT_5= @mysqld.5.port
|
||||
# ...
|
||||
# SERVER_MYPORT_N= @mysqld.N.port
|
||||
#
|
||||
# (It is allowed, but not required, to configure SERVER_MYPORT_1
|
||||
# and SERVER_MYPORT_2 too. If these variables are not set, the
|
||||
# variables MASTER_MYPORT and SLAVE_MYPORT, configured in the
|
||||
# default my.cnf used by the rpl and rpl_ndb suites, are used
|
||||
# instead. In addition, in the rpl_ndb suite, SERVER_MYPORT_3 is
|
||||
# not needed since MASTER_MYPORT1 can be used instead.)
|
||||
#
|
||||
# 2. Execute the following near the top of the test:
|
||||
#
|
||||
# [--let $rpl_server_count= 7]
|
||||
# --let $rpl_topology= 1->2->3->1->4, 2->5, 6->7
|
||||
# [--let $rpl_check_server_ids= 1]
|
||||
# [--let $rpl_skip_change_master= 1]
|
||||
# [--let $rpl_skip_start_slave= 1]
|
||||
# [--let $rpl_skip_reset_master_and_slave= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/rpl_init.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# $rpl_server_count
|
||||
# The number of servers to configure. If this is not set, the largest
|
||||
# number in $rpl_topology will be used.
|
||||
#
|
||||
# $rpl_topology
|
||||
# A comma-separated list of replication chain
|
||||
# specifications. Each replication chain specification has the
|
||||
# form S1->S2->...->Sn, where 1 <= S1,...Sn <= $rpl_server_count.
|
||||
# This file will configure S(i+1) to be a slave of S(i). If you
|
||||
# want to specify the empty topology (no server replicates at
|
||||
# all), you have to set $rpl_topology=none.
|
||||
#
|
||||
# $rpl_check_server_ids
|
||||
# If $rpl_check_server_ids is set, this script checks that the
|
||||
# @@server_id of all servers are different. This is normally
|
||||
# guaranteed by mtr, so it is only useful for debugging.
|
||||
#
|
||||
# $rpl_skip_reset_master_and_slave
|
||||
# By default, this script issues RESET MASTER and RESET SLAVE
|
||||
# before CHANGE MASTER and START SLAVE. RESET MASTER and RESET
|
||||
# SLAVE are suppressed if $rpl_skip_reset_master_and_slave is
|
||||
# set.
|
||||
#
|
||||
# $rpl_skip_change_master
|
||||
# By default, this script issues CHANGE MASTER so that all slaves
|
||||
# are ready to run as specified by $rpl_topology. CHANGE MASTER
|
||||
# is suppressed if $rpl_skip_change_master is set.
|
||||
#
|
||||
# $rpl_skip_start_slave
|
||||
# By default, this script issues START SLAVE on all slaves
|
||||
# specified by $rpl_topology. START SLAVE is suppressed if
|
||||
# $rpl_skip_change_master is set.
|
||||
#
|
||||
# $rpl_debug
|
||||
# By default, this script only outputs a static text that says
|
||||
# that rpl_init.inc was invoked. If $rpl_debug is set, additional
|
||||
# debug info is printed. The debug info may be nondeterministic,
|
||||
# so no test case should be checked in with $rpl_debug set.
|
||||
#
|
||||
# $slave_timeout
|
||||
# Timeout used when waiting for the slave threads to start.
|
||||
# See include/wait_for_slave_param.inc
|
||||
#
|
||||
#
|
||||
# ==== Side effects ====
|
||||
#
|
||||
# Changes current connection to server_1.
|
||||
|
||||
--source include/have_log_bin.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_init.inc [topology=$rpl_topology]
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Check input ----
|
||||
--echo MASTER_MYPORT='$MASTER_MYPORT' SLAVE_MYPORT='$SLAVE_MYPORT' MASTER_MYPORT1='$MASTER_MYPORT1' SLAVE_MYPORT1='$SLAVE_MYPORT1'
|
||||
}
|
||||
|
||||
# Allow $MASTER_MYPORT as alias for $SERVER_MYPORT_1
|
||||
if (`SELECT '$SERVER_MYPORT_1' = ''`)
|
||||
{
|
||||
--let SERVER_MYPORT_1= $MASTER_MYPORT
|
||||
}
|
||||
# Allow $SLAVE_MYPORT as alias for $SERVER_MYPORT_2
|
||||
if (`SELECT '$SERVER_MYPORT_2' = ''`)
|
||||
{
|
||||
--let SERVER_MYPORT_2= $SLAVE_MYPORT
|
||||
}
|
||||
# Allow $MASTER_MYPORT1 as alias for $SERVER_MYPORT_3
|
||||
# (this alias is used by rpl_ndb tests)
|
||||
if (`SELECT '$SERVER_MYPORT_3' = ''`)
|
||||
{
|
||||
--let SERVER_MYPORT_3= $MASTER_MYPORT1
|
||||
}
|
||||
# Allow $SLAVE_MYPORT1 as alias for $SERVER_MYPORT_4
|
||||
# (this alias is used by rpl_ndb tests)
|
||||
if (`SELECT '$SERVER_MYPORT_4' = ''`)
|
||||
{
|
||||
--let SERVER_MYPORT_4= $SLAVE_MYPORT1
|
||||
}
|
||||
# Check that $rpl_server_count is set
|
||||
if (!$rpl_server_count)
|
||||
{
|
||||
--let $_compute_rpl_server_count= `SELECT REPLACE('$rpl_topology', '->', ',')`
|
||||
--let $rpl_server_count= `SELECT GREATEST($_compute_rpl_server_count)`
|
||||
}
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Setup connections and reset each server ----
|
||||
}
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
|
||||
# Create two connections to each server; reset master/slave, select
|
||||
# database, set autoinc variables.
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
--let $_rpl_one= _1
|
||||
while ($_rpl_server)
|
||||
{
|
||||
# Connect.
|
||||
--let $rpl_server_number= $_rpl_server
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connect.inc
|
||||
--let $rpl_connection_name= server_$_rpl_server$_rpl_one
|
||||
--source include/rpl_connect.inc
|
||||
|
||||
# Configure server.
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connection.inc
|
||||
USE test;
|
||||
if (!$rpl_skip_reset_master_and_slave)
|
||||
{
|
||||
RESET MASTER;
|
||||
RESET SLAVE;
|
||||
}
|
||||
eval SET auto_increment_increment= $rpl_server_count;
|
||||
eval SET auto_increment_offset= $_rpl_server;
|
||||
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
|
||||
# Signal that initialization is done and all connections created.
|
||||
--let $rpl_inited= 1
|
||||
|
||||
# Signal that the server is in a dirty state and needs to be restarted
|
||||
# if the test is skipped. If the test is not skipped, it will continue
|
||||
# to the end and execute its cleanup section (and check-testcase will
|
||||
# report if you forget to clean up).
|
||||
--source include/force_restart_if_skipped.inc
|
||||
|
||||
|
||||
# Assert that all hosts have different server_ids
|
||||
if ($rpl_check_server_ids)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Check that @@server_id is distinct for all servers ----
|
||||
}
|
||||
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--let $_rpl_server2= $_rpl_server
|
||||
--dec $_rpl_server2
|
||||
while ($_rpl_server2)
|
||||
{
|
||||
--let $assert_text= Servers $_rpl_server and $_rpl_server2 should have different @@server_id
|
||||
--let $assert_condition= [$_rpl_server:SELECT @@server_id AS i, i, 1] != [$_rpl_server2:SELECT @@server_id AS i, i, 1]
|
||||
|
||||
--source include/assert.inc
|
||||
--dec $_rpl_server2
|
||||
}
|
||||
--dec $_rpl_server
|
||||
}
|
||||
}
|
||||
|
||||
# $rpl_master_list must be set so that include/rpl_change_topology.inc
|
||||
# knows which servers are initialized and not.
|
||||
--let $rpl_master_list= `SELECT REPEAT('x', $rpl_server_count * LENGTH($rpl_server_count))`
|
||||
--source include/rpl_change_topology.inc
|
||||
|
||||
|
||||
if (!$rpl_skip_start_slave)
|
||||
{
|
||||
--source include/rpl_start_slaves.inc
|
||||
}
|
||||
|
||||
|
||||
--let $rpl_connection_name= server_1
|
||||
--source include/rpl_connection.inc
|
||||
|
||||
|
||||
--let $skip_restore_connection= 1
|
||||
--let $include_filename= rpl_init.inc
|
||||
--source include/end_include_file.inc
|
132
mysql-test/include/rpl_reconnect.inc
Normal file
132
mysql-test/include/rpl_reconnect.inc
Normal file
|
@ -0,0 +1,132 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# After a server has restarted, this waits for all clients configured
|
||||
# by rpl_init.inc and/or master-slave.inc to reconnect again.
|
||||
#
|
||||
# For each connection, it issues this:
|
||||
# --enable_reconnect
|
||||
# --source include/wait_until_connected_again.inc
|
||||
# --disable_reconnect
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_server_number= N
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_reconnect.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_server_number
|
||||
# Number to identify the server that needs to reconnect. 1 is the
|
||||
# master server, 2 the slave server, 3 the 3rd server, and so on.
|
||||
# Cf. include/rpl_init.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
--let $include_filename= rpl_reconnect.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
if (!$rpl_server_number)
|
||||
{
|
||||
--die ERROR IN TEST: you must set $rpl_server_number before you source rpl_connect.inc
|
||||
}
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Enable reconnect ----
|
||||
}
|
||||
|
||||
--let $_rpl_server_number= $rpl_server_number
|
||||
|
||||
--dec $_rpl_server_number
|
||||
if (!$_rpl_server_number)
|
||||
{
|
||||
--let $rpl_connection_name= default
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
|
||||
--let $rpl_connection_name= master
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
|
||||
--let $rpl_connection_name= master1
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
}
|
||||
|
||||
--dec $_rpl_server_number
|
||||
if (!$_rpl_server_number)
|
||||
{
|
||||
--let $rpl_connection_name= slave
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
|
||||
--let $rpl_connection_name= slave1
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
}
|
||||
|
||||
--let $rpl_connection_name= server_$rpl_server_number
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
|
||||
--let $_rpl_one= _1
|
||||
--let $rpl_connection_name= server_$rpl_server_number$_rpl_one
|
||||
--source include/rpl_connection.inc
|
||||
--enable_reconnect
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Wait for reconnect and disable reconnect on all connections ----
|
||||
}
|
||||
|
||||
--let $_rpl_server_number= $rpl_server_number
|
||||
|
||||
--dec $_rpl_server_number
|
||||
if (!$_rpl_server_number)
|
||||
{
|
||||
--let $rpl_connection_name= default
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
|
||||
--let $rpl_connection_name= master
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
|
||||
--let $rpl_connection_name= master1
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
}
|
||||
|
||||
--dec $_rpl_server_number
|
||||
if (!$_rpl_server_number)
|
||||
{
|
||||
--let $rpl_connection_name= slave
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
|
||||
--let $rpl_connection_name= slave1
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
}
|
||||
|
||||
--let $rpl_connection_name= server_$rpl_server_number
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
|
||||
--let $rpl_connection_name= server_$rpl_server_number$_rpl_one
|
||||
--source include/rpl_connection.inc
|
||||
--source include/wait_until_connected_again.inc
|
||||
--disable_reconnect
|
||||
|
||||
|
||||
--let $include_filename= rpl_reconnect.inc
|
||||
--source include/end_include_file.inc
|
81
mysql-test/include/rpl_reset.inc
Normal file
81
mysql-test/include/rpl_reset.inc
Normal file
|
@ -0,0 +1,81 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Reset all replication servers to a clean state:
|
||||
#
|
||||
# - sync all slaves,
|
||||
# - stop all slaves (STOP SLAVE),
|
||||
# - remove all binlogs and relay logs (RESET MASTER and RESET SLAVE),
|
||||
# - start all slaves again (START SLAVE).
|
||||
#
|
||||
# It does not execute CHANGE MASTER, so the replication topology is
|
||||
# kept intact.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_only_running_threads= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/rpl_end.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_only_running_threads
|
||||
# If one or both of the IO and SQL threads is stopped, sync and
|
||||
# stop only the threads that are running. See
|
||||
# include/rpl_sync.inc and include/stop_slave.inc for details.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# $slave_timeout
|
||||
# Set the timeout when waiting for slave threads to stop and
|
||||
# start, respectively. See include/wait_for_slave_param.inc
|
||||
#
|
||||
# Note:
|
||||
# This script will fail if Last_SQL_Error or Last_IO_Error is
|
||||
# nonempty. If you expect an error in the SQL thread, you should
|
||||
# normally do this before you source include/rpl_reset.inc:
|
||||
#
|
||||
# --source include/wait_for_slave_sql_error.inc
|
||||
# --source include/stop_slave_io.inc
|
||||
# RESET SLAVE;
|
||||
|
||||
--let $include_filename= rpl_reset.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
|
||||
--source include/rpl_sync.inc
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo ---- Stop and reset all servers ----
|
||||
}
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
while ($_rpl_server)
|
||||
{
|
||||
--let $rpl_connection_name= server_$_rpl_server
|
||||
--source include/rpl_connection.inc
|
||||
|
||||
# Check if this server is configured to have a master
|
||||
if (`SELECT SUBSTRING('$rpl_master_list', 1 + ($_rpl_server - 1) * $rpl_server_count_length, $rpl_server_count_length) != ''`)
|
||||
{
|
||||
--source include/stop_slave.inc
|
||||
RESET SLAVE;
|
||||
}
|
||||
RESET MASTER;
|
||||
--dec $_rpl_server
|
||||
}
|
||||
|
||||
|
||||
--source include/rpl_start_slaves.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_reset.inc
|
||||
--source include/end_include_file.inc
|
39
mysql-test/include/rpl_restart_server.inc
Normal file
39
mysql-test/include/rpl_restart_server.inc
Normal file
|
@ -0,0 +1,39 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Shut down and shut up the server given by $rpl_server_number. This
|
||||
# is equivalent to rpl_stop_server.inc followed by rpl_start_server.inc
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_server_number= N
|
||||
# [--let $rpl_server_parameters= --flag1 --flag2 ...]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_restart_server.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# $rpl_server_number, $rpl_server_parameters
|
||||
# See include/rpl_start_server.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# ==== See also ====
|
||||
#
|
||||
# rpl_start_server.inc
|
||||
# rpl_stop_server.inc
|
||||
|
||||
|
||||
--let $_rpl_restart_server_args= [server_number=$rpl_server_number]
|
||||
if ($rpl_server_parameters)
|
||||
{
|
||||
--let $_rpl_restart_server_args= [server_number=$rpl_server_number parameters: $rpl_server_parameters]
|
||||
}
|
||||
--let $include_filename= rpl_restart_server.inc $_rpl_restart_server_args
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
--source include/rpl_stop_server.inc
|
||||
--source include/rpl_start_server.inc
|
||||
|
||||
--let $include_filename= rpl_restart_server.inc $_rpl_restart_server_args
|
||||
--source include/end_include_file.inc
|
54
mysql-test/include/rpl_start_server.inc
Normal file
54
mysql-test/include/rpl_start_server.inc
Normal file
|
@ -0,0 +1,54 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Start the server given by $rpl_server_number. This should normally
|
||||
# be invoked after rpl_stop_server.inc.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_server_number= N
|
||||
# [--let $rpl_server_parameters= --flag1 --flag2 ...]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_start_server.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# $rpl_server_number
|
||||
# Number to identify the server that needs to reconnect. 1 is the
|
||||
# master server, 2 the slave server, 3 the 3rd server, and so on.
|
||||
# Cf. include/rpl_init.inc
|
||||
#
|
||||
# $rpl_server_parameters
|
||||
# If set, extra parameters given by this variable are passed to
|
||||
# mysqld.
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# ==== See also ====
|
||||
#
|
||||
# rpl_stop_server.inc
|
||||
# rpl_restart_server.inc
|
||||
|
||||
|
||||
--let $_rpl_start_server_command= restart
|
||||
--let $_rpl_start_server_args= [server_number=$rpl_server_number]
|
||||
if ($rpl_server_parameters)
|
||||
{
|
||||
--let $_rpl_start_server_command= restart:$rpl_server_parameters
|
||||
--let $_rpl_start_server_args= [server_number=$rpl_server_number parameters: $rpl_server_parameters]
|
||||
}
|
||||
|
||||
--let $include_filename= rpl_start_server.inc $_rpl_start_server_args
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
--let $rpl_connection_name= server_$rpl_server_number
|
||||
--source include/rpl_connection.inc
|
||||
|
||||
# Write file to make mysql-test-run.pl start up the server again
|
||||
--exec echo "$_rpl_start_server_command" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect
|
||||
|
||||
--source include/rpl_reconnect.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_start_server.inc $_rpl_start_server_args
|
||||
--source include/end_include_file.inc
|
32
mysql-test/include/rpl_start_slaves.inc
Normal file
32
mysql-test/include/rpl_start_slaves.inc
Normal file
|
@ -0,0 +1,32 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Start all slaves configured by rpl_init.inc and wait for the slave
|
||||
# threads to start.
|
||||
#
|
||||
# Note that rpl_init.inc calls this file automatically, so you only
|
||||
# need to source this file if the slaves have stopped after that.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/rpl_start_slaves.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# $slave_timeout
|
||||
# Set the timeout when waiting for slave threads to stop and
|
||||
# start, respectively. See include/wait_for_slave_param.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_start_slaves.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
--let $rpl_source_file= include/start_slave.inc
|
||||
--source include/rpl_for_each_slave.inc
|
||||
|
||||
--let $include_filename= rpl_start_slaves.inc
|
||||
--source include/end_include_file.inc
|
63
mysql-test/include/rpl_stop_server.inc
Normal file
63
mysql-test/include/rpl_stop_server.inc
Normal file
|
@ -0,0 +1,63 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Stop the server given by $rpl_server_number.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $rpl_server_number= N
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/rpl_stop_server.inc
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# $rpl_server_number
|
||||
# Number to identify the server that needs to reconnect. 1 is the
|
||||
# master server, 2 the slave server, 3 the 3rd server, and so on.
|
||||
# Cf. include/rpl_init.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
# ==== See also ====
|
||||
#
|
||||
# rpl_start_server.inc
|
||||
# rpl_restart_server.inc
|
||||
|
||||
|
||||
# Can't use begin_include_file / end_include_file because they require
|
||||
# executing on a server and the server will go down after this script.
|
||||
if (!$_include_file_depth)
|
||||
{
|
||||
--echo include/rpl_stop_server.inc [server_number=$rpl_server_number]
|
||||
}
|
||||
--inc $_include_file_depth
|
||||
--let $_rpl_stop_server_old_connection= $CURRENT_CONNECTION
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo $_include_file_indent con='$CURRENT_CONNECTION' warn='$ENABLED_WARNINGS' qlog='$ENABLED_QUERY_LOG' rlog='$ENABLED_RESULT_LOG' aborterr='$ENABLED_ABORT_ON_ERROR'
|
||||
--echo $_include_file_indent==== BEGIN include/$include_filename ====
|
||||
}
|
||||
|
||||
|
||||
--let $rpl_connection_name= server_$rpl_server_number
|
||||
--source include/rpl_connection.inc
|
||||
|
||||
# Write file to make mysql-test-run.pl expect the "crash", but don't start
|
||||
# it until it's told to
|
||||
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.$rpl_server_number.expect
|
||||
|
||||
# Send shutdown to the connected server and give
|
||||
# it 10 seconds to die before zapping it
|
||||
shutdown_server 10;
|
||||
|
||||
--source include/wait_until_disconnected.inc
|
||||
|
||||
|
||||
--let $rpl_connection_name= $_rpl_stop_server_old_connection
|
||||
--source include/rpl_connection.inc
|
||||
--dec $_include_file_depth
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo $_include_file_indent==== END include/rpl_stop_server.inc [server_number=$rpl_server_number] ====
|
||||
--echo $_include_file_indent con='$CURRENT_CONNECTION' warn='$ENABLED_WARNINGS' qlog='$ENABLED_QUERY_LOG' rlog='$ENABLED_RESULT_LOG' aborterr='$ENABLED_ABORT_ON_ERROR'
|
||||
}
|
33
mysql-test/include/rpl_stop_slaves.inc
Normal file
33
mysql-test/include/rpl_stop_slaves.inc
Normal file
|
@ -0,0 +1,33 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Stop all slaves configured by rpl_init.inc and waits for the slave
|
||||
# threads to stop.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_only_running_threads= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $rpl_timeout= NUMBER]
|
||||
# --source include/rpl_stop_slaves.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_only_running_threads
|
||||
# See include/stop_slave.inc
|
||||
#
|
||||
# $slave_timeout
|
||||
# Set the timeout when waiting for slave threads to stop. See
|
||||
# include/wait_for_slave_param.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= rpl_stop_slaves.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
--let $rpl_source_file= include/stop_slave.inc
|
||||
--source include/rpl_for_each_slave.inc
|
||||
|
||||
--let $include_filename= rpl_stop_slaves.inc
|
||||
--source include/end_include_file.inc
|
153
mysql-test/include/rpl_sync.inc
Normal file
153
mysql-test/include/rpl_sync.inc
Normal file
|
@ -0,0 +1,153 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Sync all servers in an arbitrary replication topology. This works
|
||||
# only if the servers have been configured with rpl_init.inc (and
|
||||
# possibly rpl_change_topology.inc).
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_only_running_threads= 1]
|
||||
# [--let $rpl_debug= 1]
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# --source include/rpl_sync.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_only_running_threads
|
||||
# By default, this script assumes that both the IO thread and the
|
||||
# SQL thread are running and fails if one of them is stopped. If
|
||||
# $rpl_only_running_threads is set, this script first checks
|
||||
# which slave threads are running:
|
||||
# - If both threads are running, sync both threads with master.
|
||||
# - If only IO thread is running, sync IO thread with master.
|
||||
# - If only SQL thread is running, sync SQL thread with IO thread.
|
||||
# - If no thread is running, don't sync.
|
||||
#
|
||||
# $slave_timeout
|
||||
# Set the timeout when waiting for threads to sync. See
|
||||
# include/wait_for_slave_param.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
#
|
||||
#
|
||||
# ==== Side effects ====
|
||||
#
|
||||
# Does not change the current connection (note that this is different
|
||||
# from mysqltest's built-in sync_slave_with_master command).
|
||||
|
||||
|
||||
--let $include_filename= rpl_sync.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
# Compute $rpl_sync_chain if needed. We could have done this in
|
||||
# rpl_change_topology.inc, but instead we do it here because that
|
||||
# means we only compute $rpl_sync_chain when it is needed.
|
||||
if ($rpl_sync_chain_dirty)
|
||||
{
|
||||
--source include/rpl_generate_sync_chain.inc
|
||||
--let $rpl_sync_chain_dirty= 0
|
||||
}
|
||||
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo \$rpl_sync_chain = '$rpl_sync_chain' \$rpl_only_running_threads= $rpl_only_running_threads
|
||||
}
|
||||
|
||||
if (!$rpl_server_count_length)
|
||||
{
|
||||
--die \$rpl_server_count_length is not set. Did you call rpl_init.inc?
|
||||
}
|
||||
|
||||
|
||||
--let $_rpl_i= 1
|
||||
--let $_rpl_connect= 0
|
||||
while ($_rpl_i) {
|
||||
# $rpl_sync_chain consists of a sequence of sync chains. Each sync
|
||||
# chain has the form:
|
||||
#
|
||||
# <space><server1_1><server1_2>...<server1_N>
|
||||
#
|
||||
# So the space character indicates that a new sync chain starts.
|
||||
--let $_rpl_server= `SELECT TRIM(SUBSTR('$rpl_sync_chain', 1 + ($_rpl_i - 1) * $rpl_server_count_length, $rpl_server_count_length))`
|
||||
|
||||
if ($_rpl_server)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo [sync server_$_rpl_prev_server -> server_$_rpl_server]
|
||||
}
|
||||
if ($rpl_only_running_threads)
|
||||
{
|
||||
--connection server_$_rpl_server
|
||||
--let $_rpl_slave_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1)
|
||||
--let $_rpl_slave_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1)
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo Sync IO: $_rpl_slave_io_running; Sync SQL: $_rpl_slave_sql_running
|
||||
}
|
||||
--let $_rpl_slave_io_running= `SELECT IF('$_rpl_slave_io_running' = 'Yes', 1, '')`
|
||||
--let $_rpl_slave_sql_running= `SELECT IF('$_rpl_slave_sql_running' = 'Yes', 1, '')`
|
||||
if ($_rpl_slave_io_running)
|
||||
{
|
||||
--connection server_$_rpl_prev_server
|
||||
if ($_rpl_slave_sql_running)
|
||||
{
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--let $_rpl_master_file= query_get_value("SHOW MASTER STATUS", File, 1)
|
||||
--let $_rpl_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1)
|
||||
--echo syncing master_file='$_rpl_master_file' master_pos='$_rpl_master_pos'
|
||||
}
|
||||
--sync_slave_with_master server_$_rpl_server
|
||||
}
|
||||
if (!$_rpl_slave_sql_running)
|
||||
{
|
||||
--let $sync_slave_connection= server_$_rpl_server
|
||||
--source include/sync_slave_io_with_master.inc
|
||||
}
|
||||
}
|
||||
if (!$_rpl_slave_io_running)
|
||||
{
|
||||
if ($_rpl_slave_sql_running)
|
||||
{
|
||||
--source include/sync_slave_sql_with_io.inc
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$rpl_only_running_threads)
|
||||
{
|
||||
--connection server_$_rpl_prev_server
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--let $_rpl_master_file= query_get_value("SHOW MASTER STATUS", File, 1)
|
||||
--let $_rpl_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1)
|
||||
--echo syncing master_file='$_rpl_master_file' master_pos='$_rpl_master_pos'
|
||||
}
|
||||
--sync_slave_with_master server_$_rpl_server
|
||||
}
|
||||
}
|
||||
|
||||
# This happens at the beginning of a new sync subchain and at the
|
||||
# end of the full sync chain.
|
||||
if (!$_rpl_server)
|
||||
{
|
||||
--inc $_rpl_i
|
||||
--let $_rpl_server= `SELECT TRIM(SUBSTR('$rpl_sync_chain', 1 + ($_rpl_i - 1) * $rpl_server_count_length, $rpl_server_count_length))`
|
||||
|
||||
if (!$_rpl_server)
|
||||
{
|
||||
# terminate loop
|
||||
--let $_rpl_i= -1
|
||||
}
|
||||
}
|
||||
|
||||
--let $_rpl_prev_server= $_rpl_server
|
||||
--inc $_rpl_i
|
||||
}
|
||||
|
||||
|
||||
--let $include_filename= rpl_sync.inc
|
||||
--source include/end_include_file.inc
|
33
mysql-test/include/save_master_pos.inc
Normal file
33
mysql-test/include/save_master_pos.inc
Normal file
|
@ -0,0 +1,33 @@
|
|||
# ==== Purpose ====
|
||||
#
|
||||
# Save the current binlog position on the master, just like the
|
||||
# built-in mysqltest command save_master_pos. The advantage of this
|
||||
# script is that the saved position is available to the test script.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/save_master_pos.inc
|
||||
#
|
||||
# Typically, you would use this script together with
|
||||
# include/sync_io_with_master.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= save_master_pos.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
let $_master_file= query_get_value("SHOW MASTER STATUS", File, 1);
|
||||
let $_master_pos= query_get_value("SHOW MASTER STATUS", Position, 1);
|
||||
|
||||
if ($rpl_debug)
|
||||
{
|
||||
--echo save_master_pos saved file='$_master_file', pos='$_master_pos'
|
||||
}
|
||||
|
||||
--let $include_filename= save_master_pos.inc
|
||||
--source include/end_include_file.inc
|
|
@ -29,11 +29,15 @@
|
|||
# Creates a binlog file and a binlog index file, and sets
|
||||
# @@global.relay_log_purge=1. All this is restored when you call
|
||||
# cleanup_fake_relay_log.inc.
|
||||
#
|
||||
# Enables the query log.
|
||||
|
||||
|
||||
--disable_query_log
|
||||
--let $include_filename= setup_fake_relay_log.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
# Print message.
|
||||
let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`;
|
||||
|
@ -53,35 +57,26 @@ if ($running) {
|
|||
--echo Error: Slave was running when test case sourced
|
||||
--echo include/setup_fake_replication.inc
|
||||
--echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running
|
||||
--echo Printing some debug info:
|
||||
SHOW SLAVE STATUS;
|
||||
SHOW MASTER STATUS;
|
||||
SHOW BINLOG EVENTS;
|
||||
SHOW PROCESSLIST;
|
||||
--source include/show_rpl_debug_info.inc
|
||||
--die
|
||||
}
|
||||
|
||||
# Read server variables.
|
||||
let $MYSQLD_DATADIR= `SELECT @@datadir`;
|
||||
let $_fake_datadir= `SELECT @@datadir`;
|
||||
let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1);
|
||||
if (!$_fake_filename) {
|
||||
--echo Badly written test case: relay_log variable is empty. Please use the
|
||||
--echo server option --relay-log=FILE.
|
||||
--die ERROR IN TEST: relay_log variable is empty. Please use the server option --relay-log=FILE.
|
||||
}
|
||||
let $_fake_relay_log= $MYSQLD_DATADIR/$_fake_filename-fake.000001;
|
||||
let $_fake_relay_index= $MYSQLD_DATADIR/$_fake_filename.index;
|
||||
let $_fake_relay_log= $_fake_datadir/$_fake_filename-fake.000001;
|
||||
let $_fake_relay_index= $_fake_datadir/$_fake_filename.index;
|
||||
# Need to restore relay_log_purge in cleanup_fake_relay_log.inc, since
|
||||
# CHANGE MASTER modifies it (see the manual for CHANGE MASTER).
|
||||
let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
|
||||
|
||||
# Reset slave and remove relay log and index files if they exist
|
||||
RESET SLAVE;
|
||||
error 0,1;
|
||||
remove_file $MYSQLD_DATADIR/$_fake_filename.000001;
|
||||
error 0,1;
|
||||
remove_file $MYSQLD_DATADIR/$_fake_filename.index;
|
||||
|
||||
# Create relay log file.
|
||||
copy_file $fake_relay_log $_fake_relay_log;
|
||||
--copy_file $fake_relay_log $_fake_relay_log
|
||||
|
||||
# Create relay log index.
|
||||
|
||||
|
@ -90,17 +85,23 @@ copy_file $fake_relay_log $_fake_relay_log;
|
|||
# relay log before comparison, thus we need to added the directory
|
||||
# part (./ on unix .\ on windows) when faking the relay-log-bin.index.
|
||||
|
||||
if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") = 0`)
|
||||
{
|
||||
eval select './$_fake_filename-fake.000001\n' into dumpfile '$_fake_relay_index';
|
||||
}
|
||||
# mysqltest currently parses backslash escapes wrong, so any sequence
|
||||
# of N backslashes is collapsed to just one backslash. So we use the
|
||||
# SQL function CHAR() to generate a backslash character instead. Since
|
||||
# the string is interpreted in SQL context, we to escape it, so we use
|
||||
# two backslashes.
|
||||
|
||||
if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") != 0`)
|
||||
{
|
||||
eval select '.\\\\$_fake_filename-fake.000001\n' into dumpfile '$_fake_relay_index';
|
||||
}
|
||||
--let $_fake_dir= `select IF(convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows"), CONCAT('.', CHAR(92), CHAR(92)), './')`
|
||||
--let $write_var= $_fake_dir$_fake_filename-fake.000001\n
|
||||
--let $write_to_file= $_fake_relay_index
|
||||
--source include/write_var_to_file.inc
|
||||
|
||||
# Remember old settings.
|
||||
--let $_fake_old_master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1)
|
||||
|
||||
# Setup replication from existing relay log.
|
||||
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
|
||||
|
||||
--enable_query_log
|
||||
|
||||
--let $include_filename= setup_fake_relay_log.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
|
@ -3,87 +3,109 @@
|
|||
# Print status information for replication, typically used to debug
|
||||
# test failures.
|
||||
#
|
||||
# First, the following is printed on slave:
|
||||
# The following is printed on the current connection:
|
||||
#
|
||||
# SELECT NOW()
|
||||
# SHOW SLAVE STATUS
|
||||
# SHOW MASTER STATUS
|
||||
# SHOW PROCESSLIST
|
||||
# SHOW BINLOG EVENTS IN <binlog_name>
|
||||
#
|
||||
# Where <binlog_name> is the currently active binlog.
|
||||
#
|
||||
# Then, the following is printed on master:
|
||||
# Then, the same is printed from all connections configured by
|
||||
# rpl_init.inc - i.e., on connection server_N, where
|
||||
# 1 <= N <= $rpl_server_count
|
||||
#
|
||||
# SHOW MASTER STATUS
|
||||
# SHOW PROCESSLIST
|
||||
# SHOW BINLOG EVENTS IN <sql_binlog_name>
|
||||
# SHOW BINLOG EVENTS IN <io_binlog_name>
|
||||
#
|
||||
# Where <sql_binlog_name> is the binlog name that the slave sql thread
|
||||
# is currently reading from and <io_binlog_name> is the binlog that
|
||||
# the slave IO thread is currently reading from.
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [let $master_connection= <connection>;]
|
||||
# source include/show_rpl_debug_info.inc;
|
||||
# [--let $rpl_only_current_connection= 1]
|
||||
# --source include/show_rpl_debug_info.inc
|
||||
#
|
||||
# If $master_connection is set, debug info will be retrieved from the
|
||||
# connection named $master_connection. Otherwise, it will be
|
||||
# retrieved from the 'master' connection if the current connection is
|
||||
# 'slave'.
|
||||
# Parameters:
|
||||
# $rpl_only_current_connection
|
||||
# By default, debug info is printed from all connections, starting
|
||||
# with the current connection. If this variable is set, debug
|
||||
# info is printed only for the current connection.
|
||||
#
|
||||
#
|
||||
# ==== Side effects ====
|
||||
#
|
||||
# Turns on enable_query_log, enable_result_log, enable_warnings,
|
||||
# horizontal_results, and enable_abort_on_error.
|
||||
#
|
||||
# Prints non-deterministic output to the query log. This file should
|
||||
# never be called in a test that does not fail.
|
||||
|
||||
let $_con= $CURRENT_CONNECTION;
|
||||
--echo
|
||||
--echo [on $_con]
|
||||
--echo
|
||||
SELECT NOW();
|
||||
--echo **** SHOW SLAVE STATUS on $_con ****
|
||||
query_vertical SHOW SLAVE STATUS;
|
||||
--echo
|
||||
--echo **** SHOW PROCESSLIST on $_con ****
|
||||
SHOW PROCESSLIST;
|
||||
--echo
|
||||
--echo **** SHOW BINLOG EVENTS on $_con ****
|
||||
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
|
||||
eval SHOW BINLOG EVENTS IN '$binlog_name';
|
||||
|
||||
let $_master_con= $master_connection;
|
||||
if (!$_master_con)
|
||||
--enable_query_log
|
||||
--enable_result_log
|
||||
--enable_warnings
|
||||
--disable_abort_on_error
|
||||
--horizontal_results
|
||||
|
||||
|
||||
--let $_rpl_old_con= $CURRENT_CONNECTION
|
||||
--let $_rpl_is_first_server= 1
|
||||
--let $_rpl_server= $rpl_server_count
|
||||
--inc $_rpl_server
|
||||
|
||||
|
||||
while ($_rpl_server)
|
||||
{
|
||||
if ($_con == slave)
|
||||
if (!$_rpl_is_first_server)
|
||||
{
|
||||
let $_master_con= master;
|
||||
--connection server_$_rpl_server
|
||||
}
|
||||
if (!$_master_con)
|
||||
{
|
||||
--echo Unable to determine master connection. No debug info printed for master.
|
||||
--echo Please fix the test case by setting $master_connection before sourcing
|
||||
--echo show_rpl_debug_info.inc.
|
||||
}
|
||||
}
|
||||
|
||||
if ($_master_con)
|
||||
{
|
||||
|
||||
let $master_binlog_name_io= query_get_value("SHOW SLAVE STATUS", Master_Log_File, 1);
|
||||
let $master_binlog_name_sql= query_get_value("SHOW SLAVE STATUS", Relay_Master_Log_File, 1);
|
||||
--echo
|
||||
--echo [on $_master_con]
|
||||
connection $_master_con;
|
||||
--echo ############################## $CURRENT_CONNECTION ##############################
|
||||
--echo
|
||||
SELECT NOW();
|
||||
--echo **** SHOW MASTER STATUS on $_master_con ****
|
||||
--echo **** SHOW WARNINGS on $CURRENT_CONNECTION ****
|
||||
SHOW WARNINGS;
|
||||
--echo
|
||||
--echo **** SELECT replication-related variables on $CURRENT_CONNECTION ****
|
||||
SELECT NOW(), @@SERVER_ID;
|
||||
--echo
|
||||
--echo **** SHOW SLAVE STATUS on $CURRENT_CONNECTION ****
|
||||
query_vertical SHOW SLAVE STATUS;
|
||||
--echo
|
||||
--echo **** SHOW MASTER STATUS on $CURRENT_CONNECTION ****
|
||||
query_vertical SHOW MASTER STATUS;
|
||||
--echo
|
||||
--echo **** SHOW PROCESSLIST on $_master_con ****
|
||||
--echo **** SHOW SLAVE HOSTS on $CURRENT_CONNECTION ****
|
||||
query_vertical SHOW SLAVE HOSTS;
|
||||
--echo
|
||||
--echo **** SHOW PROCESSLIST on $CURRENT_CONNECTION ****
|
||||
SHOW PROCESSLIST;
|
||||
--echo
|
||||
--echo **** SHOW BINLOG EVENTS on $_master_con ****
|
||||
eval SHOW BINLOG EVENTS IN '$master_binlog_name_sql';
|
||||
if ($master_binlog_name_io != $master_binlog_name_sql)
|
||||
{
|
||||
eval SHOW BINLOG EVENTS IN '$master_binlog_name_io';
|
||||
}
|
||||
--echo **** SHOW BINARY LOGS on $CURRENT_CONNECTION ****
|
||||
SHOW BINARY LOGS;
|
||||
--echo
|
||||
--echo **** SHOW BINLOG EVENTS on $CURRENT_CONNECTION ****
|
||||
let $binlog_name= query_get_value("SHOW MASTER STATUS", File, 1);
|
||||
--echo binlog_name = '$binlog_name'
|
||||
eval SHOW BINLOG EVENTS IN '$binlog_name';
|
||||
--echo
|
||||
--echo **** SHOW RELAYLOG EVENTS on $CURRENT_CONNECTION ****
|
||||
let $relaylog_name= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
|
||||
--echo relaylog_name = '$relaylog_name'
|
||||
eval SHOW RELAYLOG EVENTS IN '$relaylog_name';
|
||||
|
||||
connection $_con;
|
||||
|
||||
--let $_rpl_is_first_server= 0
|
||||
--dec $_rpl_server
|
||||
# Don't use same connection twice.
|
||||
if (`SELECT 'server_$_rpl_server' = '$_rpl_old_con'`)
|
||||
{
|
||||
--dec $_rpl_server
|
||||
if ($rpl_only_current_connection)
|
||||
{
|
||||
--let $_rpl_server= 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
--connection $_rpl_old_con
|
||||
--enable_abort_on_error
|
||||
|
|
|
@ -1,25 +1,75 @@
|
|||
# Include file to show the slave status, masking out some information
|
||||
# that varies depending on where the test is executed.
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# Show selected columns of output from SHOW SLAVE STATUS.
|
||||
#
|
||||
# Note: test cases should never call SHOW SLAVE STATUS directly,
|
||||
# because that outputs more information to the query log than what is
|
||||
# needed for the property that is being tested. That would cause
|
||||
# maintenance problems, because (1) it is hard for a human to
|
||||
# understand what property is being tested; (2) the output of many of
|
||||
# the fields is non-deterministic (e.g., Slave_IO_State) or changes
|
||||
# frequently (e.g., binlog positions).
|
||||
#
|
||||
# Instead, what you want most of the time is to source one of the
|
||||
# following scripts:
|
||||
#
|
||||
# include/check_slave_no_error.inc
|
||||
# Assert that Slave_SQL_Errno = Slave_IO_Errno = 0.
|
||||
#
|
||||
# include/check_slave_is_running.inc
|
||||
# Assert that Slave_IO_Running = Slave_SQL_Running = 'Yes'.
|
||||
#
|
||||
# include/wait_for_slave_sql_error.inc
|
||||
# Wait for the SQL thread to get a given error (and assert that
|
||||
# it has this error).
|
||||
#
|
||||
# include/wait_for_slave_io_error.inc
|
||||
# Wait for the IO thread to get a given error (and assert that
|
||||
# it has this error).
|
||||
#
|
||||
# include/wait_for_slave_sql_to_stop.inc
|
||||
# include/wait_for_slave_io_to_stop.inc
|
||||
# include/wait_for_slave_to_stop.inc
|
||||
# Wait for the SQL thread, the IO thread, or both to stop (and
|
||||
# assert they stop).
|
||||
#
|
||||
# When none of the above applies, you may use this script instead.
|
||||
# However, take care so that the test never contains explicit binlog
|
||||
# coordinates. Usually you can read the binlog coordinates into a
|
||||
# variable and compare it to some other coordinates.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# --let $status_items= Column_Name[, Column_Name[, ...]]
|
||||
# --source include/show_slave_status.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $status_items
|
||||
# Set to the name of the column in the output of SHOW SLAVE STATUS
|
||||
# that you want to display. Example:
|
||||
#
|
||||
# --let $status_items= Master_SSL_Allowed
|
||||
#
|
||||
# You can show multiple columns by setting $status_items to a
|
||||
# comma-separated list. Example:
|
||||
#
|
||||
# --let $status_items= Master_Log_File, Relay_Master_Log_File
|
||||
|
||||
--let $_items=$status_items
|
||||
|
||||
--let $_show_slave_status_items=$status_items
|
||||
if (`SELECT "XX$status_items" = "XX"`)
|
||||
{
|
||||
--die 'Variable status_items is NULL'
|
||||
--die Bug in test case: The mysqltest variable $status_items is not set.
|
||||
}
|
||||
|
||||
--disable_query_log
|
||||
--vertical_results
|
||||
|
||||
while (`SELECT "XX$_items" <> "XX"`)
|
||||
while (`SELECT "XX$_show_slave_status_items" <> "XX"`)
|
||||
{
|
||||
--let $_name= `SELECT SUBSTRING_INDEX('$_items', ',', 1)`
|
||||
--let $_items= `SELECT LTRIM(SUBSTRING('$_items', LENGTH('$_name') + 2))`
|
||||
--let $_show_slave_status_name= `SELECT SUBSTRING_INDEX('$_show_slave_status_items', ',', 1)`
|
||||
--let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
|
||||
|
||||
--let $_value= query_get_value(SHOW SLAVE STATUS, $_name, 1)
|
||||
|
||||
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
|
||||
--eval SELECT "$_value" AS $_name
|
||||
--let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
|
||||
--let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
|
||||
--echo $_show_slave_status_name = '$_show_slave_status_value'
|
||||
}
|
||||
|
||||
--horizontal_results
|
||||
--enable_query_log
|
||||
|
|
|
@ -6,16 +6,34 @@
|
|||
# Please use this instead of 'START SLAVE', to reduce the risk of test
|
||||
# case bugs.
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# source include/wait_for_slave_to_start.inc;
|
||||
# [--let $slave_timeout= NUMBER]
|
||||
# [--let $rpl_debug= 1]
|
||||
# --source include/start_slave.inc
|
||||
#
|
||||
# Parameters to this macro are $slave_timeout and
|
||||
# $master_connection. See wait_for_slave_param.inc for
|
||||
# descriptions.
|
||||
# Parameters:
|
||||
# $slave_timeout
|
||||
# See include/wait_for_slave_param.inc
|
||||
#
|
||||
# $rpl_debug
|
||||
# See include/rpl_init.inc
|
||||
|
||||
|
||||
--let $include_filename= start_slave.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
|
||||
--disable_query_log
|
||||
START SLAVE;
|
||||
--enable_query_log
|
||||
--echo include/start_slave.inc
|
||||
source include/wait_for_slave_to_start.inc;
|
||||
|
||||
|
||||
--let $include_filename= start_slave.inc
|
||||
--source include/end_include_file.inc
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue