summaryrefslogtreecommitdiff
path: root/sql/wsrep_mysqld.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-08-26 08:46:57 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-08-26 08:46:57 +0300
commit87ff4ba7c874ccb8a5b1105571569a94ca959d53 (patch)
treea3dfd317697d7f698c5c5e3e3d7b3a7a3b4d181a /sql/wsrep_mysqld.cc
parentbd3eb528512dfbb99a57033ff3bf7e09069c0d4e (diff)
parentdc6bc85cd29586631d927036451d955c7013206c (diff)
downloadmariadb-git-87ff4ba7c874ccb8a5b1105571569a94ca959d53.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r--sql/wsrep_mysqld.cc44
1 files changed, 32 insertions, 12 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 524410152ca..56b92df65b3 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1,4 +1,4 @@
-/* Copyright 2008-2015 Codership Oy <http://www.codership.com>
+/* Copyright 2008-2021 Codership Oy <http://www.codership.com>
Copyright (c) 2020, 2021, MariaDB
This program is free software; you can redistribute it and/or modify
@@ -2255,12 +2255,29 @@ static int wsrep_TOI_begin(THD *thd, const char *db, const char *table,
wsrep_thd_query(thd));
my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED);
break;
+ case wsrep::e_deadlock_error:
+ WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
+ "Deadlock error.",
+ ret,
+ (thd->db.str ? thd->db.str : "(null)"),
+ wsrep_thd_query(thd));
+ my_error(ER_LOCK_DEADLOCK, MYF(0));
+ break;
+ case wsrep::e_timeout_error:
+ WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
+ "Operation timed out.",
+ ret,
+ (thd->db.str ? thd->db.str : "(null)"),
+ wsrep_thd_query(thd));
+ my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
+ break;
default:
WSREP_WARN("TO isolation failed for: %d, schema: %s, sql: %s. "
- "Check wsrep connection state and retry the query.",
+ "Check your wsrep connection state and retry the query.",
ret,
(thd->db.str ? thd->db.str : "(null)"),
wsrep_thd_query(thd));
+
if (!thd->is_error())
{
my_error(ER_LOCK_DEADLOCK, MYF(0), "WSREP replication failed. Check "
@@ -2418,13 +2435,6 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
thd->variables.auto_increment_increment= 1;
}
- /*
- TOI operations will ignore provided lock_wait_timeout and restore it
- after operation is done.
- */
- thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout;
- thd->variables.lock_wait_timeout= LONG_TIMEOUT;
-
if (thd->variables.wsrep_on && wsrep_thd_is_local(thd))
{
switch (wsrep_OSU_method_get(thd)) {
@@ -2441,8 +2451,19 @@ int wsrep_to_isolation_begin(THD *thd, const char *db_, const char *table_,
ret= -1;
break;
}
+
switch (ret) {
- case 0: /* wsrep_TOI_begin should set toi mode */ break;
+ case 0: /* wsrep_TOI_begin should set toi mode */
+ if (thd->variables.wsrep_OSU_method == WSREP_OSU_TOI)
+ {
+ /*
+ TOI operations ignore the provided lock_wait_timeout once replicated,
+ and restore it after operation is done.
+ */
+ thd->variables.saved_lock_wait_timeout= thd->variables.lock_wait_timeout;
+ thd->variables.lock_wait_timeout= LONG_TIMEOUT;
+ }
+ break;
case 1:
/* TOI replication skipped, treat as success */
ret= 0;
@@ -2461,10 +2482,9 @@ void wsrep_to_isolation_end(THD *thd)
DBUG_ASSERT(wsrep_thd_is_local_toi(thd) ||
wsrep_thd_is_in_rsu(thd));
- thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
-
if (wsrep_thd_is_local_toi(thd))
{
+ thd->variables.lock_wait_timeout= thd->variables.saved_lock_wait_timeout;
DBUG_ASSERT(wsrep_OSU_method_get(thd) == WSREP_OSU_TOI);
wsrep_TOI_end(thd);
}