Commit edbdfc2f authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-7962 wsrep_on() takes 0.14% in OLTP RO

The function wsrep_on() was being called rather frequently
in InnoDB and XtraDB. Let us cache it in trx_t and invoke
trx_t::is_wsrep() instead.

innobase_trx_init(): Cache trx->wsrep = wsrep_on(thd).

ha_innobase::write_row(): Replace many repeated calls to current_thd,
and test the cheapest condition first.
parent dd4124c2
This diff is collapsed.
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1008,10 +1009,6 @@ std::string ...@@ -1008,10 +1009,6 @@ std::string
lock_get_info( lock_get_info(
const lock_t*); const lock_t*);
/*******************************************************************//**
@return whether wsrep_on is true on trx->mysql_thd*/
#define wsrep_on_trx(trx) ((trx)->mysql_thd && wsrep_on((trx)->mysql_thd))
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "lock0lock.ic" #include "lock0lock.ic"
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2019, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -769,15 +769,21 @@ struct trx_t{ ...@@ -769,15 +769,21 @@ struct trx_t{
ro_trx_list the first time they try to acquire a lock ie. by default ro_trx_list the first time they try to acquire a lock ie. by default
we treat all read-only transactions as non-locking. */ we treat all read-only transactions as non-locking. */
trx_state_t state; trx_state_t state;
trx_lock_t lock; /*!< Information about the transaction trx_lock_t lock; /*!< Information about the transaction
locks and state. Protected by locks and state. Protected by
trx->mutex or lock_sys->mutex trx->mutex or lock_sys->mutex
or both */ or both */
ulint is_recovered; /*!< 0=normal transaction, bool is_recovered; /*!< false=normal transaction,
1=recovered, must be rolled back, true=recovered, must be rolled back,
protected by trx_sys->mutex when protected by trx_sys->mutex when
trx->in_rw_trx_list holds */ trx->in_rw_trx_list holds */
#ifdef WITH_WSREP
/** whether wsrep_on(mysql_thd) held at the start of transaction */
bool wsrep;
bool is_wsrep() const { return UNIV_UNLIKELY(wsrep); }
#else /* WITH_WSREP */
bool is_wsrep() const { return false; }
#endif /* WITH_WSREP */
/* These fields are not protected by any mutex. */ /* These fields are not protected by any mutex. */
const char* op_info; /*!< English text describing the const char* op_info; /*!< English text describing the
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1759,7 +1759,7 @@ wsrep_kill_victim( ...@@ -1759,7 +1759,7 @@ wsrep_kill_victim(
ut_ad(trx_mutex_own(lock->trx)); ut_ad(trx_mutex_own(lock->trx));
/* quit for native mysql */ /* quit for native mysql */
if (!wsrep_on(trx->mysql_thd)) return; if (!trx->is_wsrep()) return;
my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE);
my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE);
...@@ -1845,7 +1845,7 @@ lock_rec_other_has_conflicting( ...@@ -1845,7 +1845,7 @@ lock_rec_other_has_conflicting(
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) {
if (wsrep_on_trx(trx)) { if (trx->is_wsrep()) {
trx_mutex_enter(lock->trx); trx_mutex_enter(lock->trx);
/* Below function will roll back either trx /* Below function will roll back either trx
or lock->trx depending on priority of the or lock->trx depending on priority of the
...@@ -2179,8 +2179,7 @@ lock_rec_create( ...@@ -2179,8 +2179,7 @@ lock_rec_create(
ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && if (c_lock && trx->is_wsrep() &&
wsrep_on_trx(trx) &&
wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
lock_t *hash = (lock_t *)c_lock->hash; lock_t *hash = (lock_t *)c_lock->hash;
lock_t *prev = NULL; lock_t *prev = NULL;
...@@ -4973,7 +4972,7 @@ lock_table_create( ...@@ -4973,7 +4972,7 @@ lock_table_create(
UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && wsrep_on_trx(trx)) { if (c_lock && trx->is_wsrep()) {
if (wsrep_thd_is_wsrep(trx->mysql_thd) if (wsrep_thd_is_wsrep(trx->mysql_thd)
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
UT_LIST_INSERT_AFTER( UT_LIST_INSERT_AFTER(
...@@ -5212,7 +5211,7 @@ lock_table_enqueue_waiting( ...@@ -5212,7 +5211,7 @@ lock_table_enqueue_waiting(
/* Enqueue the lock request that will wait to be granted */ /* Enqueue the lock request that will wait to be granted */
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (trx->lock.was_chosen_as_deadlock_victim && wsrep_on_trx(trx)) { if (trx->lock.was_chosen_as_deadlock_victim && trx->is_wsrep()) {
return(DB_DEADLOCK); return(DB_DEADLOCK);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -200,8 +200,7 @@ wsrep_is_BF_lock_timeout( ...@@ -200,8 +200,7 @@ wsrep_is_BF_lock_timeout(
const trx_t* trx, const trx_t* trx,
bool locked = true) bool locked = true)
{ {
if (wsrep_on_trx(trx) if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
fprintf(stderr, "WSREP: BF lock wait long for trx " TRX_ID_FMT "\n", trx->id); fprintf(stderr, "WSREP: BF lock wait long for trx " TRX_ID_FMT "\n", trx->id);
srv_print_innodb_monitor = TRUE; srv_print_innodb_monitor = TRUE;
srv_print_innodb_lock_monitor = TRUE; srv_print_innodb_lock_monitor = TRUE;
...@@ -390,7 +389,7 @@ lock_wait_suspend_thread( ...@@ -390,7 +389,7 @@ lock_wait_suspend_thread(
if (lock_wait_timeout < 100000000 if (lock_wait_timeout < 100000000
&& wait_time > (double) lock_wait_timeout) { && wait_time > (double) lock_wait_timeout) {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!wsrep_on_trx(trx) || if (!trx->is_wsrep() ||
(!wsrep_is_BF_lock_timeout(trx) && (!wsrep_is_BF_lock_timeout(trx) &&
trx->error_state != DB_DEADLOCK)) { trx->error_state != DB_DEADLOCK)) {
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2019, MariaDB Corporation. Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1639,7 +1639,7 @@ row_ins_check_foreign_constraint( ...@@ -1639,7 +1639,7 @@ row_ins_check_foreign_constraint(
if (check_ref) { if (check_ref) {
err = DB_SUCCESS; err = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!wsrep_on(trx->mysql_thd)) { if (!trx->is_wsrep()) {
goto end_scan; goto end_scan;
} }
enum wsrep_key_type key_type; enum wsrep_key_type key_type;
......
...@@ -1125,7 +1125,7 @@ row_update_statistics_if_needed( ...@@ -1125,7 +1125,7 @@ row_update_statistics_if_needed(
&& dict_stats_auto_recalc_is_enabled(table)) { && dict_stats_auto_recalc_is_enabled(table)) {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() &&
wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
WSREP_DEBUG("Avoiding background statistics" WSREP_DEBUG("Avoiding background statistics"
" calculation for table %s", " calculation for table %s",
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2019, MariaDB Corporation. Copyright (c) 2018, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1811,7 +1811,7 @@ row_upd_store_row( ...@@ -1811,7 +1811,7 @@ row_upd_store_row(
inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{ {
if (!wsrep_on_trx(trx)) { if (!trx->is_wsrep()) {
return false; return false;
} }
return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved. Copyright (c) 2017, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -213,8 +213,7 @@ srv_conc_enter_innodb_with_atomics( ...@@ -213,8 +213,7 @@ srv_conc_enter_innodb_with_atomics(
for (;;) { for (;;) {
ulint sleep_in_us; ulint sleep_in_us;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_trx_is_aborting(trx->mysql_thd)) {
wsrep_trx_is_aborting(trx->mysql_thd)) {
if (wsrep_debug) if (wsrep_debug)
fprintf(stderr, fprintf(stderr,
"srv_conc_enter due to MUST_ABORT"); "srv_conc_enter due to MUST_ABORT");
...@@ -421,8 +420,7 @@ srv_conc_enter_innodb_without_atomics( ...@@ -421,8 +420,7 @@ srv_conc_enter_innodb_without_atomics(
return; return;
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_thd_is_brute_force(trx->mysql_thd)) {
wsrep_thd_is_brute_force(trx->mysql_thd)) {
srv_conc_force_enter_innodb(trx); srv_conc_force_enter_innodb(trx);
return; return;
} }
...@@ -504,8 +502,7 @@ srv_conc_enter_innodb_without_atomics( ...@@ -504,8 +502,7 @@ srv_conc_enter_innodb_without_atomics(
srv_conc.n_waiting++; srv_conc.n_waiting++;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_trx_is_aborting(trx->mysql_thd)) {
wsrep_trx_is_aborting(trx->mysql_thd)) {
os_fast_mutex_unlock(&srv_conc_mutex); os_fast_mutex_unlock(&srv_conc_mutex);
if (wsrep_debug) if (wsrep_debug)
fprintf(stderr, "srv_conc_enter due to MUST_ABORT"); fprintf(stderr, "srv_conc_enter due to MUST_ABORT");
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2019, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1331,11 +1331,7 @@ trx_commit_in_memory( ...@@ -1331,11 +1331,7 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list); ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list); ut_ad(!trx->in_rw_trx_list);
#ifdef WITH_WSREP trx->lock.was_chosen_as_deadlock_victim = FALSE;
if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
trx->lock.was_chosen_as_deadlock_victim = FALSE;
}
#endif
trx->dict_operation = TRX_DICT_OP_NONE; trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
......
This diff is collapsed.
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1013,8 +1014,6 @@ std::string ...@@ -1013,8 +1014,6 @@ std::string
lock_get_info( lock_get_info(
const lock_t*); const lock_t*);
#define wsrep_on_trx(trx) ((trx)->mysql_thd && wsrep_on((trx)->mysql_thd))
#ifndef UNIV_NONINL #ifndef UNIV_NONINL
#include "lock0lock.ic" #include "lock0lock.ic"
#endif #endif
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2019, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -818,15 +818,21 @@ struct trx_t{ ...@@ -818,15 +818,21 @@ struct trx_t{
ro_trx_list the first time they try to acquire a lock ie. by default ro_trx_list the first time they try to acquire a lock ie. by default
we treat all read-only transactions as non-locking. */ we treat all read-only transactions as non-locking. */
trx_state_t state; trx_state_t state;
trx_lock_t lock; /*!< Information about the transaction trx_lock_t lock; /*!< Information about the transaction
locks and state. Protected by locks and state. Protected by
trx->mutex or lock_sys->mutex trx->mutex or lock_sys->mutex
or both */ or both */
ulint is_recovered; /*!< 0=normal transaction, bool is_recovered; /*!< false=normal transaction,
1=recovered, must be rolled back, true=recovered, must be rolled back,
protected by trx_sys->mutex when protected by trx_sys->mutex when
trx->in_rw_trx_list holds */ trx->in_rw_trx_list holds */
#ifdef WITH_WSREP
/** whether wsrep_on(mysql_thd) held at the start of transaction */
bool wsrep;
bool is_wsrep() const { return UNIV_UNLIKELY(wsrep); }
#else /* WITH_WSREP */
bool is_wsrep() const { return false; }
#endif /* WITH_WSREP */
/* These fields are not protected by any mutex. */ /* These fields are not protected by any mutex. */
const char* op_info; /*!< English text describing the const char* op_info; /*!< English text describing the
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1770,7 +1770,7 @@ wsrep_kill_victim( ...@@ -1770,7 +1770,7 @@ wsrep_kill_victim(
ut_ad(trx_mutex_own(lock->trx)); ut_ad(trx_mutex_own(lock->trx));
/* quit for native mysql */ /* quit for native mysql */
if (!wsrep_on(trx->mysql_thd)) return; if (!trx->is_wsrep()) return;
my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE); my_bool bf_this = wsrep_thd_is_BF(trx->mysql_thd, FALSE);
my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE); my_bool bf_other = wsrep_thd_is_BF(lock->trx->mysql_thd, TRUE);
...@@ -1856,7 +1856,7 @@ lock_rec_other_has_conflicting( ...@@ -1856,7 +1856,7 @@ lock_rec_other_has_conflicting(
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) { if (lock_rec_has_to_wait(TRUE, trx, mode, lock, is_supremum)) {
if (wsrep_on_trx(trx)) { if (trx->is_wsrep()) {
trx_mutex_enter(lock->trx); trx_mutex_enter(lock->trx);
/* Below function will roll back either trx /* Below function will roll back either trx
or lock->trx depending on priority of the or lock->trx depending on priority of the
...@@ -2318,8 +2318,7 @@ lock_rec_create( ...@@ -2318,8 +2318,7 @@ lock_rec_create(
ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted); ut_ad(index->table->n_ref_count > 0 || !index->table->can_be_evicted);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && if (c_lock && trx->is_wsrep() &&
wsrep_on_trx(trx) &&
wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
lock_t *hash = (lock_t *)c_lock->hash; lock_t *hash = (lock_t *)c_lock->hash;
lock_t *prev = NULL; lock_t *prev = NULL;
...@@ -5009,7 +5008,7 @@ lock_table_create( ...@@ -5009,7 +5008,7 @@ lock_table_create(
UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock); UT_LIST_ADD_LAST(trx_locks, trx->lock.trx_locks, lock);
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (c_lock && wsrep_on_trx(trx)) { if (c_lock && trx->is_wsrep()) {
if (wsrep_thd_is_wsrep(trx->mysql_thd) if (wsrep_thd_is_wsrep(trx->mysql_thd)
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)) { && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
UT_LIST_INSERT_AFTER( UT_LIST_INSERT_AFTER(
...@@ -5248,7 +5247,7 @@ lock_table_enqueue_waiting( ...@@ -5248,7 +5247,7 @@ lock_table_enqueue_waiting(
/* Enqueue the lock request that will wait to be granted */ /* Enqueue the lock request that will wait to be granted */
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (trx->lock.was_chosen_as_deadlock_victim && wsrep_on_trx(trx)) { if (trx->lock.was_chosen_as_deadlock_victim && trx->is_wsrep()) {
return(DB_DEADLOCK); return(DB_DEADLOCK);
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2019, MariaDB Corporation. Copyright (c) 2014, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -255,8 +255,7 @@ wsrep_is_BF_lock_timeout( ...@@ -255,8 +255,7 @@ wsrep_is_BF_lock_timeout(
const trx_t* trx, const trx_t* trx,
bool locked = true) bool locked = true)
{ {
if (wsrep_on_trx(trx) if (trx->is_wsrep() && wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
&& wsrep_thd_is_BF(trx->mysql_thd, FALSE)) {
fprintf(stderr, "WSREP: BF lock wait long for trx " TRX_ID_FMT "\n", trx->id); fprintf(stderr, "WSREP: BF lock wait long for trx " TRX_ID_FMT "\n", trx->id);
srv_print_innodb_monitor = TRUE; srv_print_innodb_monitor = TRUE;
srv_print_innodb_lock_monitor = TRUE; srv_print_innodb_lock_monitor = TRUE;
...@@ -447,7 +446,7 @@ lock_wait_suspend_thread( ...@@ -447,7 +446,7 @@ lock_wait_suspend_thread(
if (lock_wait_timeout < 100000000 if (lock_wait_timeout < 100000000
&& wait_time > (double) lock_wait_timeout) { && wait_time > (double) lock_wait_timeout) {
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!wsrep_on_trx(trx) || if (!trx->is_wsrep() ||
(!wsrep_is_BF_lock_timeout(trx) && (!wsrep_is_BF_lock_timeout(trx) &&
trx->error_state != DB_DEADLOCK)) { trx->error_state != DB_DEADLOCK)) {
#endif /* WITH_WSREP */ #endif /* WITH_WSREP */
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation. Copyright (c) 2017, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1651,7 +1651,7 @@ row_ins_check_foreign_constraint( ...@@ -1651,7 +1651,7 @@ row_ins_check_foreign_constraint(
if (check_ref) { if (check_ref) {
err = DB_SUCCESS; err = DB_SUCCESS;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (!wsrep_on(trx->mysql_thd)) { if (!trx->is_wsrep()) {
goto end_scan; goto end_scan;
} }
enum wsrep_key_type key_type; enum wsrep_key_type key_type;
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2019, MariaDB Corporation. Copyright (c) 2018, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1814,7 +1814,7 @@ row_upd_store_row( ...@@ -1814,7 +1814,7 @@ row_upd_store_row(
inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx) inline bool wsrep_must_process_fk(const upd_node_t* node, const trx_t* trx)
{ {
if (!wsrep_on_trx(trx)) { if (!trx->is_wsrep()) {
return false; return false;
} }
return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE return que_node_get_type(node->common.parent) != QUE_NODE_UPDATE
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2011, 2012, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. All Rights Reserved. Copyright (c) 2017, 2020, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described Google, Inc. Those modifications are gratefully acknowledged and are described
...@@ -218,8 +218,7 @@ srv_conc_enter_innodb_with_atomics( ...@@ -218,8 +218,7 @@ srv_conc_enter_innodb_with_atomics(
for (;;) { for (;;) {
ulint sleep_in_us; ulint sleep_in_us;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_trx_is_aborting(trx->mysql_thd)) {
wsrep_trx_is_aborting(trx->mysql_thd)) {
if (wsrep_debug) if (wsrep_debug)
fprintf(stderr, fprintf(stderr,
"srv_conc_enter due to MUST_ABORT"); "srv_conc_enter due to MUST_ABORT");
...@@ -430,8 +429,7 @@ srv_conc_enter_innodb_without_atomics( ...@@ -430,8 +429,7 @@ srv_conc_enter_innodb_without_atomics(
return; return;
} }
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_thd_is_brute_force(trx->mysql_thd)) {
wsrep_thd_is_brute_force(trx->mysql_thd)) {
srv_conc_force_enter_innodb(trx); srv_conc_force_enter_innodb(trx);
return; return;
} }
...@@ -514,8 +512,7 @@ srv_conc_enter_innodb_without_atomics( ...@@ -514,8 +512,7 @@ srv_conc_enter_innodb_without_atomics(
srv_conc.n_waiting++; srv_conc.n_waiting++;
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep() && wsrep_trx_is_aborting(trx->mysql_thd)) {
wsrep_trx_is_aborting(trx->mysql_thd)) {
os_fast_mutex_unlock(&srv_conc_mutex); os_fast_mutex_unlock(&srv_conc_mutex);
if (wsrep_debug) if (wsrep_debug)
fprintf(stderr, "srv_conc_enter due to MUST_ABORT"); fprintf(stderr, "srv_conc_enter due to MUST_ABORT");
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2019, MariaDB Corporation. Copyright (c) 2016, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -379,8 +379,7 @@ trx_rollback_to_savepoint_for_mysql_low( ...@@ -379,8 +379,7 @@ trx_rollback_to_savepoint_for_mysql_low(
trx->op_info = ""; trx->op_info = "";
#ifdef WITH_WSREP #ifdef WITH_WSREP
if (wsrep_on(trx->mysql_thd) && if (trx->is_wsrep()) {
trx->lock.was_chosen_as_deadlock_victim) {
trx->lock.was_chosen_as_deadlock_victim = FALSE; trx->lock.was_chosen_as_deadlock_victim = FALSE;
} }
#endif #endif
...@@ -1083,12 +1082,6 @@ trx_roll_try_truncate( ...@@ -1083,12 +1082,6 @@ trx_roll_try_truncate(
if (trx->update_undo) { if (trx->update_undo) {
trx_undo_truncate_end(trx, trx->update_undo, limit); trx_undo_truncate_end(trx, trx->update_undo, limit);
} }
#ifdef WITH_WSREP_OUT
if (wsrep_on(trx->mysql_thd)) {
trx->lock.was_chosen_as_deadlock_victim = FALSE;
}
#endif /* WITH_WSREP */
} }
/***********************************************************************//** /***********************************************************************//**
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2019, MariaDB Corporation. Copyright (c) 2015, 2020, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -1555,11 +1555,7 @@ trx_commit_in_memory( ...@@ -1555,11 +1555,7 @@ trx_commit_in_memory(
ut_ad(!trx->in_ro_trx_list); ut_ad(!trx->in_ro_trx_list);
ut_ad(!trx->in_rw_trx_list); ut_ad(!trx->in_rw_trx_list);
#ifdef WITH_WSREP trx->lock.was_chosen_as_deadlock_victim = FALSE;
if (trx->mysql_thd && wsrep_on(trx->mysql_thd)) {
trx->lock.was_chosen_as_deadlock_victim = FALSE;
}
#endif
trx->dict_operation = TRX_DICT_OP_NONE; trx->dict_operation = TRX_DICT_OP_NONE;
trx->error_state = DB_SUCCESS; trx->error_state = DB_SUCCESS;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment