1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-30307 KILL command inside a transaction causes problem for galera replication

Added new test scenario in galera.galera_bf_kill
test to make the issue surface. The tetst scenario has
a multi statement transaction containing a KILL command.
When the KILL is submitted, another transaction is
replicated, which causes BF abort for the KILL command
processing. Handling BF abort rollback while executing
KILL command causes node hanging, in this scenario.

sql_kill() and sql_kill_user() functions have now fix,
to perform implicit commit before starting the KILL command
execution. BEcause of the implicit commit, the KILL execution
will not happen inside transaction context anymore.

Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
This commit is contained in:
sjaakola
2022-12-28 19:44:41 +02:00
committed by Julius Goryavsky
parent 78e640ea3e
commit cf0c3ec274
3 changed files with 136 additions and 1 deletions

View File

@ -9599,8 +9599,27 @@ static
void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type)
{
#ifdef WITH_WSREP
if (WSREP(thd))
{
if (!(thd->variables.option_bits & OPTION_GTID_BEGIN))
{
WSREP_DEBUG("implicit commit before KILL");
/* Commit the normal transaction if one is active. */
bool commit_failed= trans_commit_implicit(thd);
/* Release metadata locks acquired in this transaction. */
thd->release_transactional_locks();
if (commit_failed || wsrep_after_statement(thd))
{
WSREP_DEBUG("implicit commit failed, MDL released: %lld",
(longlong) thd->thread_id);
return;
}
thd->transaction->stmt.mark_trans_did_ddl();
}
}
bool wsrep_high_priority= false;
#endif
#endif /* WITH_WSREP */
uint error= kill_one_thread(thd, id, state, type
#ifdef WITH_WSREP
, wsrep_high_priority
@ -9632,6 +9651,26 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
{
uint error;
ha_rows rows;
#ifdef WITH_WSREP
if (WSREP(thd))
{
if (!(thd->variables.option_bits & OPTION_GTID_BEGIN))
{
WSREP_DEBUG("implicit commit before KILL");
/* Commit the normal transaction if one is active. */
bool commit_failed= trans_commit_implicit(thd);
/* Release metadata locks acquired in this transaction. */
thd->release_transactional_locks();
if (commit_failed || wsrep_after_statement(thd))
{
WSREP_DEBUG("implicit commit failed, MDL released: %lld",
(longlong) thd->thread_id);
return;
}
thd->transaction->stmt.mark_trans_did_ddl();
}
}
#endif /* WITH_WSREP */
switch (error= kill_threads_for_user(thd, user, state, &rows))
{
case 0: