From 1c0bea0d718e008dac0447a70d6feb7c135b048f Mon Sep 17 00:00:00 2001 From: yeweixu Date: Tue, 1 Mar 2022 10:54:25 +0800 Subject: [PATCH] repeat purge suspend forever --- .../r/bugfix_purge_suspend_forever.result | 21 ++++++++ .../t/bugfix_purge_suspend_forever-master.opt | 1 + .../t/bugfix_purge_suspend_forever.test | 51 +++++++++++++++++++ storage/innobase/read/read0read.cc | 1 + 4 files changed, 74 insertions(+) create mode 100644 mysql-test/r/bugfix_purge_suspend_forever.result create mode 100644 mysql-test/t/bugfix_purge_suspend_forever-master.opt create mode 100644 mysql-test/t/bugfix_purge_suspend_forever.test diff --git a/mysql-test/r/bugfix_purge_suspend_forever.result b/mysql-test/r/bugfix_purge_suspend_forever.result new file mode 100644 index 00000000000..cad9e06ade3 --- /dev/null +++ b/mysql-test/r/bugfix_purge_suspend_forever.result @@ -0,0 +1,21 @@ +CREATE DATABASE test1; +USE test1; +CREATE TABLE test1.t (id int primary key auto_increment); +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); +SET DEBUG_SYNC='MVCC_view_close WAIT_FOR wakeup_signal'; +select count(*) from test1.t; +delete from test1.t where id=1; +delete from test1.t where id=2; +delete from test1.t where id=3; +delete from test1.t where id=4; +delete from test1.t where id=5; +include/assert.inc [Assert that the history_len > 0] +SET DEBUG_SYNC='now SIGNAL wakeup_signal'; +include/assert.inc [Assert that the history_len = 0] +count(*) +5 +DROP database test1; diff --git a/mysql-test/t/bugfix_purge_suspend_forever-master.opt b/mysql-test/t/bugfix_purge_suspend_forever-master.opt new file mode 100644 index 00000000000..83dc636b45e --- /dev/null +++ b/mysql-test/t/bugfix_purge_suspend_forever-master.opt @@ -0,0 +1 @@ +--innodb_purge_rseg_truncate_frequency=1 diff --git a/mysql-test/t/bugfix_purge_suspend_forever.test b/mysql-test/t/bugfix_purge_suspend_forever.test new file mode 100644 index 00000000000..dc7957ede2c --- /dev/null +++ b/mysql-test/t/bugfix_purge_suspend_forever.test @@ -0,0 +1,51 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +connection default; + +# 1. init data + +CREATE DATABASE test1; +USE test1; + +CREATE TABLE test1.t (id int primary key auto_increment); + +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); +insert into test1.t values (); + +# 2. send select block purge +SET DEBUG_SYNC='MVCC_view_close WAIT_FOR wakeup_signal'; +send select count(*) from test1.t; + +# 3. delete data, purge blocked because of active readview +connect(con1,localhost,root,,); +delete from test1.t where id=1; +delete from test1.t where id=2; +delete from test1.t where id=3; +delete from test1.t where id=4; +delete from test1.t where id=5; + +sleep 5; + +--let $history_len= `select count from information_schema.innodb_metrics where name="trx_rseg_history_len"` +--let $assert_text= Assert that the history_len > 0 +--let $assert_cond= `SELECT '$history_len'>0` +--source include/assert.inc + +# 4. end select, purge will suspend forever +SET DEBUG_SYNC='now SIGNAL wakeup_signal'; +sleep 5; + +--let $history_len= `select count from information_schema.innodb_metrics where name="trx_rseg_history_len"` +--let $assert_text= Assert that the history_len = 0 +--let $assert_cond= `SELECT '$history_len'=0` +--source include/assert.inc + +# 5. clean +connection default; +reap; +DROP database test1; diff --git a/storage/innobase/read/read0read.cc b/storage/innobase/read/read0read.cc index 0393d0cfe8b..aa4e37d9fbf 100644 --- a/storage/innobase/read/read0read.cc +++ b/storage/innobase/read/read0read.cc @@ -745,6 +745,7 @@ Close a view created by the above function. void MVCC::view_close(ReadView*& view, bool own_mutex) { + DEBUG_SYNC_C("MVCC_view_close"); uintptr_t p = reinterpret_cast(view); /* Note: The assumption here is that AC-NL-RO transactions will -- 2.19.1