Skip to content

Commit fbfb5a6

Browse files
janlindstromsysprg
authored andcommitted
MDEV-33928 : Assertion failure on wsrep_thd_is_aborting
Problem was assertion assuming we always hold THD::LOCK_thd_data mutex that is not true. In most cases this is true but function is also used from InnoDB lock manager and there we can't take THD::LOCK_thd_data to obey mutex ordering. Removed assertion as wsrep transaction state can't change even that case. Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
1 parent 466bc8f commit fbfb5a6

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

sql/service_wsrep.cc

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2018-2023 Codership Oy <info@codership.com>
1+
/* Copyright 2018-2024 Codership Oy <info@codership.com>
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -263,12 +263,28 @@ extern "C" my_bool wsrep_thd_order_before(const THD *left, const THD *right)
263263
return FALSE;
264264
}
265265

266+
/** Check if wsrep transaction is aborting state.
267+
268+
Calling function should make sure that wsrep transaction state
269+
can't change during this function.
270+
271+
This function is called from
272+
wsrep_abort_thd where we hold THD::LOCK_thd_data
273+
wsrep_handle_mdl_conflict we hold THD::LOCK_thd_data
274+
wsrep_assert_no_bf_bf_wait we hold lock_sys.latch
275+
innobase_kill_query we hold THD::LOCK_thd_data (THD::awake_no_mutex)
276+
277+
@param thd thread handle
278+
279+
@return true if wsrep transaction is aborting
280+
@return false if not
281+
282+
*/
266283
extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd)
267284
{
268-
mysql_mutex_assert_owner(&thd->LOCK_thd_data);
269-
270285
const wsrep::client_state& cs(thd->wsrep_cs());
271286
const enum wsrep::transaction::state tx_state(cs.transaction().state());
287+
272288
switch (tx_state)
273289
{
274290
case wsrep::transaction::s_must_abort:
@@ -277,7 +293,7 @@ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd)
277293
case wsrep::transaction::s_aborting:
278294
return true;
279295
default:
280-
return false;
296+
break;
281297
}
282298

283299
return false;

0 commit comments

Comments
 (0)