MDEV-32541 Assertion `!(thd->server_status & (1U | 8192U))' failed in MDL_context::release_transactional_locks

SERVER_STATUS_IN_TRANS_READONLY should never be set without
SERVER_STATUS_IN_TRANS.

They're set together, must be removed together.
This commit is contained in:
Sergei Golubchik 2023-10-21 19:18:39 +02:00
parent 082aea7742
commit b00fd50fd8
4 changed files with 67 additions and 2 deletions

View File

@ -359,4 +359,34 @@ Note 4092 Unknown VIEW: 'test.s'
DROP VIEW v1;
DROP SEQUENCE s;
DROP TABLE t;
#
# End of 10.3 tests
#
#
# MDEV-32541 Assertion `!(thd->server_status & (1U | 8192U))' failed in MDL_context::release_transactional_locks
#
create sequence s1;
create sequence s2;
connect con1,localhost,root,,;
set session transaction read only;
start transaction;
connection default;
start transaction;
insert into s2 values (1, 1, 10000, 100, 1, 1000, 0, 0);
connection con1;
select lastval(s1);
lastval(s1)
NULL
select lastval(s2);;
connection default;
set lock_wait_timeout= 1;
insert into s1 values (1, 1, 10000, 100, 1, 1000, 0, 0);
connection con1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
disconnect con1;
connection default;
drop sequence s1;
drop sequence s2;
#
# End of 10.4 tests
#

View File

@ -387,4 +387,39 @@ DROP VIEW IF EXISTS s;
DROP VIEW v1;
DROP SEQUENCE s;
DROP TABLE t;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # MDEV-32541 Assertion `!(thd->server_status & (1U | 8192U))' failed in MDL_context::release_transactional_locks
--echo #
create sequence s1;
create sequence s2;
--connect (con1,localhost,root,,)
set session transaction read only;
start transaction;
--connection default
start transaction;
insert into s2 values (1, 1, 10000, 100, 1, 1000, 0, 0);
--connection con1
select lastval(s1);
--send select lastval(s2);
--connection default
set lock_wait_timeout= 1;
insert into s1 values (1, 1, 10000, 100, 1, 1000, 0, 0);
--connection con1
--error ER_LOCK_DEADLOCK
--reap
--disconnect con1
--connection default
drop sequence s1;
drop sequence s2;
--echo #
--echo # End of 10.4 tests
--echo #

View File

@ -383,7 +383,7 @@ bool trans_rollback_implicit(THD *thd)
*/
DBUG_ASSERT(thd->transaction.stmt.is_empty() && !thd->in_sub_stmt);
thd->server_status&= ~SERVER_STATUS_IN_TRANS;
thd->server_status&= ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= ha_rollback_trans(thd, true);
/*

View File

@ -45,7 +45,7 @@ public:
, m_server_status(thd->server_status)
{
m_thd->variables.option_bits&= ~OPTION_BEGIN;
m_thd->server_status&= ~SERVER_STATUS_IN_TRANS;
m_thd->server_status&= ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
m_thd->wsrep_cs().enter_toi_mode(ws_meta);
}
~Wsrep_non_trans_mode()