mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
WL#4091, replace sleeps
mysql-test/suite/rpl/r/rpl_flushlog_loop.result: updated result mysql-test/suite/rpl/r/rpl_row_view01.result: updated result mysql-test/suite/rpl/t/rpl_change_master.test: replace sleep mysql-test/suite/rpl/t/rpl_drop_temp.test: replace sleep mysql-test/suite/rpl/t/rpl_flushlog_loop.test: replace sleep mysql-test/suite/rpl/t/rpl_relayspace.test: replace waiting of state to wait_for_slave_param.inc mysql-test/suite/rpl/t/rpl_row_view01.test: replace sleep mysql-test/suite/rpl/t/rpl_trunc_temp.test: replace sleep mysql-test/include/wait_for_binlog_event.inc: New primitive: waiting an event in binlog on master
This commit is contained in:
33
mysql-test/include/wait_for_binlog_event.inc
Normal file
33
mysql-test/include/wait_for_binlog_event.inc
Normal file
@ -0,0 +1,33 @@
|
||||
# include/wait_for_binlog_event.inc
|
||||
#
|
||||
# SUMMARY
|
||||
#
|
||||
# Waits until SHOW BINLOG EVENTS has returned in last event a specified substring.
|
||||
#
|
||||
# USAGE
|
||||
#
|
||||
# let $wait_binlog_event= DROP;
|
||||
# --source include/wait_for_binlog_event.inc
|
||||
|
||||
let $_loop_count= 300;
|
||||
let $_last_event= ;
|
||||
let $_event_pos= 1;
|
||||
|
||||
while (`SELECT INSTR("$_last_event","$wait_binlog_event") = 0`)
|
||||
{
|
||||
dec $_loop_count;
|
||||
if (!$_loop_count)
|
||||
{
|
||||
SHOW BINLOG EVENTS;
|
||||
--die ERROR: failed while waiting for $wait_binlog_event in binlog
|
||||
}
|
||||
real_sleep 0.1;
|
||||
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos);
|
||||
let $_last_event= $_event;
|
||||
while (`SELECT "$_event" != "No such row"`)
|
||||
{
|
||||
inc $_event_pos;
|
||||
let $_last_event= $_event;
|
||||
let $_event= query_get_value(SHOW BINLOG EVENTS, Info, $_event_pos);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ start slave;
|
||||
let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%0%0%None%' ;
|
||||
|
||||
--source include/wait_slave_status.inc
|
||||
flush logs;
|
||||
FLUSH LOGS;
|
||||
SHOW SLAVE STATUS;
|
||||
Slave_IO_State #
|
||||
Master_Host 127.0.0.1
|
||||
@ -31,7 +31,7 @@ Master_User root
|
||||
Master_Port SLAVE_PORT
|
||||
Connect_Retry 60
|
||||
Master_Log_File slave-bin.000001
|
||||
Read_Master_Log_Pos 216
|
||||
Read_Master_Log_Pos POSITION
|
||||
Relay_Log_File #
|
||||
Relay_Log_Pos #
|
||||
Relay_Master_Log_File slave-bin.000001
|
||||
@ -46,7 +46,7 @@ Replicate_Wild_Ignore_Table
|
||||
Last_Errno 0
|
||||
Last_Error
|
||||
Skip_Counter 0
|
||||
Exec_Master_Log_Pos 216
|
||||
Exec_Master_Log_Pos POSITION
|
||||
Relay_Log_Space #
|
||||
Until_Condition None
|
||||
Until_Log_File
|
||||
|
@ -13,6 +13,7 @@ DROP TABLE IF EXISTS mysqltest1.t3;
|
||||
DROP TABLE IF EXISTS mysqltest1.t1;
|
||||
DROP TABLE IF EXISTS mysqltest1.t2;
|
||||
DROP TABLE IF EXISTS mysqltest1.t4;
|
||||
DROP TABLE IF EXISTS mysqltest1.t10;
|
||||
CREATE TABLE mysqltest1.t1 (a INT, c CHAR(6),PRIMARY KEY(a));
|
||||
CREATE TABLE mysqltest1.t2 (a INT, c CHAR(6),PRIMARY KEY(a));
|
||||
CREATE TABLE mysqltest1.t3 (a INT, c CHAR(6), c2 CHAR(6), PRIMARY KEY(a));
|
||||
@ -35,6 +36,7 @@ a c c2
|
||||
1 Thank GOD
|
||||
2 it is
|
||||
3 Friday TGIF
|
||||
CREATE TABLE mysqltest1.t10 (a INT, PRIMARY KEY(a));
|
||||
SELECT * FROM mysqltest1.v2;
|
||||
qty price value
|
||||
3 50 150
|
||||
@ -98,4 +100,5 @@ DROP TABLE IF EXISTS mysqltest1.t3;
|
||||
DROP TABLE IF EXISTS mysqltest1.t1;
|
||||
DROP TABLE IF EXISTS mysqltest1.t2;
|
||||
DROP TABLE IF EXISTS mysqltest1.t4;
|
||||
DROP TABLE IF EXISTS mysqltest1.t10;
|
||||
DROP DATABASE mysqltest1;
|
||||
|
@ -15,8 +15,10 @@ connection master;
|
||||
insert into t1 values(1);
|
||||
insert into t1 values(2);
|
||||
save_master_pos;
|
||||
let $slave_param= Read_Master_Log_Pos;
|
||||
let $slave_param_value= query_get_value(SHOW MASTER STATUS, Position, 1);
|
||||
connection slave;
|
||||
--real_sleep 3 # wait for I/O thread to have read updates
|
||||
source include/wait_for_slave_param.inc;
|
||||
stop slave;
|
||||
source include/show_slave_status2.inc;
|
||||
change master to master_user='root';
|
||||
|
@ -6,19 +6,25 @@
|
||||
# to work around NDB's issue with temp tables
|
||||
##############################################
|
||||
source include/master-slave.inc;
|
||||
source include/have_binlog_format_mixed_or_statement.inc;
|
||||
|
||||
--disable_warnings
|
||||
create database if not exists mysqltest;
|
||||
--enable_warnings
|
||||
|
||||
create temporary table mysqltest.t1 (n int)ENGINE=MyISAM;
|
||||
create temporary table mysqltest.t2 (n int)ENGINE=MyISAM;
|
||||
sync_slave_with_master;
|
||||
|
||||
connection master;
|
||||
disconnect master;
|
||||
connection slave;
|
||||
--real_sleep 3 # time for DROP to be written
|
||||
show status like 'Slave_open_temp_tables';
|
||||
|
||||
connection master1;
|
||||
# Wait until drop of temp tables appears in binlog
|
||||
let $wait_binlog_event= DROP;
|
||||
source include/wait_for_binlog_event.inc;
|
||||
|
||||
connection slave;
|
||||
show status like 'Slave_open_temp_tables';
|
||||
# Cleanup
|
||||
connection default;
|
||||
drop database mysqltest;
|
||||
|
@ -35,12 +35,31 @@ let $result_pattern= '%127.0.0.1%root%slave-bin.000001%slave-bin.000001%Yes%Yes%
|
||||
#
|
||||
# Flush logs of slave
|
||||
#
|
||||
flush logs;
|
||||
sleep 5;
|
||||
# Create full loop by following way:
|
||||
# 1. Insert into t1 on master (1st).
|
||||
# 2. Insert into t1 on slave (2nd) when the event (1st) for t1 replicated.
|
||||
# 3. Master waits until the event (2nd) for t1 will be replicated.
|
||||
|
||||
--disable_query_log
|
||||
CREATE TABLE t1 (a INT KEY) ENGINE= MyISAM;
|
||||
INSERT INTO t1 VALUE(1);
|
||||
--enable_query_log
|
||||
FLUSH LOGS;
|
||||
connection slave;
|
||||
let $wait_condition= SELECT COUNT(*) = 1 FROM t1;
|
||||
-- source include/wait_condition.inc
|
||||
--disable_query_log
|
||||
INSERT INTO t1 VALUE(2);
|
||||
--enable_query_log
|
||||
connection master;
|
||||
let $wait_condition= SELECT COUNT(*) = 2 FROM t1;
|
||||
-- source include/wait_condition.inc
|
||||
--enable_query_log
|
||||
|
||||
#
|
||||
# Show status of slave
|
||||
#
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT
|
||||
let $pos= query_get_value(SHOW SLAVE STATUS, Read_Master_Log_Pos, 1);
|
||||
--replace_result $SLAVE_MYPORT SLAVE_PORT $pos POSITION
|
||||
--replace_column 1 # 8 # 9 # 16 # 23 # 33 # 34 # 35 #
|
||||
--query_vertical SHOW SLAVE STATUS
|
||||
|
@ -14,23 +14,10 @@ connection slave;
|
||||
reset slave;
|
||||
start slave io_thread;
|
||||
# Give the I/O thread time to block.
|
||||
let $run= 1;
|
||||
let $counter= 300;
|
||||
while ($run)
|
||||
{
|
||||
let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
|
||||
if (`SELECT '$io_state' = 'Waiting for the slave SQL thread to free enough relay log space'`){
|
||||
let $run= 0;
|
||||
}
|
||||
sleep 0.1;
|
||||
if (!$counter){
|
||||
--echo "Failed while waiting for slave IO thread block"
|
||||
SHOW SLAVE STATUS;
|
||||
exit;
|
||||
}
|
||||
dec $counter;
|
||||
}
|
||||
sleep 2;
|
||||
let $slave_param= Slave_IO_State;
|
||||
let $slave_param_value= Waiting for the slave SQL thread to free enough relay log space;
|
||||
source include/wait_for_slave_param.inc;
|
||||
|
||||
# A bug caused the I/O thread to refuse stopping.
|
||||
stop slave io_thread;
|
||||
reset slave;
|
||||
|
@ -23,6 +23,7 @@ DROP TABLE IF EXISTS mysqltest1.t3;
|
||||
DROP TABLE IF EXISTS mysqltest1.t1;
|
||||
DROP TABLE IF EXISTS mysqltest1.t2;
|
||||
DROP TABLE IF EXISTS mysqltest1.t4;
|
||||
DROP TABLE IF EXISTS mysqltest1.t10;
|
||||
|
||||
# Begin test section 1
|
||||
CREATE TABLE mysqltest1.t1 (a INT, c CHAR(6),PRIMARY KEY(a));
|
||||
@ -43,12 +44,18 @@ CREATE VIEW mysqltest1.v4 AS SELECT * FROM mysqltest1.v3 WHERE a > 1 WITH LOCAL
|
||||
|
||||
SELECT * FROM mysqltest1.v2;
|
||||
SELECT * FROM mysqltest1.v1;
|
||||
# Had to add a sleep for use with NDB
|
||||
|
||||
|
||||
# Had to add a waiting for use with NDB
|
||||
# engine. Injector thread would have not
|
||||
# populated biblog and data would not be on
|
||||
# populated binlog and data would not be on
|
||||
# the slave.
|
||||
sleep 10;
|
||||
sync_slave_with_master;
|
||||
|
||||
CREATE TABLE mysqltest1.t10 (a INT, PRIMARY KEY(a));
|
||||
let $wait_binlog_event= CREATE TABLE mysqltest1.t10;
|
||||
-- source include/wait_for_binlog_event.inc
|
||||
--sync_slave_with_master
|
||||
|
||||
SELECT * FROM mysqltest1.v2;
|
||||
SELECT * FROM mysqltest1.v1;
|
||||
connection master;
|
||||
@ -82,6 +89,7 @@ DROP TABLE IF EXISTS mysqltest1.t3;
|
||||
DROP TABLE IF EXISTS mysqltest1.t1;
|
||||
DROP TABLE IF EXISTS mysqltest1.t2;
|
||||
DROP TABLE IF EXISTS mysqltest1.t4;
|
||||
DROP TABLE IF EXISTS mysqltest1.t10;
|
||||
DROP DATABASE mysqltest1;
|
||||
sync_slave_with_master;
|
||||
|
||||
|
@ -27,7 +27,12 @@ show status like 'Slave_open_temp_tables';
|
||||
|
||||
# Disconnect the master, temp table on slave should dissapear
|
||||
disconnect master;
|
||||
--real_sleep 3 # time for DROP to be read by slave
|
||||
|
||||
connection master1;
|
||||
# Wait until drop of temp tables appers in binlog
|
||||
let $wait_binlog_event= DROP;
|
||||
source include/wait_for_binlog_event.inc;
|
||||
|
||||
connection slave;
|
||||
show status like 'Slave_open_temp_tables';
|
||||
|
||||
|
Reference in New Issue
Block a user