diff --git a/mysql-test/suite/innodb/r/purge_pessimistic.result b/mysql-test/suite/innodb/r/purge_pessimistic.result index a7ce4e13d6009..7ff69724554fa 100644 --- a/mysql-test/suite/innodb/r/purge_pessimistic.result +++ b/mysql-test/suite/innodb/r/purge_pessimistic.result @@ -34,3 +34,21 @@ col1 DROP TABLE t2; SET @@GLOBAL.debug_dbug = @old_debug_dbug; SET DEBUG_SYNC='RESET'; +# +# MDEV-39706 Assertion `!thd || !coordinator_thd' failed +# +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connect con1,localhost,root,,; +UPDATE t1 set f1= f1 + 1; +DELETE FROM t1; +connection default; +disconnect con1; +COMMIT; +SET @old_view_update= @@global.innodb_trx_purge_view_update_only_debug; +SET @@GLOBAL.innodb_trx_purge_view_update_only_debug=1; +SET STATEMENT max_statement_time=0.1 FOR SET GLOBAL innodb_max_purge_lag_wait=1; +SET @@GLOBAL.innodb_trx_purge_view_update_only_debug=@old_view_update; +InnoDB 0 transactions not purged +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/purge_pessimistic.test b/mysql-test/suite/innodb/t/purge_pessimistic.test index 88be65a6be5fa..83c5f2d4e6c65 100644 --- a/mysql-test/suite/innodb/t/purge_pessimistic.test +++ b/mysql-test/suite/innodb/t/purge_pessimistic.test @@ -49,3 +49,24 @@ DROP TABLE t2; SET @@GLOBAL.debug_dbug = @old_debug_dbug; SET DEBUG_SYNC='RESET'; + +--echo # +--echo # MDEV-39706 Assertion `!thd || !coordinator_thd' failed +--echo # +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +INSERT INTO t1 VALUES(1); +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connect(con1,localhost,root,,); +UPDATE t1 set f1= f1 + 1; +DELETE FROM t1; + +connection default; +disconnect con1; +COMMIT; +SET @old_view_update= @@global.innodb_trx_purge_view_update_only_debug; +SET @@GLOBAL.innodb_trx_purge_view_update_only_debug=1; +SET STATEMENT max_statement_time=0.1 FOR SET GLOBAL innodb_max_purge_lag_wait=1; +SET @@GLOBAL.innodb_trx_purge_view_update_only_debug=@old_view_update; +--source include/wait_all_purged.inc +DROP TABLE t1; diff --git a/storage/innobase/include/trx0purge.h b/storage/innobase/include/trx0purge.h index 25b76c0ecccaf..49c5ddfb276e1 100644 --- a/storage/innobase/include/trx0purge.h +++ b/storage/innobase/include/trx0purge.h @@ -506,6 +506,14 @@ class purge_sys_t /** Reset the state of a purge_worker_task at the end of a batch */ inline void reset_worker_thd(THD *thd) const noexcept; + +#ifdef UNIV_DEBUG + int reset_coordinator() noexcept + { + coordinator_thd= nullptr; + return 0; + } +#endif /* UNIV_DEBUG */ }; /** The global data structure coordinating a purge */ diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index 3614d792578ba..2d5745bc33a52 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -1472,7 +1472,10 @@ TRANSACTIONAL_TARGET ulint trx_purge(ulint n_tasks, ulint history_size) purge_sys.clone_oldest_view(thd); - ut_d(if (srv_purge_view_update_only_debug) return 0); +#ifdef UNIV_DEBUG + if (srv_purge_view_update_only_debug) + return purge_sys.reset_coordinator(); +#endif /* UNIV_DEBUG */ /* Fetch the UNDO recs that need to be purged. */ ulint n_work= 0;