revision-id: 960604a7d16225ae001148346c6e100ca9dae969 (mariadb-10.1.41-22-g960604a7d16) parent(s): 91fdb931fa2f734d54acadeb3e9c860a26543f04 author: Sujatha committer: Sujatha timestamp: 2019-08-21 16:30:24 +0530 message: MDEV-20188: binlog.binlog_stm_drop_tmp_tbl fails in buildbot with Unknown table on exec Analysis: ======== As part of BUG#28642318 fix, two new test cases were added. The first test case tests a scenario where two sessions are present, in which the first session has a regular table named 't1' and another session has a temporary table named 't1'. Test executes a DELETE statement on regular table. These statements are captured from binary log and replayed back on new client connection to prove that DELETE statement is applied successfully. Note that the binlog contains only CREATE TEMPORARY TABLE part hence a temporary table gets created in new connection. This replaying logic is implemented by using '--exec $MYSQL' command. If the new connection gets disconnected within the scope of first test case the test passes, i.e the temporary table gets dropped as part thread cleanup. But on slow platforms the connection gets closed at the time of execution of test case 2. When the temporary table is dropped as part thread cleanup a "DROP TEMPORARY TABLE t1" is written into the binary log. In test case two the same sessions continue to exist and and table names are reused to test a new bug scenario. The additional "DROP TEMPORARY TABLE" command drops second test specific tables which results in "Unknown table" error. Fix: ==== In first case capture the binlog content only after both tables are dropped from respective sessions. This doesn't affect the original test case. Modified the table names to 't2' in first test case, so that test failures can be easily interpreted. --- mysql-test/extra/binlog_tests/drop_temp_table.test | 21 +++++++++------------ .../suite/binlog/r/binlog_row_drop_tmp_tbl.result | 12 +++++------- .../suite/binlog/r/binlog_stm_drop_tmp_tbl.result | 12 +++++------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/mysql-test/extra/binlog_tests/drop_temp_table.test b/mysql-test/extra/binlog_tests/drop_temp_table.test index 9139ac76017..ac35bd5c566 100644 --- a/mysql-test/extra/binlog_tests/drop_temp_table.test +++ b/mysql-test/extra/binlog_tests/drop_temp_table.test @@ -122,29 +122,26 @@ connect (con1,localhost,root,,); SET @save_binlog_format= @@session.binlog_format; SET @@session.binlog_format=STATEMENT; let $MYSQLD_DATADIR= `select @@datadir`; -CREATE TABLE t1 (a INT) ENGINE=INNODB; +CREATE TABLE t2 (a INT) ENGINE=INNODB; --connection con1 SET @@session.binlog_format=STATEMENT; -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; --connection default -DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a; - ---exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql +DELETE d1, d2 FROM t2 AS d1, t2 AS d2 WHERE d1.a<>d2.a; --connection default -DROP TABLE t1; +DROP TABLE t2; + +--connection con1 +DROP TABLE t2; + +--exec $MYSQL_BINLOG --force-if-open $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/bug28642318.sql --echo # DELETE query fails with table re-open error without patch. --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug28642318.sql ---echo # Clean up. ---connection con1 -DROP TABLE IF EXISTS t1; - ---connection default -DROP TABLE IF EXISTS t1; RESET MASTER; --echo # Test case for DROP query. diff --git a/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result b/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result index 3d97817161e..bd1203d66d5 100644 --- a/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result +++ b/mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result @@ -60,15 +60,13 @@ RESET MASTER; # Set up. SET @save_binlog_format= @@session.binlog_format; SET @@session.binlog_format=STATEMENT; -CREATE TABLE t1 (a INT) ENGINE=INNODB; +CREATE TABLE t2 (a INT) ENGINE=INNODB; SET @@session.binlog_format=STATEMENT; -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; -DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a; -DROP TABLE t1; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; +DELETE d1, d2 FROM t2 AS d1, t2 AS d2 WHERE d1.a<>d2.a; +DROP TABLE t2; +DROP TABLE t2; # DELETE query fails with table re-open error without patch. -# Clean up. -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t1; RESET MASTER; # Test case for DROP query. CREATE TABLE t1 (a INT) ENGINE=INNODB; diff --git a/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result b/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result index b13ffea86db..b9b913ed451 100644 --- a/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result +++ b/mysql-test/suite/binlog/r/binlog_stm_drop_tmp_tbl.result @@ -88,15 +88,13 @@ RESET MASTER; # Set up. SET @save_binlog_format= @@session.binlog_format; SET @@session.binlog_format=STATEMENT; -CREATE TABLE t1 (a INT) ENGINE=INNODB; +CREATE TABLE t2 (a INT) ENGINE=INNODB; SET @@session.binlog_format=STATEMENT; -CREATE TEMPORARY TABLE t1 (b BLOB) ENGINE=INNODB; -DELETE d1, d2 FROM t1 AS d1, t1 AS d2 WHERE d1.a<>d2.a; -DROP TABLE t1; +CREATE TEMPORARY TABLE t2 (b BLOB) ENGINE=INNODB; +DELETE d1, d2 FROM t2 AS d1, t2 AS d2 WHERE d1.a<>d2.a; +DROP TABLE t2; +DROP TABLE t2; # DELETE query fails with table re-open error without patch. -# Clean up. -DROP TABLE IF EXISTS t1; -DROP TABLE IF EXISTS t1; RESET MASTER; # Test case for DROP query. CREATE TABLE t1 (a INT) ENGINE=INNODB;