From 9702d53ff8c340e9b9563e7f5298b336c2af7f3a Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Fri, 25 Jun 2010 09:07:18 +0200 Subject: [PATCH] Bug #53757 assert in mysql_truncate_by_delete The assert was triggered if a connection executing TRUNCATE on a InnoDB table was killed during open_tables. This bug was fixed in the scope of Bug #45643 "InnoDB does not support replication of TRUNCATE TABLE". This patch adds test coverage to innodb_mysql_sync.test. --- mysql-test/r/innodb_mysql_sync.result | 18 ++++++++++++++++++ mysql-test/t/innodb_mysql_sync.test | 26 ++++++++++++++++++++++++++ sql/sql_base.cc | 1 + 3 files changed, 45 insertions(+) diff --git a/mysql-test/r/innodb_mysql_sync.result b/mysql-test/r/innodb_mysql_sync.result index 0e75e62b13a..43a98829d4e 100644 --- a/mysql-test/r/innodb_mysql_sync.result +++ b/mysql-test/r/innodb_mysql_sync.result @@ -48,3 +48,21 @@ Warnings: Error 1146 Table 'test.t1' doesn't exist # Connection default SET DEBUG_SYNC= "RESET"; +# +# Bug#53757 assert in mysql_truncate_by_delete +# +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1(a INT) Engine=InnoDB; +CREATE TABLE t2(id INT); +INSERT INTO t1 VALUES (1), (2); +INSERT INTO t2 VALUES(connection_id()); +SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed"; +# Sending: (not reaped since connection is killed later) +TRUNCATE t1; +SET DEBUG_SYNC= "now WAIT_FOR opening"; +SELECT ((@id := id) - id) FROM t2; +((@id := id) - id) +0 +KILL @id; +SET DEBUG_SYNC= "now SIGNAL killed"; +DROP TABLE t1, t2; diff --git a/mysql-test/t/innodb_mysql_sync.test b/mysql-test/t/innodb_mysql_sync.test index ee92ee9f52e..07f75afec40 100644 --- a/mysql-test/t/innodb_mysql_sync.test +++ b/mysql-test/t/innodb_mysql_sync.test @@ -80,6 +80,32 @@ disconnect con1; SET DEBUG_SYNC= "RESET"; +--echo # +--echo # Bug#53757 assert in mysql_truncate_by_delete +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1(a INT) Engine=InnoDB; +CREATE TABLE t2(id INT); +INSERT INTO t1 VALUES (1), (2); + +connect (con1, localhost, root); +INSERT INTO t2 VALUES(connection_id()); +SET DEBUG_SYNC= "open_and_process_table SIGNAL opening WAIT_FOR killed"; +--echo # Sending: (not reaped since connection is killed later) +--send TRUNCATE t1 + +connection default; +SET DEBUG_SYNC= "now WAIT_FOR opening"; +SELECT ((@id := id) - id) FROM t2; +KILL @id; +SET DEBUG_SYNC= "now SIGNAL killed"; +DROP TABLE t1, t2; + + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc diff --git a/sql/sql_base.cc b/sql/sql_base.cc index bd73dd57367..0d4d949d701 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4429,6 +4429,7 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, bool error= FALSE; bool safe_to_ignore_table= FALSE; DBUG_ENTER("open_and_process_table"); + DEBUG_SYNC(thd, "open_and_process_table"); /* Ignore placeholders for derived tables. After derived tables