mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
6966d7fe4b
This is a backport from 10.5. The problem seems to be a deadlock between KILL command execution and BF abort issued by an applier, where: * KILL has locked victim's LOCK_thd_kill and LOCK_thd_data. * Applier has innodb side global lock mutex and victim trx mutex. * KILL is calling innobase_kill_query, and is blocked by innodb global lock mutex. * Applier is in wsrep_innobase_kill_one_trx and is blocked by victim's LOCK_thd_kill. The fix in this commit removes the TOI replication of KILL command and makes KILL execution less intrusive operation. Aborting the victim happens now by using awake_no_mutex() and ha_abort_transaction(). If the KILL happens when the transaction is committing, the KILL operation is postponed to happen after the statement has completed in order to avoid KILL to interrupt commit processing. Notable changes in this commit: * wsrep client connections's error state may remain sticky after client connection is closed. This error message will then pop up for the next client session issuing first SQL statement. This problem raised with test galera.galera_bf_kill. The fix is to reset wsrep client error state, before a THD is reused for next connetion. * Release THD locks in wsrep_abort_transaction when locking innodb mutexes. This guarantees same locking order as with applier BF aborting. * BF abort from MDL was changed to do BF abort on server/wsrep-lib side first, and only then do the BF abort on InnoDB side. This removes the need to call back from InnoDB for BF aborts which originate from MDL and simplifies the locking. * Removed wsrep_thd_set_wsrep_aborter() from service_wsrep.h. The manipulation of the wsrep_aborter can be done solely on server side. Moreover, it is now debug only variable and could be excluded from optimized builds. * Remove LOCK_thd_kill from wsrep_thd_LOCK/UNLOCK to allow more fine grained locking for SR BF abort which may require locking of victim LOCK_thd_kill. Added explicit call for wsrep_thd_kill_LOCK/UNLOCK where appropriate. * Wsrep-lib was updated to version which allows external locking for BF abort calls. Changes to MTR tests: * Disable galera_bf_abort_group_commit. This test is going to be removed (MDEV-30855). * Record galera_gcache_recover_manytrx as result file was incomplete. Trivial change. * Make galera_create_table_as_select more deterministic: Wait until CTAS execution has reached MDL wait for multi-master conflict case. Expected error from multi-master conflict is ER_QUERY_INTERRUPTED. This is because CTAS does not yet have open wsrep transaction when it is waiting for MDL, query gets interrupted instead of BF aborted. This should be addressed in separate task. * A new test galera_kill_group_commit to verify correct behavior when KILL is executed while the transaction is committing. Co-authored-by: Seppo Jaakola <seppo.jaakola@iki.fi> Co-authored-by: Jan Lindström <jan.lindstrom@galeracluster.com> Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
155 lines
3.3 KiB
C++
155 lines
3.3 KiB
C++
/* Copyright (C) 2014, 2021, MariaDB
|
|
|
|
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
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */
|
|
|
|
#include "mariadb.h"
|
|
#include <sql_class.h>
|
|
#include <mysql/service_wsrep.h>
|
|
|
|
my_bool wsrep_thd_is_BF(const THD *, my_bool)
|
|
{ return 0; }
|
|
|
|
int wsrep_is_wsrep_xid(const void* xid)
|
|
{ return 0; }
|
|
|
|
long long wsrep_xid_seqno(const XID* x)
|
|
{ return -1; }
|
|
|
|
const unsigned char* wsrep_xid_uuid(const XID*)
|
|
{
|
|
static const unsigned char uuid[16]= {0};
|
|
return uuid;
|
|
}
|
|
|
|
bool wsrep_prepare_key_for_innodb(THD* thd, const uchar*, size_t, const uchar*, size_t, struct wsrep_buf*, size_t*)
|
|
{ return 1; }
|
|
|
|
bool wsrep_prepare_key(const uchar*, size_t, const uchar*, size_t, struct wsrep_buf*, size_t*)
|
|
{ return 0; }
|
|
|
|
struct wsrep *get_wsrep()
|
|
{ return 0; }
|
|
|
|
my_bool get_wsrep_recovery()
|
|
{ return 0; }
|
|
|
|
bool wsrep_consistency_check(THD *)
|
|
{ return 0; }
|
|
|
|
void wsrep_lock_rollback()
|
|
{ }
|
|
|
|
my_bool wsrep_on(const THD *)
|
|
{ return 0; }
|
|
|
|
void wsrep_thd_LOCK(const THD *)
|
|
{ }
|
|
|
|
int wsrep_thd_TRYLOCK(const THD *)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
void wsrep_thd_UNLOCK(const THD *)
|
|
{ }
|
|
|
|
void wsrep_thd_kill_LOCK(const THD *)
|
|
{ }
|
|
|
|
void wsrep_thd_kill_UNLOCK(const THD *)
|
|
{ }
|
|
|
|
const char *wsrep_thd_conflict_state_str(THD *)
|
|
{ return 0; }
|
|
|
|
const char *wsrep_thd_exec_mode_str(THD *)
|
|
{ return NULL; }
|
|
|
|
const char *wsrep_thd_query(const THD *)
|
|
{ return "NULL"; }
|
|
|
|
const char *wsrep_thd_query_state_str(THD *)
|
|
{ return 0; }
|
|
|
|
int wsrep_thd_retry_counter(const THD *)
|
|
{ return 0; }
|
|
|
|
bool wsrep_thd_ignore_table(THD *)
|
|
{ return 0; }
|
|
|
|
long long wsrep_thd_trx_seqno(const THD *)
|
|
{ return -1; }
|
|
|
|
my_bool wsrep_thd_is_aborting(const THD *)
|
|
{ return 0; }
|
|
|
|
void wsrep_set_data_home_dir(const char *)
|
|
{ }
|
|
|
|
my_bool wsrep_thd_is_local(const THD *)
|
|
{ return 0; }
|
|
|
|
void wsrep_thd_self_abort(THD *)
|
|
{ }
|
|
|
|
int wsrep_thd_append_key(THD *, const struct wsrep_key*, int, enum Wsrep_service_key_type)
|
|
{ return 0; }
|
|
|
|
const char* wsrep_thd_client_state_str(const THD*)
|
|
{ return 0; }
|
|
|
|
const char* wsrep_thd_client_mode_str(const THD*)
|
|
{ return 0; }
|
|
|
|
const char* wsrep_thd_transaction_state_str(const THD*)
|
|
{ return 0; }
|
|
|
|
query_id_t wsrep_thd_transaction_id(const THD *)
|
|
{ return 0; }
|
|
|
|
my_bool wsrep_thd_bf_abort(THD *, THD *, my_bool)
|
|
{ return 0; }
|
|
|
|
my_bool wsrep_thd_order_before(const THD*, const THD *)
|
|
{ return 0; }
|
|
|
|
void wsrep_handle_SR_rollback(THD*, THD*)
|
|
{ }
|
|
|
|
my_bool wsrep_thd_skip_locking(const THD*)
|
|
{ return 0;}
|
|
|
|
const char* wsrep_get_sr_table_name()
|
|
{ return 0; }
|
|
|
|
my_bool wsrep_get_debug()
|
|
{ return 0;}
|
|
|
|
void wsrep_commit_ordered(THD* )
|
|
{ }
|
|
|
|
void wsrep_log(void (*)(const char *, ...), const char *, ...)
|
|
{
|
|
}
|
|
|
|
my_bool wsrep_thd_is_applying(const THD*)
|
|
{ return 0;}
|
|
|
|
void wsrep_report_bf_lock_wait(const THD*,
|
|
unsigned long long)
|
|
{}
|
|
|
|
void wsrep_thd_set_PA_unsafe(THD*)
|
|
{}
|
|
|