diff --git a/mysql-test/r/assert_failed_in_crash_recovery_rollback.result b/mysql-test/r/assert_failed_in_crash_recovery_rollback.result new file mode 100644 index 00000000000..823718d7ebb --- /dev/null +++ b/mysql-test/r/assert_failed_in_crash_recovery_rollback.result @@ -0,0 +1,11 @@ +# +# ASSERTION `ut_ad(false)` FAILED IN CRASH RECOVERY ROLLBACK THREAD. +# +CREATE TABLE t1(n INT); +begin; +insert into t1 values(1); +SET debug = "+d,crash_after_flush_engine_log"; +CREATE TABLE t2(n int); +ERROR HY000: Lost connection to MySQL server during query +# restart: --debug=d,sleep_before_trx_recovery_rollback +DROP TABLE t1; diff --git a/mysql-test/t/assert_failed_in_crash_recovery_rollback.test b/mysql-test/t/assert_failed_in_crash_recovery_rollback.test new file mode 100644 index 00000000000..85d57deaca0 --- /dev/null +++ b/mysql-test/t/assert_failed_in_crash_recovery_rollback.test @@ -0,0 +1,23 @@ +--source include/have_debug.inc + +--echo # +--echo # ASSERTION `ut_ad(false)` FAILED IN CRASH RECOVERY ROLLBACK THREAD. +--echo # +CREATE TABLE t1(n INT); + +CONNECT (con_1, localhost, root,,); +begin; +insert into t1 values(1); + +connection default; + +--source include/expect_crash.inc +SET debug = "+d,crash_after_flush_engine_log"; +--error 2013 +CREATE TABLE t2(n int); + +# Restart the server. +--let $restart_parameters = restart: --debug=d,sleep_before_trx_recovery_rollback +--source include/start_mysqld.inc + +DROP TABLE t1; diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc index 9f6644c7369..e0627ac4350 100644 --- a/storage/innobase/trx/trx0roll.cc +++ b/storage/innobase/trx/trx0roll.cc @@ -784,6 +784,9 @@ void trx_recovery_rollback(THD *thd) { std::vector shared_mdl_list; ut_ad(!srv_read_only_mode); + DBUG_EXECUTE_IF("sleep_before_trx_recovery_rollback", + {std::this_thread::sleep_for(std::chrono::seconds(5));}); + // Take MDL locks /* During this stage the server is not open for external connections, and * there will not be any concurrent threads requesting MDL, hence we don't @@ -800,9 +803,7 @@ void trx_recovery_rollback(THD *thd) { /* Ignore transactions that has already finished. */ if (trx == nullptr) { - /* Currently these recovered transactions are not expected to finish - * earlier. Assert in Debug mode. */ - ut_ad(false); + /* This can happen when trx has been rollbacked by binlog recovery. */ continue; } auto table = dd_table_open_on_id(table_id, nullptr, nullptr, false, true);