mariadb/sql/wsrep_dummy.cc

172 lines
3.7 KiB
C++
Raw Normal View History

2021-03-19 10:42:44 +01:00
/* 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.,
2019-05-11 21:19:05 +02:00
51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA. */
#include "mariadb.h"
#include <sql_class.h>
#include <mysql/service_wsrep.h>
2019-01-23 12:30:00 +01:00
my_bool wsrep_thd_is_BF(const THD *, my_bool)
{ return 0; }
2019-01-23 12:30:00 +01:00
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*)
{
2019-01-23 12:30:00 +01:00
static const unsigned char uuid[16]= {0};
return uuid;
}
2019-01-23 12:30:00 +01:00
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; }
2015-07-14 22:05:29 +02:00
my_bool get_wsrep_recovery()
{ return 0; }
bool wsrep_consistency_check(THD *)
{ return 0; }
void wsrep_lock_rollback()
{ }
2019-01-23 12:30:00 +01:00
my_bool wsrep_on(const THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
void wsrep_thd_LOCK(const THD *)
{ }
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>
2023-04-19 15:51:55 +02:00
int wsrep_thd_TRYLOCK(const THD *)
{
return 0;
}
2019-01-23 12:30:00 +01:00
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; }
2019-01-23 12:30:00 +01:00
const char *wsrep_thd_query(const THD *)
2019-11-01 14:23:18 +01:00
{ return "NULL"; }
2019-01-23 12:30:00 +01:00
const char *wsrep_thd_query_state_str(THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
int wsrep_thd_retry_counter(const THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
bool wsrep_thd_ignore_table(THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
long long wsrep_thd_trx_seqno(const THD *)
{ return -1; }
my_bool wsrep_thd_is_aborting(const THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
void wsrep_set_data_home_dir(const char *)
{ }
my_bool wsrep_thd_is_local(const THD *)
{ return 0; }
2019-01-23 12:30:00 +01:00
void wsrep_thd_self_abort(THD *)
{ }
2019-01-23 12:30:00 +01:00
int wsrep_thd_append_key(THD *, const struct wsrep_key*, int, enum Wsrep_service_key_type)
{ return 0; }
int wsrep_thd_append_table_key(THD *, const char*, const char*, enum Wsrep_service_key_type)
{ return 0; }
my_bool wsrep_thd_is_local_transaction(const THD*)
{ return 0; }
2019-01-23 12:30:00 +01:00
const char* wsrep_thd_client_state_str(const THD*)
{ return 0; }
2019-01-23 12:30:00 +01:00
const char* wsrep_thd_client_mode_str(const THD*)
{ return 0; }
2019-01-23 12:30:00 +01:00
const char* wsrep_thd_transaction_state_str(const THD*)
{ return 0; }
2019-01-23 12:30:00 +01:00
query_id_t wsrep_thd_transaction_id(const THD *)
{ return 0; }
my_bool wsrep_thd_bf_abort(THD *, THD *, my_bool)
2019-01-23 12:30:00 +01:00
{ return 0; }
my_bool wsrep_thd_order_before(const THD*, const THD *)
{ return 0; }
void wsrep_handle_SR_rollback(THD*, THD*)
{ }
2019-01-23 12:30:00 +01:00
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;}
10.4 wsrep group commit fixes (#1224) * MDEV-16509 Improve wsrep commit performance with binlog disabled Release commit order critical section early after trx_commit_low() if binlog is not transaction coordinator. In order to avoid two phase commit, binlog_hton is not registered for THD during IO_CACHE population. Implemented a test which verifies that the transactions release commit order early. This optimization will change behavior during recovery as the commit is not two phase when binlog is off. Fixed and recorded wsrep-recover-v25 and wsrep-recover to match the behavior. * MDEV-18730 Ordering for wsrep binlog group commit Previously out of order execution was allowed for wsrep commits. Established proper ordering by populating wait_for_commit for every wsrep THD and making group commit leader to wait for prior commits before proceeding to trx_group_commit_leader(). * MDEV-18730 Added a test case to verify correct commit ordering * MDEV-16509, MDEV-18730 Review fixes Use WSREP_EMULATE_BINLOG() macro to decide if the binlog_hton should be registered. Whitespace/syntax fixes and cleanups. * MDEV-16509 Require binlog for galera_var_innodb_disallow_writes test If the commit to InnoDB is done in one phase, the native InnoDB behavior is that the transaction is committed in memory before it is persisted to disk. This means that the innodb_disallow_writes=ON may not prevent transaction to become visible to other readers before commit is completely over. On the other hand, if the commit is two phase (as it is with binlog), the transaction will be blocked in prepare phase. Fixed the test to use binlog, which enforces two phase commit, which in turn makes commit to block before the changes become visible to other connections. This guarantees that the test produces expected result.
2019-03-15 06:09:13 +01:00
void wsrep_commit_ordered(THD* )
{ }
void wsrep_log(void (*)(const char *, ...), const char *, ...)
{
}
2020-04-27 12:28:13 +02:00
my_bool wsrep_thd_is_applying(const THD*)
{ return 0;}
my_bool wsrep_thd_has_ignored_error(const THD*)
{ return 0;}
void wsrep_thd_set_ignored_error(THD*, my_bool)
{ }
ulong wsrep_OSU_method_get(const THD*)
MDEV-21910 Deadlock between BF abort and manual KILL command When high priority replication slave applier encounters lock conflict in innodb, it will force the conflicting lock holder transaction (victim) to rollback. This is a must in multi-master sychronous replication model to avoid cluster lock-up. This high priority victim abort (aka "brute force" (BF) abort), is started from innodb lock manager while holding the victim's transaction's (trx) mutex. Depending on the execution state of the victim transaction, it may happen that the BF abort will call for THD::awake() to wake up the victim transaction for the rollback. Now, if BF abort requires THD::awake() to be called, then the applier thread executed locking protocol of: victim trx mutex -> victim THD::LOCK_thd_data If, at the same time another DBMS super user issues KILL command to abort the same victim, it will execute locking protocol of: victim THD::LOCK_thd_data -> victim trx mutex. These two locking protocol acquire mutexes in opposite order, hence unresolvable mutex locking deadlock may occur. The fix in this commit adds THD::wsrep_aborter flag to synchronize who can kill the victim This flag is set both when BF is called for from innodb and by KILL command. Either path of victim killing will bail out if victim's wsrep_killed is already set to avoid mutex conflicts with the other aborter execution. THD::wsrep_aborter records the aborter THD's ID. This is needed to preserve the right to kill the victim from different locations for the same aborter thread. It is also good error logging, to see who is reponsible for the abort. A new test case was added in galera.galera_bf_kill_debug.test for scenario where wsrep applier thread and manual KILL command try to kill same idle victim
2020-05-19 10:12:26 +02:00
{ return 0;}
2020-09-21 11:29:00 +02:00
void wsrep_report_bf_lock_wait(const THD*,
unsigned long long)
{}
void wsrep_thd_set_PA_unsafe(THD*)
{}
uint32 wsrep_get_domain_id()
{ return 0;}