From e67ab663f0a6566a9d7bc319d7932d1ea2d3957f Mon Sep 17 00:00:00 2001
From: Serge Kozlov <skozlov@mysql.com>
Date: Fri, 12 Dec 2008 14:34:18 +0300
Subject: [PATCH] Bug#41108: It is a testcase timeout bug so the patch fixes
 test code in places where timeout can happen: 1. Added waiting start/stop
 slave to make sure that slave works properly. 2. Added cleanup for slave. 3.
 Updated related result files.

---
 mysql-test/extra/rpl_tests/rpl_flsh_tbls.test | 19 ++++++++++++-------
 .../suite/rpl/r/rpl_row_flsh_tbls.result      |  1 +
 .../suite/rpl/r/rpl_stm_flsh_tbls.result      |  1 +
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
index ee6b0ed1426..0baf49c9fac 100644
--- a/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
+++ b/mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
@@ -4,8 +4,7 @@
 # Test of FLUSH NO_WRITE_TO_BINLOG by the way.
 #
 
-
--- source include/master-slave.inc
+source include/master-slave.inc;
 
 let $SERVER_VERSION=`select version()`;
 
@@ -34,26 +33,32 @@ flush tables;
 --replace_column 2 # 5 #
 --replace_regex /table_id: [0-9]+/table_id: #/
 eval SHOW BINLOG EVENTS FROM $rename_event_pos ;
-save_master_pos;
-connection slave;
-sync_with_master;
+
+sync_slave_with_master;
 # Check that the slave is not confused.
 select * from t3;
 # Note that all this confusion may cause warnings 'table xx is open on rename'
 # in the .err files; these are not fatal and are not reported by mysql-test-run.
-
 stop slave;
+source include/wait_for_slave_to_stop.inc;
+
 connection master;
 drop table t1;
+
 connection slave;
 flush tables with read lock;
 start slave;
-sleep 1;
+source include/wait_for_slave_to_start.inc;
 --error 1192
 stop slave;
 
+# Cleanup
+unlock tables;
+
 connection master;
 drop table t3, t4, t5;
 
+sync_slave_with_master;
+
 # End of 4.1 tests
 
diff --git a/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result b/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result
index 09626754428..129bad0fbcc 100644
--- a/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result
+++ b/mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result
@@ -30,4 +30,5 @@ flush tables with read lock;
 start slave;
 stop slave;
 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+unlock tables;
 drop table t3, t4, t5;
diff --git a/mysql-test/suite/rpl/r/rpl_stm_flsh_tbls.result b/mysql-test/suite/rpl/r/rpl_stm_flsh_tbls.result
index 1c6b5615b6e..74031af1dde 100644
--- a/mysql-test/suite/rpl/r/rpl_stm_flsh_tbls.result
+++ b/mysql-test/suite/rpl/r/rpl_stm_flsh_tbls.result
@@ -30,4 +30,5 @@ flush tables with read lock;
 start slave;
 stop slave;
 ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+unlock tables;
 drop table t3, t4, t5;
-- 
2.30.9