diff --git a/mysql-test/r/bug8013.result b/mysql-test/r/bug8013.result new file mode 100644 index 0000000000000000000000000000000000000000..f25e6fc81571f79dfb94cf44c6e5c378ee2d9621 --- /dev/null +++ b/mysql-test/r/bug8013.result @@ -0,0 +1,16 @@ +CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +CREATE TABLE t2 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +CREATE TABLE t3 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +ALTER table t2 discard tablespace ; +FLUSH table t1 for export; +unlock tables; +DROP TABLE t1; +set debug='+d,insert_finish_prepare'; +INSERT INTO t3 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3'); +# kill mysqld and start mysqld +SET DEBUG_SYNC = 'now WAIT_FOR before_insert_finish_prepare'; +# restart +set debug='-d,insert_finish_prepare'; +ALTER TABLE t2 IMPORT TABLESPACE; +DROP TABLE t2; +DROP TABLE t3; diff --git a/mysql-test/t/bug8013.test b/mysql-test/t/bug8013.test new file mode 100644 index 0000000000000000000000000000000000000000..cabf908f5173142da7ffe816d017883f5d7be1b3 --- /dev/null +++ b/mysql-test/t/bug8013.test @@ -0,0 +1,34 @@ +--source include/have_debug_sync.inc + +let $MYSQLD_DATADIR = `SELECT @@datadir`; +CREATE TABLE t1 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +CREATE TABLE t2 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +CREATE TABLE t3 (c1 VARCHAR(32), c2 VARCHAR(32), c3 VARCHAR(32)); +ALTER table t2 discard tablespace ; +FLUSH table t1 for export; +--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg +--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd +unlock tables; +DROP TABLE t1; + +set debug='+d,insert_finish_prepare'; +send INSERT INTO t3 VALUES ('Test Data -1', 'Test Data -2', 'Test Data -3'); + + +--echo # kill mysqld and start mysqld +connect (con1,localhost,root,,); +SET DEBUG_SYNC = 'now WAIT_FOR before_insert_finish_prepare'; +--let $_server_id= `SELECT @@server_id` +--let $expect_file_name_s3= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect +--let $mysqld_pid_file=`SELECT @@GLOBAL.pid_file` +--source include/expect_crash.inc +exec kill -9 `cat $mysqld_pid_file`; +--source include/start_mysqld.inc + +set debug='-d,insert_finish_prepare'; + +# mysqld instance core +ALTER TABLE t2 IMPORT TABLESPACE; + +DROP TABLE t2; +DROP TABLE t3; diff --git a/storage/innobase/dict/dict0dd.cc b/storage/innobase/dict/dict0dd.cc index 1a932b7b74aac2c4fd52cf547b1dcdf248249bc9..a89a60a5c1d2712a2174169fca376e20bb65e3c3 100644 --- a/storage/innobase/dict/dict0dd.cc +++ b/storage/innobase/dict/dict0dd.cc @@ -7068,6 +7068,11 @@ bool dd_tablespace_update_cache(THD *thd) { break; } + dd_space_states state = dd_tablespace_get_state_enum(&p, id); + if (state == DD_SPACE_STATE_DISCARDED) { + continue; + } + const char *space_name = t->name().c_str(); fil_space_t *space = fil_space_get(id); diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 5655a5d92284f5cd2d3eae79d0102b87d799395b..81b5e6242d8732165eed86197b7c7fa59dca99b4 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -68,6 +68,7 @@ this program; if not, write to the Free Software Foundation, Inc., #include "ut0pool.h" #include "ut0vec.h" +#include "debug_sync.h" #include "my_dbug.h" #include "mysql/plugin.h" #include "sql/clone_handler.h" @@ -3068,6 +3069,12 @@ static void trx_prepare(trx_t *trx) { if (lsn > 0) { trx_flush_logs(trx, lsn); } + +#ifndef NDEBUG + DBUG_SIGNAL_WAIT_FOR(current_thd, "insert_finish_prepare", + "before_insert_finish_prepare", + "after_insert_finish_prepare"); +#endif } /** Sets the transaction as prepared in the transaction coordinator for