MDEV-29293 MariaDB stuck on starting commit state
This commit contains a merge from 10.5-MDEV-29293-squash into 10.6. Although the bug MDEV-29293 was not reproducible with 10.6, the fix contains several improvements for wsrep KILL query and BF abort handling, and addresses the following issues: * MDEV-30307 KILL command issued inside a transaction is problematic for galera replication: This commit will remove KILL TOI replication, so Galera side transaction context is not lost during KILL. * MDEV-21075 KILL QUERY maintains nodes data consistency but breaks GTID sequence: This is fixed as well as KILL does not use TOI, and thus does not change GTID state. * MDEV-30372 Assertion in wsrep-lib state: This was caused by BF abort or KILL when local transaction was in the middle of group commit. This commit disables THD::killed handling during commit, so the problem is avoided. * MDEV-30963 Assertion failure !lock.was_chosen_as_deadlock_victim in trx0trx.h:1065: The assertion happened when the victim was BF aborted via MDL while it was committing. This commit changes MDL BF aborts so that transactions which are committing cannot be BF aborted via MDL. The RQG grammar attached in the issue could not reproduce the crash anymore. Original commit message from 10.5 fix: MDEV-29293 MariaDB stuck on starting commit state 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). * Make galera_var_retry_autocommit result more readable by echoing cases and expectations into result. Only one expected result for reap to verify that server returns expected status for query. * 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_bf_abort_registering to check that registering trx gets BF aborted through MDL. * 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>
This commit is contained in:
parent
d2420669bd
commit
f307160218
@ -57,6 +57,7 @@ extern struct wsrep_service_st {
|
||||
my_bool (*wsrep_on_func)(const MYSQL_THD thd);
|
||||
bool (*wsrep_prepare_key_for_innodb_func)(MYSQL_THD thd, const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*);
|
||||
void (*wsrep_thd_LOCK_func)(const MYSQL_THD thd);
|
||||
int (*wsrep_thd_TRYLOCK_func)(const MYSQL_THD thd);
|
||||
void (*wsrep_thd_UNLOCK_func)(const MYSQL_THD thd);
|
||||
const char * (*wsrep_thd_query_func)(const MYSQL_THD thd);
|
||||
int (*wsrep_thd_retry_counter_func)(const MYSQL_THD thd);
|
||||
@ -89,7 +90,6 @@ extern struct wsrep_service_st {
|
||||
ulong (*wsrep_OSU_method_get_func)(const MYSQL_THD thd);
|
||||
my_bool (*wsrep_thd_has_ignored_error_func)(const MYSQL_THD thd);
|
||||
void (*wsrep_thd_set_ignored_error_func)(MYSQL_THD thd, my_bool val);
|
||||
bool (*wsrep_thd_set_wsrep_aborter_func)(MYSQL_THD bf_thd, MYSQL_THD thd);
|
||||
void (*wsrep_report_bf_lock_wait_func)(const MYSQL_THD thd,
|
||||
unsigned long long trx_id);
|
||||
void (*wsrep_thd_kill_LOCK_func)(const MYSQL_THD thd);
|
||||
@ -111,6 +111,7 @@ extern struct wsrep_service_st {
|
||||
#define wsrep_on(thd) (thd) && WSREP_ON && wsrep_service->wsrep_on_func(thd)
|
||||
#define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F,G)
|
||||
#define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T)
|
||||
#define wsrep_thd_TRYLOCK(T) wsrep_service->wsrep_thd_TRYLOCK_func(T)
|
||||
#define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T)
|
||||
#define wsrep_thd_kill_LOCK(T) wsrep_service->wsrep_thd_kill_LOCK_func(T)
|
||||
#define wsrep_thd_kill_UNLOCK(T) wsrep_service->wsrep_thd_kill_UNLOCK_func(T)
|
||||
@ -141,7 +142,6 @@ extern struct wsrep_service_st {
|
||||
#define wsrep_OSU_method_get(T) wsrep_service->wsrep_OSU_method_get_func(T)
|
||||
#define wsrep_thd_has_ignored_error(T) wsrep_service->wsrep_thd_has_ignored_error_func(T)
|
||||
#define wsrep_thd_set_ignored_error(T,V) wsrep_service->wsrep_thd_set_ignored_error_func(T,V)
|
||||
#define wsrep_thd_set_wsrep_aborter(T) wsrep_service->wsrep_thd_set_wsrep_aborter_func(T1, T2)
|
||||
#define wsrep_report_bf_lock_wait(T,I) wsrep_service->wsrep_report_bf_lock_wait(T,I)
|
||||
#define wsrep_thd_set_PA_unsafe(T) wsrep_service->wsrep_thd_set_PA_unsafe_func(T)
|
||||
#else
|
||||
@ -175,6 +175,8 @@ void wsrep_set_data_home_dir(const char *data_dir);
|
||||
extern "C" my_bool wsrep_on(const MYSQL_THD thd);
|
||||
/* Lock thd wsrep lock */
|
||||
extern "C" void wsrep_thd_LOCK(const MYSQL_THD thd);
|
||||
/* Try thd wsrep lock. Return non-zero if lock could not be taken. */
|
||||
extern "C" int wsrep_thd_TRYLOCK(const MYSQL_THD thd);
|
||||
/* Unlock thd wsrep lock */
|
||||
extern "C" void wsrep_thd_UNLOCK(const MYSQL_THD thd);
|
||||
|
||||
@ -197,8 +199,6 @@ extern "C" my_bool wsrep_thd_is_local(const MYSQL_THD thd);
|
||||
/* Return true if thd is in high priority mode */
|
||||
/* todo: rename to is_high_priority() */
|
||||
extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd);
|
||||
/* set wsrep_aborter for the target THD */
|
||||
extern "C" bool wsrep_thd_set_wsrep_aborter(MYSQL_THD bf_thd, MYSQL_THD victim_thd);
|
||||
/* Return true if thd is in TOI mode */
|
||||
extern "C" my_bool wsrep_thd_is_toi(const MYSQL_THD thd);
|
||||
/* Return true if thd is in replicating TOI mode */
|
||||
@ -249,7 +249,6 @@ extern "C" my_bool wsrep_thd_is_applying(const MYSQL_THD thd);
|
||||
extern "C" ulong wsrep_OSU_method_get(const MYSQL_THD thd);
|
||||
extern "C" my_bool wsrep_thd_has_ignored_error(const MYSQL_THD thd);
|
||||
extern "C" void wsrep_thd_set_ignored_error(MYSQL_THD thd, my_bool val);
|
||||
extern "C" bool wsrep_thd_set_wsrep_aborter(MYSQL_THD bf_thd, MYSQL_THD victim_thd);
|
||||
extern "C" void wsrep_report_bf_lock_wait(const THD *thd,
|
||||
unsigned long long trx_id);
|
||||
/* declare parallel applying unsafety for the THD */
|
||||
|
@ -26,3 +26,5 @@ galera_var_ignore_apply_errors : 28: "Server did not transition to READY state"
|
||||
galera_bf_kill_debug : timeout after 900 seconds
|
||||
galera_ssl_upgrade : [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 130: Incorrect file format 'gtid_slave_pos'
|
||||
galera_insert_bulk : MDEV-30536 no expected deadlock in galera_insert_bulk test
|
||||
MDEV-27713 : test is using get_lock(), which is now rejected in cluster
|
||||
galera_bf_abort_group_commit : MDEV-30855 PR to remove the test exists
|
||||
|
21
mysql-test/suite/galera/r/MDEV-29293.result
Normal file
21
mysql-test/suite/galera/r/MDEV-29293.result
Normal file
@ -0,0 +1,21 @@
|
||||
connection node_2;
|
||||
connection node_1;
|
||||
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
set wsrep_sync_wait = 0;
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) engine=InnoDB;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
connection node_1a;
|
||||
BEGIN;
|
||||
UPDATE t1 SET b=3 WHERE a=1;
|
||||
connection node_1;
|
||||
set debug_sync='wsrep_kill_before_awake_no_mutex SIGNAL before_kill WAIT_FOR continue';
|
||||
connection node_1b;
|
||||
set debug_sync= 'now WAIT_FOR before_kill';
|
||||
connection node_2;
|
||||
UPDATE t1 SET b=7 WHERE a=1;
|
||||
connection node_1b;
|
||||
set debug_sync= 'now SIGNAL continue';
|
||||
connection node_1;
|
||||
DROP TABLE t1;
|
||||
SET DEBUG_SYNC= 'RESET';
|
@ -82,6 +82,7 @@ connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
LOCK TABLE t2 WRITE;
|
||||
connection node_1;
|
||||
CREATE TABLE t1 AS SELECT * FROM t2;;
|
||||
connection node_1a;
|
||||
connection node_2;
|
||||
SELECT COUNT(*) = 5 FROM t2;
|
||||
COUNT(*) = 5
|
||||
|
@ -134,6 +134,3 @@ connection node_1;
|
||||
call mtr.add_suppression("Error in Log_event::read_log_event():.*");
|
||||
CALL mtr.add_suppression("conflict state 7 after post commit");
|
||||
CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
|
||||
connection node_2;
|
||||
call mtr.add_suppression("Error in Log_event::read_log_event():.*");
|
||||
CALL mtr.add_suppression("Skipped GCache ring buffer recovery");
|
||||
|
27
mysql-test/suite/galera/r/galera_kill_group_commit.result
Normal file
27
mysql-test/suite/galera/r/galera_kill_group_commit.result
Normal file
@ -0,0 +1,27 @@
|
||||
connection node_2;
|
||||
connection node_1;
|
||||
connect node_1_kill, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
connect node_1_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
SET SESSION wsrep_sync_wait = 0;
|
||||
connect node_1_follower, 127.0.0.1, root, , test, $NODE_MYPORT_1;
|
||||
SET SESSION wsrep_sync_wait = 0;
|
||||
connection node_1;
|
||||
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
SET SESSION DEBUG_SYNC = "commit_before_enqueue SIGNAL leader_before_enqueue_reached WAIT_FOR leader_before_enqueue_continue";
|
||||
INSERT INTO t1 VALUES (1);
|
||||
connection node_1_ctrl;
|
||||
SET DEBUG_SYNC = "now WAIT_FOR leader_before_enqueue_reached";
|
||||
connection node_1_follower;
|
||||
INSERT INTO t1 VALUES (2);;
|
||||
connection node_1_ctrl;
|
||||
connection node_1_kill;
|
||||
# Execute KILL QUERY for group commit follower
|
||||
SET DEBUG_SYNC = "now SIGNAL leader_before_enqueue_continue";
|
||||
connection node_1_follower;
|
||||
connection node_1;
|
||||
SELECT * FROM t1;
|
||||
f1
|
||||
1
|
||||
2
|
||||
SET DEBUG_SYNC = "RESET";
|
||||
DROP TABLE t1;
|
@ -36,7 +36,10 @@ SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
||||
connection node_1;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
1
|
||||
connection node_1;
|
||||
SELECT COUNT(*) FROM t1;
|
||||
COUNT(*)
|
||||
0
|
||||
SET DEBUG_SYNC = 'RESET';
|
||||
SET GLOBAL debug_dbug = NULL;
|
||||
DROP TABLE t1;
|
||||
|
41
mysql-test/suite/galera/t/MDEV-29293.test
Normal file
41
mysql-test/suite/galera/t/MDEV-29293.test
Normal file
@ -0,0 +1,41 @@
|
||||
--source include/galera_cluster.inc
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/galera_have_debug_sync.inc
|
||||
|
||||
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
||||
--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
||||
set wsrep_sync_wait = 0;
|
||||
|
||||
CREATE TABLE t1(a int not null primary key auto_increment, b int) engine=InnoDB;
|
||||
INSERT INTO t1 VALUES (1,2);
|
||||
|
||||
--connection node_1a
|
||||
--let $victim_id = `SELECT CONNECTION_ID()`
|
||||
BEGIN;
|
||||
UPDATE t1 SET b=3 WHERE a=1;
|
||||
|
||||
--connection node_1
|
||||
set debug_sync='wsrep_kill_before_awake_no_mutex SIGNAL before_kill WAIT_FOR continue';
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
--send_eval KILL CONNECTION $victim_id
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
--connection node_1b
|
||||
set debug_sync= 'now WAIT_FOR before_kill';
|
||||
|
||||
--connection node_2
|
||||
UPDATE t1 SET b=7 WHERE a=1;
|
||||
|
||||
--connection node_1b
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE User = 'system user' AND State LIKE 'Update_rows_log_event%';
|
||||
--source include/wait_condition.inc
|
||||
set debug_sync= 'now SIGNAL continue';
|
||||
|
||||
--connection node_1
|
||||
--reap
|
||||
DROP TABLE t1;
|
||||
SET DEBUG_SYNC= 'RESET';
|
||||
|
@ -113,6 +113,10 @@ LOCK TABLE t2 WRITE;
|
||||
--connection node_1
|
||||
--send CREATE TABLE t1 AS SELECT * FROM t2;
|
||||
|
||||
--connection node_1a
|
||||
--let $wait_condition = SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE STATE LIKE 'Waiting for table metadata lock%'
|
||||
--source include/wait_condition.inc
|
||||
|
||||
--connection node_2
|
||||
SELECT COUNT(*) = 5 FROM t2;
|
||||
CREATE TABLE t1 AS SELECT * FROM t2;
|
||||
@ -121,7 +125,7 @@ CREATE TABLE t1 AS SELECT * FROM t2;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--connection node_1
|
||||
--error ER_TABLE_EXISTS_ERROR,ER_LOCK_DEADLOCK
|
||||
--error ER_TABLE_EXISTS_ERROR,ER_QUERY_INTERRUPTED
|
||||
--reap
|
||||
|
||||
DROP TABLE t1, t2;
|
||||
|
5
mysql-test/suite/galera/t/galera_kill_group_commit.cnf
Normal file
5
mysql-test/suite/galera/t/galera_kill_group_commit.cnf
Normal file
@ -0,0 +1,5 @@
|
||||
!include ../galera_2nodes.cnf
|
||||
|
||||
[mysqld]
|
||||
log-bin
|
||||
log-slave-updates
|
69
mysql-test/suite/galera/t/galera_kill_group_commit.test
Normal file
69
mysql-test/suite/galera/t/galera_kill_group_commit.test
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Verify that transaction which has reached group commit queue
|
||||
# cannot be killed. If the kill succeeds, assertion for
|
||||
# wsrep transaction state will fail.
|
||||
#
|
||||
# If the bug is present, i.e. wsrep transaction gets killed during
|
||||
# group commit wait, this test is enough to reproduce the crash
|
||||
# most of the time.
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug_sync.inc
|
||||
--source include/galera_cluster.inc
|
||||
|
||||
# Connection for KILL commands
|
||||
--connect node_1_kill, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
||||
# Connection for sync point control
|
||||
--connect node_1_ctrl, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
||||
SET SESSION wsrep_sync_wait = 0;
|
||||
# Connection for group commit follower
|
||||
--connect node_1_follower, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
||||
# Need to disable sync wait to reach commit queue when leader
|
||||
# is blocked.
|
||||
SET SESSION wsrep_sync_wait = 0;
|
||||
--let $follower_id = `SELECT CONNECTION_ID()`
|
||||
|
||||
--connection node_1
|
||||
CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
|
||||
|
||||
SET SESSION DEBUG_SYNC = "commit_before_enqueue SIGNAL leader_before_enqueue_reached WAIT_FOR leader_before_enqueue_continue";
|
||||
--send INSERT INTO t1 VALUES (1)
|
||||
|
||||
--connection node_1_ctrl
|
||||
SET DEBUG_SYNC = "now WAIT_FOR leader_before_enqueue_reached";
|
||||
|
||||
--connection node_1_follower
|
||||
# SET SESSION DEBUG_SYNC = "group_commit_waiting_for_prior SIGNAL follower_waiting_for_prior_reached WAIT_FOR follower_waiting_for_prior_continue";
|
||||
--send INSERT INTO t1 VALUES (2);
|
||||
|
||||
--connection node_1_ctrl
|
||||
# TODO: Is it possible to use sync points to enforce group commit to happen?
|
||||
# The leader will hold commit monitor in commit_before_enqueue sync point,
|
||||
# which prevents the follower to reach the group commit wait state.
|
||||
# We now sleep and expect the follower to reach group commit, but this
|
||||
# may cause false negatives.
|
||||
--sleep 1
|
||||
|
||||
--connection node_1_kill
|
||||
--echo # Execute KILL QUERY for group commit follower
|
||||
--disable_query_log
|
||||
--disable_result_log
|
||||
# Because it is currently impossible to verify that the
|
||||
# follower has reached group commit queue, the KILL may
|
||||
# sometimes return success.
|
||||
--error 0,ER_KILL_DENIED_ERROR
|
||||
--eval KILL QUERY $follower_id
|
||||
--enable_result_log
|
||||
--enable_query_log
|
||||
|
||||
SET DEBUG_SYNC = "now SIGNAL leader_before_enqueue_continue";
|
||||
--connection node_1_follower
|
||||
--reap
|
||||
|
||||
--connection node_1
|
||||
--reap
|
||||
SELECT * FROM t1;
|
||||
|
||||
SET DEBUG_SYNC = "RESET";
|
||||
DROP TABLE t1;
|
@ -64,6 +64,7 @@ SELECT COUNT(*) FROM t1;
|
||||
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
||||
|
||||
--connection node_1
|
||||
--error 0,ER_LOCK_DEADLOCK
|
||||
--reap
|
||||
SELECT COUNT(*) FROM t1;
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "sql_sequence.h"
|
||||
#include "mem_root_array.h"
|
||||
#include <utility> // pair
|
||||
#include <my_attribute.h> /* __attribute__ */
|
||||
|
||||
class Alter_info;
|
||||
class Virtual_column_info;
|
||||
@ -1530,9 +1531,9 @@ struct handlerton
|
||||
const char *query, uint query_length,
|
||||
const char *db, const char *table_name);
|
||||
|
||||
void (*abort_transaction)(handlerton *hton, THD *bf_thd,
|
||||
THD *victim_thd, my_bool signal);
|
||||
int (*set_checkpoint)(handlerton *hton, const XID* xid);
|
||||
void (*abort_transaction)(handlerton *hton, THD *bf_thd, THD *victim_thd,
|
||||
my_bool signal) __attribute__((nonnull));
|
||||
int (*set_checkpoint)(handlerton *hton, const XID *xid);
|
||||
int (*get_checkpoint)(handlerton *hton, XID* xid);
|
||||
/**
|
||||
Check if the version of the table matches the version in the .frm
|
||||
|
@ -32,6 +32,11 @@ extern "C" void wsrep_thd_LOCK(const THD *thd)
|
||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
}
|
||||
|
||||
extern "C" int wsrep_thd_TRYLOCK(const THD *thd)
|
||||
{
|
||||
return mysql_mutex_trylock(&thd->LOCK_thd_data);
|
||||
}
|
||||
|
||||
extern "C" void wsrep_thd_UNLOCK(const THD *thd)
|
||||
{
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
||||
@ -196,6 +201,7 @@ extern "C" void wsrep_handle_SR_rollback(THD *bf_thd,
|
||||
|
||||
/* Note: do not store/reset globals before wsrep_bf_abort() call
|
||||
to avoid losing BF thd context. */
|
||||
mysql_mutex_lock(&victim_thd->LOCK_thd_data);
|
||||
if (!(bf_thd && bf_thd != victim_thd))
|
||||
{
|
||||
DEBUG_SYNC(victim_thd, "wsrep_before_SR_rollback");
|
||||
@ -208,6 +214,7 @@ extern "C" void wsrep_handle_SR_rollback(THD *bf_thd,
|
||||
{
|
||||
wsrep_thd_self_abort(victim_thd);
|
||||
}
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
if (bf_thd)
|
||||
{
|
||||
wsrep_store_threadvars(bf_thd);
|
||||
@ -218,7 +225,7 @@ extern "C" my_bool wsrep_thd_bf_abort(THD *bf_thd, THD *victim_thd,
|
||||
my_bool signal)
|
||||
{
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_kill);
|
||||
mysql_mutex_assert_not_owner(&victim_thd->LOCK_thd_data);
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
my_bool ret= wsrep_bf_abort(bf_thd, victim_thd);
|
||||
/*
|
||||
Send awake signal if victim was BF aborted or does not
|
||||
@ -227,19 +234,8 @@ extern "C" my_bool wsrep_thd_bf_abort(THD *bf_thd, THD *victim_thd,
|
||||
*/
|
||||
if ((ret || !wsrep_on(victim_thd)) && signal)
|
||||
{
|
||||
mysql_mutex_lock(&victim_thd->LOCK_thd_data);
|
||||
|
||||
if (victim_thd->wsrep_aborter && victim_thd->wsrep_aborter != bf_thd->thread_id)
|
||||
{
|
||||
WSREP_DEBUG("victim is killed already by %llu, skipping awake",
|
||||
victim_thd->wsrep_aborter);
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
return false;
|
||||
}
|
||||
|
||||
victim_thd->wsrep_aborter= bf_thd->thread_id;
|
||||
victim_thd->awake_no_mutex(KILL_QUERY_HARD);
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
} else {
|
||||
WSREP_DEBUG("wsrep_thd_bf_abort skipped awake, signal %d", signal);
|
||||
}
|
||||
@ -368,25 +364,6 @@ extern "C" ulong wsrep_OSU_method_get(const MYSQL_THD thd)
|
||||
return(global_system_variables.wsrep_OSU_method);
|
||||
}
|
||||
|
||||
extern "C" bool wsrep_thd_set_wsrep_aborter(THD *bf_thd, THD *victim_thd)
|
||||
{
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
if (!bf_thd)
|
||||
{
|
||||
victim_thd->wsrep_aborter= 0;
|
||||
WSREP_DEBUG("wsrep_thd_set_wsrep_aborter resetting wsrep_aborter");
|
||||
return false;
|
||||
}
|
||||
if (victim_thd->wsrep_aborter && victim_thd->wsrep_aborter != bf_thd->thread_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
victim_thd->wsrep_aborter= bf_thd->thread_id;
|
||||
WSREP_DEBUG("wsrep_thd_set_wsrep_aborter setting wsrep_aborter %u",
|
||||
victim_thd->wsrep_aborter);
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" void wsrep_report_bf_lock_wait(const THD *thd,
|
||||
unsigned long long trx_id)
|
||||
{
|
||||
|
@ -1310,6 +1310,11 @@ void THD::init()
|
||||
wsrep_affected_rows = 0;
|
||||
m_wsrep_next_trx_id = WSREP_UNDEFINED_TRX_ID;
|
||||
wsrep_aborter = 0;
|
||||
wsrep_abort_by_kill = NOT_KILLED;
|
||||
wsrep_abort_by_kill_err = 0;
|
||||
#ifndef DBUG_OFF
|
||||
wsrep_killed_state = 0;
|
||||
#endif /* DBUG_OFF */
|
||||
wsrep_desynced_backup_stage= false;
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
@ -1661,6 +1666,13 @@ void THD::reset_for_reuse()
|
||||
#endif
|
||||
#ifdef WITH_WSREP
|
||||
wsrep_free_status(this);
|
||||
wsrep_cs().reset_error();
|
||||
wsrep_aborter= 0;
|
||||
wsrep_abort_by_kill= NOT_KILLED;
|
||||
wsrep_abort_by_kill_err= 0;
|
||||
#ifndef DBUG_OFF
|
||||
wsrep_killed_state= 0;
|
||||
#endif /* DBUG_OFF */
|
||||
#endif /* WITH_WSREP */
|
||||
}
|
||||
|
||||
@ -1917,7 +1929,9 @@ void THD::awake_no_mutex(killed_state state_to_set)
|
||||
}
|
||||
|
||||
/* Interrupt target waiting inside a storage engine. */
|
||||
if (state_to_set != NOT_KILLED && !wsrep_is_bf_aborted(this))
|
||||
if (state_to_set != NOT_KILLED &&
|
||||
IF_WSREP(!wsrep_is_bf_aborted(this) && wsrep_abort_by_kill == NOT_KILLED,
|
||||
true))
|
||||
ha_kill_query(this, thd_kill_level(this));
|
||||
|
||||
abort_current_cond_wait(false);
|
||||
@ -2144,6 +2158,17 @@ void THD::reset_killed()
|
||||
mysql_mutex_unlock(&LOCK_thd_kill);
|
||||
}
|
||||
#ifdef WITH_WSREP
|
||||
if (WSREP_NNULL(this))
|
||||
{
|
||||
if (wsrep_abort_by_kill != NOT_KILLED)
|
||||
{
|
||||
mysql_mutex_assert_not_owner(&LOCK_thd_kill);
|
||||
mysql_mutex_lock(&LOCK_thd_kill);
|
||||
wsrep_abort_by_kill= NOT_KILLED;
|
||||
wsrep_abort_by_kill_err= 0;
|
||||
mysql_mutex_unlock(&LOCK_thd_kill);
|
||||
}
|
||||
}
|
||||
mysql_mutex_assert_not_owner(&LOCK_thd_data);
|
||||
mysql_mutex_lock(&LOCK_thd_data);
|
||||
wsrep_aborter= 0;
|
||||
|
@ -5402,7 +5402,14 @@ public:
|
||||
bool wsrep_ignore_table;
|
||||
/* thread who has started kill for this THD protected by LOCK_thd_data*/
|
||||
my_thread_id wsrep_aborter;
|
||||
|
||||
/* Kill signal used, if thread was killed by manual KILL. Protected by
|
||||
LOCK_thd_kill. */
|
||||
std::atomic<killed_state> wsrep_abort_by_kill;
|
||||
/* */
|
||||
struct err_info* wsrep_abort_by_kill_err;
|
||||
#ifndef DBUG_OFF
|
||||
int wsrep_killed_state;
|
||||
#endif /* DBUG_OFF */
|
||||
/* true if BF abort is observed in do_command() right after reading
|
||||
client's packet, and if the client has sent PS execute command. */
|
||||
bool wsrep_delayed_BF_abort;
|
||||
|
@ -7886,7 +7886,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
|
||||
thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit)
|
||||
{
|
||||
#ifdef ENABLED_DEBUG_SYNC
|
||||
DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit",
|
||||
DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit",
|
||||
{
|
||||
const char act[]=
|
||||
"now "
|
||||
@ -9248,23 +9248,20 @@ kill_one_thread(THD *thd, my_thread_id id, killed_state kill_signal, killed_type
|
||||
thd->security_ctx->user_matches(tmp->security_ctx))
|
||||
#endif /* WITH_WSREP */
|
||||
{
|
||||
{
|
||||
#ifdef WITH_WSREP
|
||||
DEBUG_SYNC(thd, "before_awake_no_mutex");
|
||||
if (tmp->wsrep_aborter && tmp->wsrep_aborter != thd->thread_id)
|
||||
{
|
||||
/* victim is in hit list already, bail out */
|
||||
WSREP_DEBUG("victim %lld has wsrep aborter: %lu, skipping awake()",
|
||||
id, tmp->wsrep_aborter);
|
||||
error= 0;
|
||||
}
|
||||
else
|
||||
if (WSREP(tmp))
|
||||
{
|
||||
error = wsrep_kill_thd(thd, tmp, kill_signal);
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif /* WITH_WSREP */
|
||||
{
|
||||
WSREP_DEBUG("kill_one_thread victim: %lld wsrep_aborter %lu"
|
||||
" by signal %d",
|
||||
id, tmp->wsrep_aborter, kill_signal);
|
||||
tmp->awake_no_mutex(kill_signal);
|
||||
error= 0;
|
||||
#ifdef WITH_WSREP
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -9387,18 +9384,6 @@ static
|
||||
void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type)
|
||||
{
|
||||
uint error;
|
||||
#ifdef WITH_WSREP
|
||||
if (WSREP(thd))
|
||||
{
|
||||
WSREP_DEBUG("sql_kill called");
|
||||
if (thd->wsrep_applier)
|
||||
{
|
||||
WSREP_DEBUG("KILL in applying, bailing out here");
|
||||
return;
|
||||
}
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
if (likely(!(error= kill_one_thread(thd, id, state, type))))
|
||||
{
|
||||
if (!thd->killed)
|
||||
@ -9408,11 +9393,6 @@ void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type)
|
||||
}
|
||||
else
|
||||
my_error(error, MYF(0), id);
|
||||
#ifdef WITH_WSREP
|
||||
return;
|
||||
wsrep_error_label:
|
||||
my_error(ER_KILL_DENIED_ERROR, MYF(0), (long long) thd->thread_id);
|
||||
#endif /* WITH_WSREP */
|
||||
}
|
||||
|
||||
|
||||
@ -9421,18 +9401,6 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
|
||||
{
|
||||
uint error;
|
||||
ha_rows rows;
|
||||
#ifdef WITH_WSREP
|
||||
if (WSREP(thd))
|
||||
{
|
||||
WSREP_DEBUG("sql_kill_user called");
|
||||
if (thd->wsrep_applier)
|
||||
{
|
||||
WSREP_DEBUG("KILL in applying, bailing out here");
|
||||
return;
|
||||
}
|
||||
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
switch (error= kill_threads_for_user(thd, user, state, &rows))
|
||||
{
|
||||
case 0:
|
||||
@ -9448,11 +9416,6 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state)
|
||||
default:
|
||||
my_error(error, MYF(0));
|
||||
}
|
||||
#ifdef WITH_WSREP
|
||||
return;
|
||||
wsrep_error_label:
|
||||
my_error(ER_KILL_DENIED_ERROR, MYF(0), (long long) thd->thread_id);
|
||||
#endif /* WITH_WSREP */
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,6 +151,7 @@ static struct wsrep_service_st wsrep_handler = {
|
||||
wsrep_on,
|
||||
wsrep_prepare_key_for_innodb,
|
||||
wsrep_thd_LOCK,
|
||||
wsrep_thd_TRYLOCK,
|
||||
wsrep_thd_UNLOCK,
|
||||
wsrep_thd_query,
|
||||
wsrep_thd_retry_counter,
|
||||
@ -179,7 +180,6 @@ static struct wsrep_service_st wsrep_handler = {
|
||||
wsrep_OSU_method_get,
|
||||
wsrep_thd_has_ignored_error,
|
||||
wsrep_thd_set_ignored_error,
|
||||
wsrep_thd_set_wsrep_aborter,
|
||||
wsrep_report_bf_lock_wait,
|
||||
wsrep_thd_kill_LOCK,
|
||||
wsrep_thd_kill_UNLOCK,
|
||||
|
@ -56,6 +56,11 @@ my_bool wsrep_on(const THD *)
|
||||
void wsrep_thd_LOCK(const THD *)
|
||||
{ }
|
||||
|
||||
int wsrep_thd_TRYLOCK(const THD *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wsrep_thd_UNLOCK(const THD *)
|
||||
{ }
|
||||
|
||||
@ -154,8 +159,6 @@ void wsrep_thd_set_ignored_error(THD*, my_bool)
|
||||
{ }
|
||||
ulong wsrep_OSU_method_get(const THD*)
|
||||
{ return 0;}
|
||||
bool wsrep_thd_set_wsrep_aborter(THD*, THD*)
|
||||
{ return 0;}
|
||||
|
||||
void wsrep_report_bf_lock_wait(const THD*,
|
||||
unsigned long long)
|
||||
|
@ -510,6 +510,7 @@ int Wsrep_high_priority_service::log_dummy_write_set(const wsrep::ws_handle& ws_
|
||||
m_thd->wait_for_prior_commit();
|
||||
}
|
||||
|
||||
WSREP_DEBUG("checkpointing dummy write set %lld", ws_meta.seqno().get());
|
||||
wsrep_set_SE_checkpoint(ws_meta.gtid(), wsrep_gtid_server.gtid());
|
||||
|
||||
if (!WSREP_EMULATE_BINLOG(m_thd))
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "log_event.h"
|
||||
#include "sql_connect.h"
|
||||
#include "thread_cache.h"
|
||||
#include "debug_sync.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@ -3037,7 +3038,22 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
request_thd, granted_thd);
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
|
||||
DEBUG_SYNC(request_thd, "before_wsrep_thd_abort");
|
||||
DBUG_EXECUTE_IF("sync.before_wsrep_thd_abort", {
|
||||
const char act[]= "now "
|
||||
"SIGNAL sync.before_wsrep_thd_abort_reached "
|
||||
"WAIT_FOR signal.before_wsrep_thd_abort";
|
||||
DBUG_ASSERT(!debug_sync_set_action(request_thd, STRING_WITH_LEN(act)));
|
||||
};);
|
||||
|
||||
/* Here we will call wsrep_abort_transaction so we should hold
|
||||
THD::LOCK_thd_data to protect victim from concurrent usage
|
||||
and THD::LOCK_thd_kill to protect from disconnect or delete.
|
||||
|
||||
*/
|
||||
mysql_mutex_lock(&granted_thd->LOCK_thd_kill);
|
||||
mysql_mutex_lock(&granted_thd->LOCK_thd_data);
|
||||
|
||||
if (wsrep_thd_is_toi(granted_thd) ||
|
||||
wsrep_thd_is_applying(granted_thd))
|
||||
{
|
||||
@ -3045,13 +3061,11 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
{
|
||||
WSREP_DEBUG("BF thread waiting for SR in aborting state");
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
}
|
||||
else if (wsrep_thd_is_SR(granted_thd) && !wsrep_thd_is_SR(request_thd))
|
||||
{
|
||||
WSREP_MDL_LOG(INFO, "MDL conflict, DDL vs SR",
|
||||
schema, schema_len, request_thd, granted_thd);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
wsrep_abort_thd(request_thd, granted_thd, 1);
|
||||
}
|
||||
else
|
||||
@ -3060,6 +3074,7 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
request_thd, granted_thd);
|
||||
ticket->wsrep_report(true);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
|
||||
unireg_abort(1);
|
||||
}
|
||||
}
|
||||
@ -3068,7 +3083,6 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
{
|
||||
WSREP_DEBUG("BF thread waiting for FLUSH");
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
if (granted_thd->current_backup_stage != BACKUP_FINISHED &&
|
||||
wsrep_check_mode(WSREP_MODE_BF_MARIABACKUP))
|
||||
{
|
||||
@ -3080,7 +3094,6 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
WSREP_DEBUG("DROP caused BF abort, conf %s",
|
||||
wsrep_thd_transaction_state_str(granted_thd));
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
wsrep_abort_thd(request_thd, granted_thd, 1);
|
||||
}
|
||||
else
|
||||
@ -3090,7 +3103,6 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
ticket->wsrep_report(wsrep_debug);
|
||||
if (granted_thd->wsrep_trx().active())
|
||||
{
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
wsrep_abort_thd(request_thd, granted_thd, 1);
|
||||
}
|
||||
else
|
||||
@ -3099,9 +3111,9 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
Granted_thd is likely executing with wsrep_on=0. If the requesting
|
||||
thd is BF, BF abort and wait.
|
||||
*/
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
if (wsrep_thd_is_BF(request_thd, FALSE))
|
||||
{
|
||||
granted_thd->awake_no_mutex(KILL_QUERY_HARD);
|
||||
ha_abort_transaction(request_thd, granted_thd, TRUE);
|
||||
}
|
||||
else
|
||||
@ -3109,10 +3121,14 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
WSREP_MDL_LOG(INFO, "MDL unknown BF-BF conflict", schema, schema_len,
|
||||
request_thd, granted_thd);
|
||||
ticket->wsrep_report(true);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
|
||||
unireg_abort(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_data);
|
||||
mysql_mutex_unlock(&granted_thd->LOCK_thd_kill);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -3124,13 +3140,17 @@ void wsrep_handle_mdl_conflict(MDL_context *requestor_ctx,
|
||||
static bool abort_replicated(THD *thd)
|
||||
{
|
||||
bool ret_code= false;
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill);
|
||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
if (thd->wsrep_trx().state() == wsrep::transaction::s_committing)
|
||||
{
|
||||
WSREP_DEBUG("aborting replicated trx: %llu", (ulonglong)(thd->real_id));
|
||||
|
||||
(void)wsrep_abort_thd(thd, thd, TRUE);
|
||||
wsrep_abort_thd(thd, thd, TRUE);
|
||||
ret_code= true;
|
||||
}
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_kill);
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
@ -148,9 +148,13 @@ void Wsrep_server_service::release_high_priority_service(wsrep::high_priority_se
|
||||
wsrep_delete_threadvars();
|
||||
}
|
||||
|
||||
void Wsrep_server_service::background_rollback(wsrep::client_state& client_state)
|
||||
void Wsrep_server_service::background_rollback(
|
||||
wsrep::unique_lock<wsrep::mutex> &lock WSREP_UNUSED,
|
||||
wsrep::client_state &client_state)
|
||||
{
|
||||
Wsrep_client_state& cs= static_cast<Wsrep_client_state&>(client_state);
|
||||
DBUG_ASSERT(lock.owns_lock());
|
||||
Wsrep_client_state &cs= static_cast<Wsrep_client_state &>(client_state);
|
||||
mysql_mutex_assert_owner(&cs.thd()->LOCK_thd_data);
|
||||
wsrep_fire_rollbacker(cs.thd());
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,8 @@ public:
|
||||
|
||||
void release_high_priority_service(wsrep::high_priority_service*);
|
||||
|
||||
void background_rollback(wsrep::client_state&);
|
||||
void background_rollback(wsrep::unique_lock<wsrep::mutex> &,
|
||||
wsrep::client_state &);
|
||||
|
||||
void bootstrap();
|
||||
void log_message(enum wsrep::log::level, const char*);
|
||||
|
204
sql/wsrep_thd.cc
204
sql/wsrep_thd.cc
@ -307,48 +307,9 @@ void wsrep_fire_rollbacker(THD *thd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int wsrep_abort_thd(THD *bf_thd,
|
||||
THD *victim_thd,
|
||||
my_bool signal)
|
||||
static bool wsrep_bf_abort_low(THD *bf_thd, THD *victim_thd)
|
||||
{
|
||||
DBUG_ENTER("wsrep_abort_thd");
|
||||
|
||||
mysql_mutex_lock(&victim_thd->LOCK_thd_data);
|
||||
|
||||
/* Note that when you use RSU node is desynced from cluster, thus WSREP(thd)
|
||||
might not be true.
|
||||
*/
|
||||
if ((WSREP_NNULL(bf_thd) ||
|
||||
((WSREP_ON || bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU) &&
|
||||
wsrep_thd_is_toi(bf_thd))) &&
|
||||
!wsrep_thd_is_aborting(victim_thd))
|
||||
{
|
||||
WSREP_DEBUG("wsrep_abort_thd, by: %llu, victim: %llu",
|
||||
(long long)bf_thd->real_id, (long long)victim_thd->real_id);
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
ha_abort_transaction(bf_thd, victim_thd, signal);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
WSREP_DEBUG("wsrep_abort_thd not effective: bf %llu victim %llu "
|
||||
"wsrep %d wsrep_on %d RSU %d TOI %d aborting %d",
|
||||
(long long)bf_thd->real_id, (long long)victim_thd->real_id,
|
||||
WSREP_NNULL(bf_thd), WSREP_ON,
|
||||
bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU,
|
||||
wsrep_thd_is_toi(bf_thd),
|
||||
wsrep_thd_is_aborting(victim_thd));
|
||||
}
|
||||
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd)
|
||||
{
|
||||
WSREP_LOG_THD(bf_thd, "BF aborter before");
|
||||
WSREP_LOG_THD(victim_thd, "victim before");
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
|
||||
#ifdef ENABLED_DEBUG_SYNC
|
||||
DBUG_EXECUTE_IF("sync.wsrep_bf_abort",
|
||||
@ -362,6 +323,85 @@ bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd)
|
||||
};);
|
||||
#endif
|
||||
|
||||
wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno());
|
||||
bool ret;
|
||||
|
||||
{
|
||||
/* Adopt the lock, it is being held by the caller. */
|
||||
Wsrep_mutex wsm{&victim_thd->LOCK_thd_data};
|
||||
wsrep::unique_lock<wsrep::mutex> lock{wsm, std::adopt_lock};
|
||||
|
||||
if (wsrep_thd_is_toi(bf_thd))
|
||||
{
|
||||
ret= victim_thd->wsrep_cs().total_order_bf_abort(lock, bf_seqno);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBUG_ASSERT(WSREP(victim_thd) ? victim_thd->wsrep_trx().active() : 1);
|
||||
ret= victim_thd->wsrep_cs().bf_abort(lock, bf_seqno);
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
/* BF abort should be allowed only once by wsrep-lib.*/
|
||||
DBUG_ASSERT(victim_thd->wsrep_aborter == 0);
|
||||
victim_thd->wsrep_aborter= bf_thd->thread_id;
|
||||
wsrep_bf_aborts_counter++;
|
||||
}
|
||||
lock.release(); /* No unlock at the end of the scope. */
|
||||
}
|
||||
|
||||
/* Sanity check for wsrep-lib calls to return with LOCK_thd_data held. */
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wsrep_abort_thd(THD *bf_thd,
|
||||
THD *victim_thd,
|
||||
my_bool signal)
|
||||
{
|
||||
DBUG_ENTER("wsrep_abort_thd");
|
||||
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_kill);
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
|
||||
/* Note that when you use RSU node is desynced from cluster, thus WSREP(thd)
|
||||
might not be true.
|
||||
*/
|
||||
if ((WSREP(bf_thd)
|
||||
|| ((WSREP_ON || bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU)
|
||||
&& wsrep_thd_is_toi(bf_thd))
|
||||
|| bf_thd->lex->sql_command == SQLCOM_KILL)
|
||||
&& !wsrep_thd_is_aborting(victim_thd) &&
|
||||
wsrep_bf_abort_low(bf_thd, victim_thd) &&
|
||||
!victim_thd->wsrep_cs().is_rollbacker_active())
|
||||
{
|
||||
WSREP_DEBUG("wsrep_abort_thd, by: %llu, victim: %llu",
|
||||
(long long)bf_thd->real_id, (long long)victim_thd->real_id);
|
||||
victim_thd->awake_no_mutex(KILL_QUERY_HARD);
|
||||
ha_abort_transaction(bf_thd, victim_thd, signal);
|
||||
}
|
||||
else
|
||||
{
|
||||
WSREP_DEBUG("wsrep_abort_thd not effective: bf %llu victim %llu "
|
||||
"wsrep %d wsrep_on %d RSU %d TOI %d aborting %d",
|
||||
(long long)bf_thd->real_id, (long long)victim_thd->real_id,
|
||||
WSREP_NNULL(bf_thd), WSREP_ON,
|
||||
bf_thd->variables.wsrep_OSU_method == WSREP_OSU_RSU,
|
||||
wsrep_thd_is_toi(bf_thd),
|
||||
wsrep_thd_is_aborting(victim_thd));
|
||||
}
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd)
|
||||
{
|
||||
WSREP_LOG_THD(bf_thd, "BF aborter before");
|
||||
WSREP_LOG_THD(victim_thd, "victim before");
|
||||
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
|
||||
if (WSREP(victim_thd) && !victim_thd->wsrep_trx().active())
|
||||
{
|
||||
WSREP_DEBUG("wsrep_bf_abort, BF abort for non active transaction."
|
||||
@ -384,30 +424,84 @@ bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd)
|
||||
wsrep_check_mode(WSREP_MODE_BF_MARIABACKUP))
|
||||
{
|
||||
WSREP_DEBUG("killing connection for non wsrep session");
|
||||
mysql_mutex_lock(&victim_thd->LOCK_thd_data);
|
||||
victim_thd->awake_no_mutex(KILL_CONNECTION);
|
||||
mysql_mutex_unlock(&victim_thd->LOCK_thd_data);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret;
|
||||
wsrep::seqno bf_seqno(bf_thd->wsrep_trx().ws_meta().seqno());
|
||||
return wsrep_bf_abort_low(bf_thd, victim_thd);
|
||||
}
|
||||
|
||||
if (wsrep_thd_is_toi(bf_thd))
|
||||
uint wsrep_kill_thd(THD *thd, THD *victim_thd, killed_state kill_signal)
|
||||
{
|
||||
DBUG_ENTER("wsrep_kill_thd");
|
||||
DBUG_ASSERT(WSREP(victim_thd));
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_kill);
|
||||
mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data);
|
||||
using trans= wsrep::transaction;
|
||||
auto trx_state= victim_thd->wsrep_trx().state();
|
||||
#ifndef DBUG_OFF
|
||||
victim_thd->wsrep_killed_state= trx_state;
|
||||
#endif /* DBUG_OFF */
|
||||
/*
|
||||
Already killed or in commit codepath. Mark the victim as killed,
|
||||
the killed status will be restored in wsrep_after_commit() and
|
||||
will be processed after the commit is over. In case of multiple
|
||||
KILLs happened on commit codepath, the last one will be effective.
|
||||
*/
|
||||
if (victim_thd->wsrep_abort_by_kill ||
|
||||
trx_state == trans::s_preparing ||
|
||||
trx_state == trans::s_committing ||
|
||||
trx_state == trans::s_ordered_commit)
|
||||
{
|
||||
ret= victim_thd->wsrep_cs().total_order_bf_abort(bf_seqno);
|
||||
victim_thd->wsrep_abort_by_kill= kill_signal;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
else
|
||||
/*
|
||||
Mark killed victim_thd with kill_signal so that awake_no_mutex does
|
||||
not dive into storage engine. We use ha_abort_transaction()
|
||||
to do the storage engine part for wsrep THDs.
|
||||
*/
|
||||
DEBUG_SYNC(thd, "wsrep_kill_before_awake_no_mutex");
|
||||
victim_thd->wsrep_abort_by_kill= kill_signal;
|
||||
victim_thd->awake_no_mutex(kill_signal);
|
||||
/* ha_abort_transaction() releases tmp->LOCK_thd_kill, so tmp
|
||||
is not safe to access anymore. */
|
||||
ha_abort_transaction(thd, victim_thd, 1);
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
void wsrep_backup_kill_for_commit(THD *thd)
|
||||
{
|
||||
DBUG_ASSERT(WSREP(thd));
|
||||
mysql_mutex_assert_owner(&thd->LOCK_thd_kill);
|
||||
DBUG_ASSERT(thd->killed != NOT_KILLED);
|
||||
mysql_mutex_lock(&thd->LOCK_thd_data);
|
||||
/* If the transaction will roll back, keep the killed state.
|
||||
For must replay, the replay will happen in different THD context
|
||||
which is high priority and cannot be killed. The owning thread will
|
||||
pick the killed state in after statement processing. */
|
||||
if (thd->wsrep_trx().state() != wsrep::transaction::s_cert_failed &&
|
||||
thd->wsrep_trx().state() != wsrep::transaction::s_must_abort &&
|
||||
thd->wsrep_trx().state() != wsrep::transaction::s_aborting &&
|
||||
thd->wsrep_trx().state() != wsrep::transaction::s_must_replay)
|
||||
{
|
||||
DBUG_ASSERT(WSREP(victim_thd) ? victim_thd->wsrep_trx().active() : 1);
|
||||
ret= victim_thd->wsrep_cs().bf_abort(bf_seqno);
|
||||
thd->wsrep_abort_by_kill= thd->killed;
|
||||
thd->wsrep_abort_by_kill_err= thd->killed_err;
|
||||
thd->killed= NOT_KILLED;
|
||||
thd->killed_err= 0;
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
wsrep_bf_aborts_counter++;
|
||||
}
|
||||
return ret;
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_data);
|
||||
}
|
||||
|
||||
void wsrep_restore_kill_after_commit(THD *thd)
|
||||
{
|
||||
DBUG_ASSERT(WSREP(thd));
|
||||
mysql_mutex_assert_owner(&thd->LOCK_thd_kill);
|
||||
thd->killed= thd->wsrep_abort_by_kill;
|
||||
thd->killed_err= thd->wsrep_abort_by_kill_err;
|
||||
thd->wsrep_abort_by_kill= NOT_KILLED;
|
||||
thd->wsrep_abort_by_kill_err= 0;
|
||||
}
|
||||
|
||||
int wsrep_create_threadvars()
|
||||
|
@ -88,10 +88,39 @@ bool wsrep_create_appliers(long threads, bool mutex_protected=false);
|
||||
void wsrep_create_rollbacker();
|
||||
|
||||
bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd);
|
||||
int wsrep_abort_thd(THD *bf_thd,
|
||||
/*
|
||||
Abort transaction for victim_thd. This function is called from
|
||||
MDL BF abort codepath.
|
||||
*/
|
||||
void wsrep_abort_thd(THD *bf_thd,
|
||||
THD *victim_thd,
|
||||
my_bool signal) __attribute__((nonnull(1,2)));
|
||||
|
||||
/**
|
||||
Kill wsrep connection with kill_signal. Object thd is not
|
||||
guaranteed to exist anymore when this function returns.
|
||||
|
||||
Asserts that the caller holds victim_thd->LOCK_thd_kill,
|
||||
victim_thd->LOCK_thd_data.
|
||||
|
||||
@param thd THD object for connection that executes the KILL.
|
||||
@param victim_thd THD object for connection to be killed.
|
||||
@param kill_signal Kill signal.
|
||||
|
||||
@return Zero if the kill was successful, otherwise non-zero error code.
|
||||
*/
|
||||
uint wsrep_kill_thd(THD *thd, THD *victim_thd, killed_state kill_signal);
|
||||
|
||||
/*
|
||||
Backup kill status for commit.
|
||||
*/
|
||||
void wsrep_backup_kill_for_commit(THD *);
|
||||
|
||||
/*
|
||||
Restore KILL status after commit.
|
||||
*/
|
||||
void wsrep_restore_kill_after_commit(THD *);
|
||||
|
||||
/*
|
||||
Helper methods to deal with thread local storage.
|
||||
The purpose of these methods is to hide the details of thread
|
||||
|
@ -256,6 +256,11 @@ static inline int wsrep_before_prepare(THD* thd, bool all)
|
||||
thd->wsrep_trx().ws_meta().gtid(),
|
||||
wsrep_gtid_server.gtid());
|
||||
}
|
||||
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill);
|
||||
if (thd->killed) wsrep_backup_kill_for_commit(thd);
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_kill);
|
||||
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
@ -323,6 +328,11 @@ static inline int wsrep_before_commit(THD* thd, bool all)
|
||||
wsrep_gtid_server.gtid());
|
||||
wsrep_register_for_group_commit(thd);
|
||||
}
|
||||
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill);
|
||||
if (thd->killed) wsrep_backup_kill_for_commit(thd);
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_kill);
|
||||
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
@ -341,7 +351,8 @@ static inline int wsrep_before_commit(THD* thd, bool all)
|
||||
static inline int wsrep_ordered_commit(THD* thd, bool all)
|
||||
{
|
||||
DBUG_ENTER("wsrep_ordered_commit");
|
||||
WSREP_DEBUG("wsrep_ordered_commit: %d", wsrep_is_real(thd, all));
|
||||
WSREP_DEBUG("wsrep_ordered_commit: %d %lld", wsrep_is_real(thd, all),
|
||||
(long long) wsrep_thd_trx_seqno(thd));
|
||||
DBUG_ASSERT(wsrep_run_commit_hook(thd, all));
|
||||
DBUG_RETURN(thd->wsrep_cs().ordered_commit());
|
||||
}
|
||||
@ -449,10 +460,18 @@ int wsrep_after_statement(THD* thd)
|
||||
wsrep::to_c_string(thd->wsrep_cs().state()),
|
||||
wsrep::to_c_string(thd->wsrep_cs().mode()),
|
||||
wsrep::to_c_string(thd->wsrep_cs().transaction().state()));
|
||||
DBUG_RETURN((thd->wsrep_cs().state() != wsrep::client_state::s_none &&
|
||||
int ret= ((thd->wsrep_cs().state() != wsrep::client_state::s_none &&
|
||||
thd->wsrep_cs().mode() == Wsrep_client_state::m_local) &&
|
||||
!thd->internal_transaction() ?
|
||||
thd->wsrep_cs().after_statement() : 0);
|
||||
|
||||
if (wsrep_is_active(thd))
|
||||
{
|
||||
mysql_mutex_lock(&thd->LOCK_thd_kill);
|
||||
wsrep_restore_kill_after_commit(thd);
|
||||
mysql_mutex_unlock(&thd->LOCK_thd_kill);
|
||||
}
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
||||
static inline void wsrep_after_apply(THD* thd)
|
||||
|
@ -1987,8 +1987,9 @@ static void innodb_disable_internal_writes(bool disable)
|
||||
sst_enable_innodb_writes();
|
||||
}
|
||||
|
||||
static void wsrep_abort_transaction(handlerton*, THD *, THD *, my_bool);
|
||||
static int innobase_wsrep_set_checkpoint(handlerton* hton, const XID* xid);
|
||||
static void wsrep_abort_transaction(handlerton *, THD *, THD *, my_bool)
|
||||
__attribute__((nonnull));
|
||||
static int innobase_wsrep_set_checkpoint(handlerton *hton, const XID *xid);
|
||||
static int innobase_wsrep_get_checkpoint(handlerton* hton, XID* xid);
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
@ -18672,36 +18673,45 @@ void lock_wait_wsrep_kill(trx_t *bf_trx, ulong thd_id, trx_id_t trx_id)
|
||||
wsrep_thd_client_mode_str(vthd),
|
||||
wsrep_thd_transaction_state_str(vthd),
|
||||
wsrep_thd_query(vthd));
|
||||
/* Mark transaction as a victim for Galera abort */
|
||||
vtrx->lock.set_wsrep_victim();
|
||||
if (!wsrep_thd_set_wsrep_aborter(bf_thd, vthd))
|
||||
aborting= true;
|
||||
else
|
||||
WSREP_DEBUG("kill transaction skipped due to wsrep_aborter set");
|
||||
aborting= true;
|
||||
}
|
||||
}
|
||||
mysql_mutex_unlock(&lock_sys.wait_mutex);
|
||||
vtrx->mutex_unlock();
|
||||
}
|
||||
wsrep_thd_UNLOCK(vthd);
|
||||
if (aborting)
|
||||
|
||||
DEBUG_SYNC(bf_thd, "before_wsrep_thd_abort");
|
||||
if (aborting && wsrep_thd_bf_abort(bf_thd, vthd, true))
|
||||
{
|
||||
/* Need to grab mutexes again to ensure that the trx is still in
|
||||
right state. */
|
||||
lock_sys.wr_lock(SRW_LOCK_CALL);
|
||||
mysql_mutex_lock(&lock_sys.wait_mutex);
|
||||
vtrx->mutex_lock();
|
||||
|
||||
/* if victim is waiting for some other lock, we have to cancel
|
||||
that waiting
|
||||
*/
|
||||
lock_sys.cancel_lock_wait_for_trx(vtrx);
|
||||
|
||||
DEBUG_SYNC(bf_thd, "before_wsrep_thd_abort");
|
||||
if (!wsrep_thd_bf_abort(bf_thd, vthd, true))
|
||||
if (vtrx->id == trx_id)
|
||||
{
|
||||
wsrep_thd_LOCK(vthd);
|
||||
wsrep_thd_set_wsrep_aborter(NULL, vthd);
|
||||
wsrep_thd_UNLOCK(vthd);
|
||||
|
||||
WSREP_DEBUG("wsrep_thd_bf_abort has failed, victim %lu will survive",
|
||||
thd_get_thread_id(vthd));
|
||||
switch (vtrx->state) {
|
||||
default:
|
||||
break;
|
||||
case TRX_STATE_ACTIVE:
|
||||
case TRX_STATE_PREPARED:
|
||||
lock_sys.cancel_lock_wait_for_wsrep_bf_abort(vtrx);
|
||||
}
|
||||
}
|
||||
lock_sys.wr_unlock();
|
||||
mysql_mutex_unlock(&lock_sys.wait_mutex);
|
||||
vtrx->mutex_unlock();
|
||||
}
|
||||
else
|
||||
{
|
||||
WSREP_DEBUG("wsrep_thd_bf_abort has failed, victim %lu will survive",
|
||||
thd_get_thread_id(vthd));
|
||||
}
|
||||
wsrep_thd_UNLOCK(vthd);
|
||||
wsrep_thd_kill_UNLOCK(vthd);
|
||||
}
|
||||
}
|
||||
@ -18709,68 +18719,50 @@ void lock_wait_wsrep_kill(trx_t *bf_trx, ulong thd_id, trx_id_t trx_id)
|
||||
/** This function forces the victim transaction to abort. Aborting the
|
||||
transaction does NOT end it, it still has to be rolled back.
|
||||
|
||||
The caller must lock LOCK_thd_kill and LOCK_thd_data.
|
||||
|
||||
@param bf_thd brute force THD asking for the abort
|
||||
@param victim_thd victim THD to be aborted
|
||||
|
||||
@return 0 victim was aborted
|
||||
@return -1 victim thread was aborted (no transaction)
|
||||
*/
|
||||
static
|
||||
void
|
||||
wsrep_abort_transaction(
|
||||
handlerton*,
|
||||
THD *bf_thd,
|
||||
THD *victim_thd,
|
||||
my_bool signal)
|
||||
static void wsrep_abort_transaction(handlerton *, THD *bf_thd, THD *victim_thd,
|
||||
my_bool signal)
|
||||
{
|
||||
DBUG_ENTER("wsrep_abort_transaction");
|
||||
ut_ad(bf_thd);
|
||||
ut_ad(victim_thd);
|
||||
DBUG_ENTER("wsrep_abort_transaction");
|
||||
ut_ad(bf_thd);
|
||||
ut_ad(victim_thd);
|
||||
|
||||
wsrep_thd_kill_LOCK(victim_thd);
|
||||
wsrep_thd_LOCK(victim_thd);
|
||||
trx_t* victim_trx= thd_to_trx(victim_thd);
|
||||
wsrep_thd_UNLOCK(victim_thd);
|
||||
trx_t *victim_trx= thd_to_trx(victim_thd);
|
||||
|
||||
WSREP_DEBUG("abort transaction: BF: %s victim: %s victim conf: %s",
|
||||
wsrep_thd_query(bf_thd),
|
||||
wsrep_thd_query(victim_thd),
|
||||
wsrep_thd_transaction_state_str(victim_thd));
|
||||
WSREP_DEBUG("abort transaction: BF: %s victim: %s victim conf: %s",
|
||||
wsrep_thd_query(bf_thd), wsrep_thd_query(victim_thd),
|
||||
wsrep_thd_transaction_state_str(victim_thd));
|
||||
|
||||
if (victim_trx) {
|
||||
victim_trx->lock.set_wsrep_victim();
|
||||
if (!victim_trx)
|
||||
{
|
||||
WSREP_DEBUG("abort transaction: victim did not exist");
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
wsrep_thd_LOCK(victim_thd);
|
||||
bool aborting= !wsrep_thd_set_wsrep_aborter(bf_thd, victim_thd);
|
||||
wsrep_thd_UNLOCK(victim_thd);
|
||||
if (aborting) {
|
||||
DEBUG_SYNC(bf_thd, "before_wsrep_thd_abort");
|
||||
DBUG_EXECUTE_IF("sync.before_wsrep_thd_abort",
|
||||
{
|
||||
const char act[]=
|
||||
"now "
|
||||
"SIGNAL sync.before_wsrep_thd_abort_reached "
|
||||
"WAIT_FOR signal.before_wsrep_thd_abort";
|
||||
DBUG_ASSERT(!debug_sync_set_action(bf_thd,
|
||||
STRING_WITH_LEN(act)));
|
||||
};);
|
||||
wsrep_thd_bf_abort(bf_thd, victim_thd, signal);
|
||||
}
|
||||
} else {
|
||||
DBUG_EXECUTE_IF("sync.before_wsrep_thd_abort",
|
||||
{
|
||||
const char act[]=
|
||||
"now "
|
||||
"SIGNAL sync.before_wsrep_thd_abort_reached "
|
||||
"WAIT_FOR signal.before_wsrep_thd_abort";
|
||||
DBUG_ASSERT(!debug_sync_set_action(bf_thd,
|
||||
STRING_WITH_LEN(act)));
|
||||
};);
|
||||
wsrep_thd_bf_abort(bf_thd, victim_thd, signal);
|
||||
}
|
||||
lock_sys.wr_lock(SRW_LOCK_CALL);
|
||||
mysql_mutex_lock(&lock_sys.wait_mutex);
|
||||
victim_trx->mutex_lock();
|
||||
|
||||
wsrep_thd_kill_UNLOCK(victim_thd);
|
||||
DBUG_VOID_RETURN;
|
||||
switch (victim_trx->state) {
|
||||
default:
|
||||
break;
|
||||
case TRX_STATE_ACTIVE:
|
||||
case TRX_STATE_PREPARED:
|
||||
/* Cancel lock wait if the victim is waiting for a lock in InnoDB.
|
||||
The transaction which is blocked somewhere else (e.g. waiting
|
||||
for next command or MDL) has been interrupted by THD::awake_no_mutex()
|
||||
on server level before calling this function. */
|
||||
lock_sys.cancel_lock_wait_for_wsrep_bf_abort(victim_trx);
|
||||
}
|
||||
lock_sys.wr_unlock();
|
||||
mysql_mutex_unlock(&lock_sys.wait_mutex);
|
||||
victim_trx->mutex_unlock();
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -955,6 +955,10 @@ public:
|
||||
|
||||
/** Cancel possible lock waiting for a transaction */
|
||||
static void cancel_lock_wait_for_trx(trx_t *trx);
|
||||
#ifdef WITH_WSREP
|
||||
/** Cancel lock waiting for a wsrep BF abort. */
|
||||
static void cancel_lock_wait_for_wsrep_bf_abort(trx_t *trx);
|
||||
#endif /* WITH_WSREP */
|
||||
};
|
||||
|
||||
/** The lock system */
|
||||
|
@ -5732,13 +5732,14 @@ static void lock_release_autoinc_locks(trx_t *trx)
|
||||
}
|
||||
|
||||
/** Cancel a waiting lock request and release possibly waiting transactions */
|
||||
template <bool from_deadlock= false>
|
||||
template <bool from_deadlock= false, bool inner_trx_lock= true>
|
||||
void lock_cancel_waiting_and_release(lock_t *lock)
|
||||
{
|
||||
lock_sys.assert_locked(*lock);
|
||||
mysql_mutex_assert_owner(&lock_sys.wait_mutex);
|
||||
trx_t *trx= lock->trx;
|
||||
trx->mutex_lock();
|
||||
if (inner_trx_lock)
|
||||
trx->mutex_lock();
|
||||
ut_d(const auto trx_state= trx->state);
|
||||
ut_ad(trx_state == TRX_STATE_COMMITTED_IN_MEMORY ||
|
||||
trx_state == TRX_STATE_ACTIVE);
|
||||
@ -5762,7 +5763,8 @@ void lock_cancel_waiting_and_release(lock_t *lock)
|
||||
|
||||
lock_wait_end<from_deadlock>(trx);
|
||||
|
||||
trx->mutex_unlock();
|
||||
if (inner_trx_lock)
|
||||
trx->mutex_unlock();
|
||||
}
|
||||
|
||||
void lock_sys_t::cancel_lock_wait_for_trx(trx_t *trx)
|
||||
@ -5779,6 +5781,19 @@ void lock_sys_t::cancel_lock_wait_for_trx(trx_t *trx)
|
||||
mysql_mutex_unlock(&lock_sys.wait_mutex);
|
||||
}
|
||||
|
||||
#ifdef WITH_WSREP
|
||||
void lock_sys_t::cancel_lock_wait_for_wsrep_bf_abort(trx_t *trx)
|
||||
{
|
||||
lock_sys.assert_locked();
|
||||
mysql_mutex_assert_owner(&lock_sys.wait_mutex);
|
||||
ut_ad(trx->mutex_is_owner());
|
||||
ut_ad(trx->state == TRX_STATE_ACTIVE || trx->state == TRX_STATE_PREPARED);
|
||||
trx->lock.set_wsrep_victim();
|
||||
if (lock_t *lock= trx->lock.wait_lock)
|
||||
lock_cancel_waiting_and_release<false, false>(lock);
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
/** Cancel a waiting lock request.
|
||||
@tparam check_victim whether to check for DB_DEADLOCK
|
||||
@param trx active transaction
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 4951c38357737d568b554402bc5b6abe88a38fe1
|
||||
Subproject commit e238c0d240c2557229b0523a4a032f3cf8b41639
|
Loading…
x
Reference in New Issue
Block a user