Skip to content

Commit

Permalink
MDEV-32541 Assertion `!(thd->server_status & (1U | 8192U))' failed in…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
vuvova committed Oct 23, 2023
1 parent 082aea7 commit b00fd50
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
30 changes: 30 additions & 0 deletions mysql-test/suite/sql_sequence/other.result
Expand Up @@ -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
#
35 changes: 35 additions & 0 deletions mysql-test/suite/sql_sequence/other.test
Expand Up @@ -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 #
2 changes: 1 addition & 1 deletion sql/transaction.cc
Expand Up @@ -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);
/*
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_high_priority_service.cc
Expand Up @@ -45,7 +45,7 @@ class Wsrep_non_trans_mode
, 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()
Expand Down

0 comments on commit b00fd50

Please sign in to comment.