Skip to content

Commit 224c950

Browse files
committed
MDEV-23101 : SIGSEGV in lock_rec_unlock() when Galera is enabled
Remove incorrect BF (brute force) handling from lock_rec_has_to_wait_in_queue and move condition to correct callers. Add a function to report BF lock waits and assert if incorrect BF-BF lock wait happens. wsrep_report_bf_lock_wait Add a new function to report BF lock wait. wsrep_assert_no_bf_bf_wait Add a new function to check do we have a BF-BF wait and if we have report this case and assert as it is a bug. lock_rec_has_to_wait Use new wsrep_assert_bf_wait to check BF-BF wait. lock_rec_create_low lock_table_create Use new function to report BF lock waits. lock_rec_insert_by_trx_age lock_grant_and_move_on_page lock_grant_and_move_on_rec Assert that trx is not Galera as VATS is not compatible with Galera. lock_rec_add_to_queue If there is conflicting lock in a queue make sure that transaction is BF. lock_rec_has_to_wait_in_queue Remove incorrect BF handling. If there is conflicting locks in a queue all transactions must wait. lock_rec_dequeue_from_page lock_rec_unlock If there is conflicting lock make sure it is not BF-BF case. lock_rec_queue_validate Add Galera record locking rules comment and use new function to report BF lock waits. All attempts to reproduce the original assertion have been failed. Therefore, there is no test case on this commit.
1 parent 75e82f7 commit 224c950

File tree

6 files changed

+168
-156
lines changed

6 files changed

+168
-156
lines changed

include/mysql/service_wsrep.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ extern struct wsrep_service_st {
115115
void (*wsrep_unlock_rollback_func)();
116116
void (*wsrep_set_data_home_dir_func)(const char *data_dir);
117117
my_bool (*wsrep_thd_is_applier_func)(MYSQL_THD);
118+
void (*wsrep_report_bf_lock_wait_func)(MYSQL_THD thd,
119+
unsigned long long trx_id);
118120
} *wsrep_service;
119121

120122
#ifdef MYSQL_DYNAMIC_PLUGIN
@@ -161,6 +163,7 @@ extern struct wsrep_service_st {
161163
#define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
162164
#define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A)
163165
#define wsrep_thd_is_applier(T) wsrep_service->wsrep_thd_is_applier_func(T)
166+
#define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait_func(T,I)
164167

165168
#define wsrep_debug get_wsrep_debug()
166169
#define wsrep_log_conflicts get_wsrep_log_conflicts()
@@ -223,6 +226,8 @@ bool wsrep_thd_ignore_table(THD *thd);
223226
void wsrep_unlock_rollback();
224227
void wsrep_set_data_home_dir(const char *data_dir);
225228
my_bool wsrep_thd_is_applier(MYSQL_THD thd);
229+
void wsrep_report_bf_lock_wait(THD *thd,
230+
unsigned long long trx_id);
226231
#endif
227232

228233
#ifdef __cplusplus

sql/sql_plugin_services.ic

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static struct wsrep_service_st wsrep_handler = {
184184
wsrep_trx_order_before,
185185
wsrep_unlock_rollback,
186186
wsrep_set_data_home_dir,
187-
wsrep_thd_is_applier
187+
wsrep_thd_is_applier,
188+
wsrep_report_bf_lock_wait
188189
};
189190

190191
static struct thd_specifics_service_st thd_specifics_handler=

sql/wsrep_dummy.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2014 SkySQL Ab.
1+
/* Copyright (C) 2014, 2020, MariaDB
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
@@ -154,3 +154,7 @@ void wsrep_log(void (*)(const char *, ...), const char *, ...)
154154

155155
my_bool wsrep_thd_is_applier(MYSQL_THD thd)
156156
{ return false; }
157+
158+
void wsrep_report_bf_lock_wait(MYSQL_THD thd,
159+
unsigned long long id)
160+
{}

sql/wsrep_thd.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,3 +876,23 @@ bool wsrep_is_load_multi_commit(THD *thd)
876876
{
877877
return thd->wsrep_split_flag;
878878
}
879+
880+
void wsrep_report_bf_lock_wait(THD *thd,
881+
unsigned long long trx_id)
882+
{
883+
if (thd)
884+
{
885+
WSREP_ERROR("Thread %s trx_id: %llu thread: %ld "
886+
"seqno: %lld query_state: %s conf_state: %s exec_mode: %s "
887+
"applier: %d query: %s",
888+
wsrep_thd_is_BF(thd, false) ? "BF" : "normal",
889+
trx_id,
890+
thd_get_thread_id(thd),
891+
wsrep_thd_trx_seqno(thd),
892+
wsrep_thd_query_state_str(thd),
893+
wsrep_thd_conflict_state_str(thd),
894+
wsrep_thd_exec_mode_str(thd),
895+
thd->wsrep_applier,
896+
wsrep_thd_query(thd));
897+
}
898+
}

sql/wsrep_thd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ extern "C" my_bool wsrep_thd_is_BF_or_commit(void *thd_ptr, my_bool sync);
4545
extern "C" my_bool wsrep_thd_is_local(void *thd_ptr, my_bool sync);
4646
extern "C" int wsrep_thd_in_locking_session(void *thd_ptr);
4747

48+
extern void wsrep_report_bf_lock_wait(THD *thd,
49+
unsigned long long trx_id);
50+
4851
#else /* WITH_WSREP */
4952

5053
#define wsrep_thd_is_BF(T, S) (0)

0 commit comments

Comments
 (0)