Commit 015fb54d authored by Jan Lindström's avatar Jan Lindström

MDEV-25037 : SIGSEGV in MDL_lock::hog_lock_types_bitmap

We should not call mdl_context.release_explicit_locks() in
Wsrep_client_service::bf_rollback() if client is quiting because
it will be done again in THD::cleanup().

Note that problem with GET_LOCK() / RELEASE_LOCK() will be fixed
on MDEV-30473.
parent 75bbf645
connection node_2;
connection node_1;
BACKUP STAGE START;
START TRANSACTION;
COMMIT;
BACKUP STAGE END;
--source include/galera_cluster.inc
BACKUP STAGE START;
START TRANSACTION;
COMMIT;
BACKUP STAGE END;
/* Copyright 2018-2022 Codership Oy <info@codership.com>
/* Copyright 2018-2023 Codership Oy <info@codership.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -349,22 +349,36 @@ void Wsrep_client_service::debug_crash(const char* crash_point)
int Wsrep_client_service::bf_rollback()
{
DBUG_ASSERT(m_thd == current_thd);
DBUG_ENTER("Wsrep_client_service::rollback");
DBUG_ENTER("Wsrep_client_service::bf_rollback");
int ret= (trans_rollback_stmt(m_thd) || trans_rollback(m_thd));
if (m_thd->locked_tables_mode && m_thd->lock)
{
if (m_thd->locked_tables_list.unlock_locked_tables(m_thd))
ret= 1;
m_thd->variables.option_bits&= ~OPTION_TABLE_LOCK;
}
if (m_thd->global_read_lock.is_acquired())
WSREP_DEBUG("::bf_rollback() thread: %lu, client_state %s "
"client_mode %s trans_state %s killed %d",
thd_get_thread_id(m_thd),
wsrep_thd_client_state_str(m_thd),
wsrep_thd_client_mode_str(m_thd),
wsrep_thd_transaction_state_str(m_thd),
m_thd->killed);
/* If client is quiting all below will be done in THD::cleanup()
TODO: why we need this any other case? */
if (m_thd->wsrep_cs().state() != wsrep::client_state::s_quitting)
{
m_thd->global_read_lock.unlock_global_read_lock(m_thd);
if (m_thd->locked_tables_mode && m_thd->lock)
{
if (m_thd->locked_tables_list.unlock_locked_tables(m_thd))
ret= 1;
m_thd->variables.option_bits&= ~OPTION_TABLE_LOCK;
}
if (m_thd->global_read_lock.is_acquired())
{
m_thd->global_read_lock.unlock_global_read_lock(m_thd);
}
m_thd->release_transactional_locks();
mysql_ull_cleanup(m_thd);
m_thd->mdl_context.release_explicit_locks();
}
m_thd->release_transactional_locks();
mysql_ull_cleanup(m_thd);
m_thd->mdl_context.release_explicit_locks();
DBUG_RETURN(ret);
}
......@@ -292,6 +292,7 @@ int Wsrep_high_priority_service::append_fragment_and_commit(
ret= ret || trans_commit(m_thd);
ret= ret || (m_thd->wsrep_cs().after_applying(), 0);
m_thd->release_transactional_locks();
free_root(m_thd->mem_root, MYF(MY_KEEP_PREALLOC));
......@@ -380,6 +381,15 @@ int Wsrep_high_priority_service::rollback(const wsrep::ws_handle& ws_handle,
assert(ws_handle == wsrep::ws_handle());
}
int ret= (trans_rollback_stmt(m_thd) || trans_rollback(m_thd));
WSREP_DEBUG("::rollback() thread: %lu, client_state %s "
"client_mode %s trans_state %s killed %d",
thd_get_thread_id(m_thd),
wsrep_thd_client_state_str(m_thd),
wsrep_thd_client_mode_str(m_thd),
wsrep_thd_transaction_state_str(m_thd),
m_thd->killed);
m_thd->release_transactional_locks();
mysql_ull_cleanup(m_thd);
m_thd->mdl_context.release_explicit_locks();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment