summaryrefslogtreecommitdiff
path: root/sql/wsrep_var.cc
diff options
context:
space:
mode:
authorDaniele Sciascia <daniele.sciascia@galeracluster.com>2021-03-24 10:55:27 +0100
committerJan Lindström <jan.lindstrom@mariadb.com>2021-04-05 09:10:23 +0300
commit915983e1cc3a0a356a0adfef38fc7ad87264bd9f (patch)
tree8453158b6726c2082eddf9d08245df41e8852718 /sql/wsrep_var.cc
parent880baedcf6f2c1c342dc59e8a0e813c0ea728264 (diff)
downloadmariadb-git-915983e1cc3a0a356a0adfef38fc7ad87264bd9f.tar.gz
MDEV-25226 Assertion when wsrep_on set OFF with SR transaction
This patch makes the following changes around variable wsrep_on: 1) Variable wsrep_on can no longer be updated from a session that has an active transaction running. The original behavior allowed cases like this: BEGIN; INSERT INTO t1 VALUES (1); SET SESSION wsrep_on = OFF; INSERT INTO t1 VALUES (2); COMMIT; With regular transactions this would result in no replication events (not even value 1). With streaming replication it would be unnecessarily complex to achieve the same behavior. In the above example, it would be possible for value 1 to be already replicated if it happened to fill a separate fragment, while value 2 wouldn't. 2) Global variable wsrep_on no longer affects current sessions, only subsequent ones. This is to avoid a similar case to the above, just using just by using global wsrep_on instead session wsrep_on: --connection conn_1 BEGIN; INSERT INTO t1 VALUES(1); --connection conn_2 SET GLOBAL wsrep_on = OFF; --connection conn_1 INSERT INTO t1 VALUES(2); COMMIT; The above example results in the transaction to be replicated, as global wsrep_on will only affect the session wsrep_on of new connections. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
Diffstat (limited to 'sql/wsrep_var.cc')
-rw-r--r--sql/wsrep_var.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 815a65ff240..01e9d022cfb 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -88,10 +88,11 @@ static bool refresh_provider_options()
}
}
-static void wsrep_set_wsrep_on()
+void wsrep_set_wsrep_on()
{
- WSREP_ON_= global_system_variables.wsrep_on && wsrep_provider &&
- strcmp(wsrep_provider, WSREP_NONE);
+ WSREP_PROVIDER_EXISTS_= wsrep_provider &&
+ strncasecmp(wsrep_provider, WSREP_NONE, FN_REFLEN);
+ WSREP_ON_= global_system_variables.wsrep_on && WSREP_PROVIDER_EXISTS_;
}
/* This is intentionally declared as a weak global symbol, so that
@@ -146,6 +147,13 @@ bool wsrep_on_check(sys_var *self, THD* thd, set_var* var)
" innodb_lock_schedule_algorithm=FCFS and restart.", MYF(0));
return true;
}
+
+ if (thd->in_active_multi_stmt_transaction())
+ {
+ my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0));
+ return true;
+ }
+
return false;
}