summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2021-03-01 15:21:31 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2021-03-01 15:21:31 +0200
commitebb2db5912ebb9b4e3ef230f15ae65529ff30be4 (patch)
tree980aa6fcfb5e86ed2cbfa23a80dfb5d18855b63a
parentb47304eb02fd203ab9ecd29261e6915e0059af0a (diff)
downloadmariadb-git-bb-10.6-MDEV-20715.tar.gz
MDEV-20715 : Implement system variable to disallow local GTIDs in Galerabb-10.6-MDEV-20715
Added a new wsrep_mode feature DISALLOW_LOCAL_GTID for this. Nodes can have GTIDs for local transactions in the following scenarios: A DDL statement is executed with wsrep_OSU_method=RSU set. A DML statement writes to a non-InnoDB table. A DML statement writes to an InnoDB table with wsrep_on=OFF set. If user has set wsrep_mode=DISALLOW_LOCAL_GTID these operations produce a error ERROR HY000: Galera replication not supported
-rw-r--r--mysql-test/suite/galera/r/galera_disallow_local_gtid.result99
-rw-r--r--mysql-test/suite/galera/r/galera_var_wsrep_mode.result79
-rw-r--r--mysql-test/suite/galera/t/galera_disallow_local_gtid.test104
-rw-r--r--mysql-test/suite/galera/t/galera_var_wsrep_mode.test65
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_wsrep.result2
-rw-r--r--sql/sql_base.cc36
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sys_vars.cc1
-rw-r--r--sql/wsrep_mysqld.cc38
-rw-r--r--sql/wsrep_mysqld.h3
-rw-r--r--sql/wsrep_var.cc10
12 files changed, 429 insertions, 11 deletions
diff --git a/mysql-test/suite/galera/r/galera_disallow_local_gtid.result b/mysql-test/suite/galera/r/galera_disallow_local_gtid.result
new file mode 100644
index 00000000000..0ec0d7149d7
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_disallow_local_gtid.result
@@ -0,0 +1,99 @@
+connection node_2;
+connection node_1;
+call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
+connection node_1;
+CREATE TABLE tab(a int not null primary key) engine=InnoDB;
+CREATE TABLE tab1(a int not null primary key) engine=MyISAM;
+CREATE TABLE tab2(a int not null primary key) engine=Aria;
+CREATE TABLE tab3(a int not null primary key) engine=MEMORY;
+SET GLOBAL wsrep_mode = DISALLOW_LOCAL_GTID;
+SET SESSION wsrep_OSU_method='RSU';
+ALTER TABLE tab FORCE;
+ERROR HY000: Galera replication not supported
+SET SESSiON sql_log_bin=0;
+ALTER TABLE tab FORCE;
+SET SESSION wsrep_OSU_method='TOI';
+SET SESSION sql_log_bin=1;
+SET SESSION wsrep_on=OFF;
+INSERT INTO tab VALUES (1);
+ERROR HY000: Galera replication not supported
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab VALUES (1);
+SET SESSiON sql_log_bin=1;
+SET SESSION wsrep_on=ON;
+INSERT INTO tab VALUES (2);
+SELECT * FROM tab;
+a
+1
+2
+connection node_2;
+SELECT * FROM tab;
+a
+2
+connection node_1;
+INSERT INTO tab1 VALUES(1);
+ERROR HY000: Galera replication not supported
+INSERT INTO tab2 VALUES(1);
+ERROR HY000: Galera replication not supported
+INSERT INTO tab3 VALUES(1);
+ERROR HY000: Galera replication not supported
+SET GLOBAL wsrep_mode = "DISALLOW_LOCAL_GTID,REPLICATE_MYISAM,REPLICATE_ARIA";
+INSERT INTO tab1 VALUES(2);
+INSERT INTO tab2 VALUES(2);
+INSERT INTO tab3 VALUES(2);
+ERROR HY000: Galera replication not supported
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab1 VALUES(3);
+INSERT INTO tab2 VALUES(3);
+INSERT INTO tab3 VALUES(3);
+SET SESSION sql_log_bin=1;
+SET SESSION wsrep_on=OFF;
+INSERT INTO tab1 VALUES(4);
+ERROR HY000: Galera replication not supported
+INSERT INTO tab2 VALUES(4);
+ERROR HY000: Galera replication not supported
+INSERT INTO tab3 VALUES(4);
+ERROR HY000: Galera replication not supported
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab1 VALUES(5);
+INSERT INTO tab2 VALUES(5);
+INSERT INTO tab3 VALUES(5);
+SET SESSION wsrep_on=ON;
+INSERT INTO tab1 VALUES(6);
+INSERT INTO tab2 VALUES(6);
+INSERT INTO tab3 VALUES(6);
+SELECT * FROM tab1;
+a
+2
+3
+5
+6
+SELECT * FROM tab2;
+a
+2
+3
+5
+6
+SELECT * FROM tab3;
+a
+3
+5
+6
+connection node_2;
+SELECT * FROM tab1;
+a
+2
+3
+6
+SELECT * FROM tab2;
+a
+2
+3
+6
+SELECT * FROM tab3;
+a
+connection node_1;
+DROP TABLE tab;
+DROP TABLE tab1;
+DROP TABLE tab2;
+DROP TABLE tab3;
diff --git a/mysql-test/suite/galera/r/galera_var_wsrep_mode.result b/mysql-test/suite/galera/r/galera_var_wsrep_mode.result
new file mode 100644
index 00000000000..8682ad685a5
--- /dev/null
+++ b/mysql-test/suite/galera/r/galera_var_wsrep_mode.result
@@ -0,0 +1,79 @@
+connection node_2;
+connection node_1;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+
+SET GLOBAL wsrep_mode=DEFAULT;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+
+SET SESSION wsrep_mode=DEFAULT;
+ERROR HY000: Variable 'wsrep_mode' is a GLOBAL variable and should be set with SET GLOBAL
+SELECT @@global.wsrep_mode;
+@@global.wsrep_mode
+
+SELECT @@session.wsrep_mode;
+ERROR HY000: Variable 'wsrep_mode' is a GLOBAL variable
+SET GLOBAL wsrep_mode=A;
+ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'A'
+SET GLOBAL wsrep_mode='A';
+ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'A'
+SET GLOBAL wsrep_mode=NULL;
+ERROR 42000: Variable 'wsrep_mode' can't be set to the value of 'NULL'
+SET GLOBAL wsrep_mode=64;
+ERROR 42000: Variable 'wsrep_mode' can't be set to the value of '64'
+SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
+SET GLOBAL wsrep_mode=1;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION
+SET GLOBAL wsrep_mode=32;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+DISALLOW_LOCAL_GTID
+SET GLOBAL wsrep_mode='';
+SELECT @@wsrep_mode;
+@@wsrep_mode
+
+SET GLOBAL wsrep_mode=STRICT_REPLICATION;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION
+SET GLOBAL wsrep_mode=BINLOG_ROW_FORMAT_ONLY;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+BINLOG_ROW_FORMAT_ONLY
+SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+REQUIRED_PRIMARY_KEY
+SET GLOBAL wsrep_mode=REPLICATE_MYISAM;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+REPLICATE_MYISAM
+SET GLOBAL wsrep_mode=REPLICATE_ARIA;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+REPLICATE_ARIA
+SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID;
+SELECT @@wsrep_mode;
+@@wsrep_mode
+DISALLOW_LOCAL_GTID
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY';
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID';
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID
+SET GLOBAL wsrep_mode='BINLOG_ROW_FORMAT_ONLY,STRICT_REPLICATION';
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,REQUIRED_PRIMARY_KEY,REPLICATE_ARIA,DISALLOW_LOCAL_GTID';
+SELECT @@wsrep_mode;
+@@wsrep_mode
+STRICT_REPLICATION,REQUIRED_PRIMARY_KEY,REPLICATE_ARIA,DISALLOW_LOCAL_GTID
+SET GLOBAL wsrep_mode=DEFAULT;
diff --git a/mysql-test/suite/galera/t/galera_disallow_local_gtid.test b/mysql-test/suite/galera/t/galera_disallow_local_gtid.test
new file mode 100644
index 00000000000..b28bab1f8cb
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_disallow_local_gtid.test
@@ -0,0 +1,104 @@
+--source include/galera_cluster.inc
+--source include/have_aria.inc
+#
+# Nodes can have GTIDs for local transactions in the following scenarios:
+#
+# A DDL statement is executed with wsrep_OSU_method=RSU set.
+# A DML statement writes to a non-InnoDB table.
+# A DML statement writes to an InnoDB table with wsrep_on=OFF set.
+#
+call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
+#
+# A DDL statement is executed with wsrep_OSU_method=RSU set.
+#
+--connection node_1
+CREATE TABLE tab(a int not null primary key) engine=InnoDB;
+CREATE TABLE tab1(a int not null primary key) engine=MyISAM;
+CREATE TABLE tab2(a int not null primary key) engine=Aria;
+CREATE TABLE tab3(a int not null primary key) engine=MEMORY;
+
+SET GLOBAL wsrep_mode = DISALLOW_LOCAL_GTID;
+SET SESSION wsrep_OSU_method='RSU';
+
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+ALTER TABLE tab FORCE;
+
+SET SESSiON sql_log_bin=0;
+ALTER TABLE tab FORCE;
+SET SESSION wsrep_OSU_method='TOI';
+#
+# A DML statement writes to an InnoDB table with wsrep_on=OFF set.
+#
+SET SESSION sql_log_bin=1;
+SET SESSION wsrep_on=OFF;
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab VALUES (1);
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab VALUES (1);
+SET SESSiON sql_log_bin=1;
+SET SESSION wsrep_on=ON;
+INSERT INTO tab VALUES (2);
+
+SELECT * FROM tab;
+--connection node_2
+SELECT * FROM tab;
+#
+# A DML statement writes to a non-InnoDB table.
+#
+--connection node_1
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab1 VALUES(1);
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab2 VALUES(1);
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab3 VALUES(1);
+#
+# Set MyISAM and Aria replication on using TOI
+#
+SET GLOBAL wsrep_mode = "DISALLOW_LOCAL_GTID,REPLICATE_MYISAM,REPLICATE_ARIA";
+INSERT INTO tab1 VALUES(2);
+INSERT INTO tab2 VALUES(2);
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab3 VALUES(2);
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab1 VALUES(3);
+INSERT INTO tab2 VALUES(3);
+INSERT INTO tab3 VALUES(3);
+SET SESSION sql_log_bin=1;
+SET SESSION wsrep_on=OFF;
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab1 VALUES(4);
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab2 VALUES(4);
+--error ER_GALERA_REPLICATION_NOT_SUPPORTED
+INSERT INTO tab3 VALUES(4);
+SET SESSiON sql_log_bin=0;
+INSERT INTO tab1 VALUES(5);
+INSERT INTO tab2 VALUES(5);
+INSERT INTO tab3 VALUES(5);
+SET SESSION wsrep_on=ON;
+INSERT INTO tab1 VALUES(6);
+INSERT INTO tab2 VALUES(6);
+INSERT INTO tab3 VALUES(6);
+
+SELECT * FROM tab1;
+SELECT * FROM tab2;
+SELECT * FROM tab3;
+
+--connection node_2
+SELECT * FROM tab1;
+SELECT * FROM tab2;
+SELECT * FROM tab3;
+
+--connection node_1
+--disable_query_log
+SET SESSION sql_log_bin=DEFAULT;
+SET GLOBAL wsrep_mode=DEFAULT;
+set GLOBAL wsrep_OSU_method=DEFAULT;
+--enable_query_log
+
+DROP TABLE tab;
+DROP TABLE tab1;
+DROP TABLE tab2;
+DROP TABLE tab3;
+
diff --git a/mysql-test/suite/galera/t/galera_var_wsrep_mode.test b/mysql-test/suite/galera/t/galera_var_wsrep_mode.test
new file mode 100644
index 00000000000..56953b1e71b
--- /dev/null
+++ b/mysql-test/suite/galera/t/galera_var_wsrep_mode.test
@@ -0,0 +1,65 @@
+--source include/galera_cluster.inc
+
+# default
+SELECT @@wsrep_mode;
+
+SET GLOBAL wsrep_mode=DEFAULT;
+SELECT @@wsrep_mode;
+
+--error ER_GLOBAL_VARIABLE
+SET SESSION wsrep_mode=DEFAULT;
+SELECT @@global.wsrep_mode;
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+SELECT @@session.wsrep_mode;
+
+#
+# Incorrect input
+#
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL wsrep_mode=A;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL wsrep_mode='A';
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL wsrep_mode=NULL;
+--error ER_WRONG_VALUE_FOR_VAR
+SET GLOBAL wsrep_mode=64;
+--error ER_PARSE_ERROR
+SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM;
+#
+# Correct input
+#
+SET GLOBAL wsrep_mode=1;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=32;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode='';
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=STRICT_REPLICATION;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=BINLOG_ROW_FORMAT_ONLY;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=REQUIRED_PRIMARY_KEY;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=REPLICATE_MYISAM;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=REPLICATE_ARIA;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode=DISALLOW_LOCAL_GTID;
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY';
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID';
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode='BINLOG_ROW_FORMAT_ONLY,STRICT_REPLICATION';
+SELECT @@wsrep_mode;
+SET GLOBAL wsrep_mode='STRICT_REPLICATION,REQUIRED_PRIMARY_KEY,REPLICATE_ARIA,DISALLOW_LOCAL_GTID';
+SELECT @@wsrep_mode;
+
+# reset
+SET GLOBAL wsrep_mode=DEFAULT;
+
+
+
+
+
+
diff --git a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
index aaafbb08619..6bea1a88caa 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_wsrep.result
@@ -342,7 +342,7 @@ VARIABLE_COMMENT Set of WSREP features that are enabled.
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA
+ENUM_VALUE_LIST STRICT_REPLICATION,BINLOG_ROW_FORMAT_ONLY,REQUIRED_PRIMARY_KEY,REPLICATE_MYISAM,REPLICATE_ARIA,DISALLOW_LOCAL_GTID
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
GLOBAL_VALUE_PATH NULL
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index bfbf688c932..1a1186aca73 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4445,7 +4445,41 @@ restart:
error= TRUE;
goto error;
}
-#endif
+
+ /* If user has issued wsrep_on = OFF and wsrep was on before
+ we need to check is local gtid feature disabled */
+ if (thd->wsrep_was_on &&
+ thd->variables.sql_log_bin == 1 &&
+ !WSREP(thd) &&
+ wsrep_check_mode(WSREP_MODE_DISALLOW_LOCAL_GTID))
+ {
+ enum_sql_command sql_command= thd->lex->sql_command;
+ bool is_dml_stmt= thd->get_command() != COM_STMT_PREPARE &&
+ (sql_command == SQLCOM_INSERT ||
+ sql_command == SQLCOM_INSERT_SELECT ||
+ sql_command == SQLCOM_REPLACE ||
+ sql_command == SQLCOM_REPLACE_SELECT ||
+ sql_command == SQLCOM_UPDATE ||
+ sql_command == SQLCOM_UPDATE_MULTI ||
+ sql_command == SQLCOM_LOAD ||
+ sql_command == SQLCOM_DELETE);
+
+ if (is_dml_stmt && !is_temporary_table(tables))
+ {
+ /* wsrep_mode = WSREP_MODE_DISALLOW_LOCAL_GTID, treat as error */
+ my_error(ER_GALERA_REPLICATION_NOT_SUPPORTED, MYF(0));
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_OPTION_PREVENTS_STATEMENT,
+ "You can't execute statements that would generate local "
+ "GTIDs when wsrep_mode = DISALLOW_LOCAL_GTID is set. "
+ "Try disabling binary logging with SET sql_log_bin=0 "
+ "to execute this statement.");
+
+ error= TRUE;
+ goto error;
+ }
+ }
+#endif /* WITH_WSREP */
}
error:
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index d23b190b2c5..4992bca5aa9 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -713,6 +713,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
wsrep_current_gtid_seqno(0),
wsrep_affected_rows(0),
wsrep_has_ignored_error(false),
+ wsrep_was_on(false),
wsrep_ignore_table(false),
wsrep_aborter(0),
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 2913a4a8350..bf7f26527b0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -5239,6 +5239,8 @@ public:
uint64 wsrep_current_gtid_seqno;
ulong wsrep_affected_rows;
bool wsrep_has_ignored_error;
+ /* true if wsrep_on was ON in last wsrep_on_update */
+ bool wsrep_was_on;
/*
When enabled, do not replicate/binlog updates from the current table that's
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index f817f9086a9..8b73484cb8a 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -5933,6 +5933,7 @@ static const char *wsrep_mode_names[]=
"REQUIRED_PRIMARY_KEY",
"REPLICATE_MYISAM",
"REPLICATE_ARIA",
+ "DISALLOW_LOCAL_GTID",
NullS
};
static Sys_var_set Sys_wsrep_mode(
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 21131b6b671..973d40d8ae9 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -1069,7 +1069,6 @@ void wsrep_recover()
{
WSREP_INFO("Recovered position: %s", oss.str().c_str());
}
-
}
@@ -1089,7 +1088,7 @@ void wsrep_stop_replication(THD *thd)
*/
if (thd && !thd->wsrep_applier) trans_rollback(thd);
wsrep_close_client_connections(TRUE, thd);
-
+
/* wait until appliers have stopped */
wsrep_wait_appliers_close(thd);
@@ -1424,10 +1423,24 @@ bool wsrep_check_mode_after_open_table (THD *thd,
/* InnoDB table doesn't have explicit primary-key defined. */
wsrep_push_warning(thd, WSREP_REQUIRE_PRIMARY_KEY, hton, tables);
}
+
+ if (db_type != DB_TYPE_INNODB &&
+ thd->variables.sql_log_bin == 1 &&
+ wsrep_check_mode(WSREP_MODE_DISALLOW_LOCAL_GTID))
+ {
+ /* Table is not an InnoDB table and local GTIDs are disallowed */
+ my_error(ER_GALERA_REPLICATION_NOT_SUPPORTED, MYF(0));
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_OPTION_PREVENTS_STATEMENT,
+ "You can't execute statements that would generate local "
+ "GTIDs when wsrep_mode = DISALLOW_LOCAL_GTID is set. "
+ "Try disabling binary logging with SET sql_log_bin=0 "
+ "to execute this statement.");
+ goto wsrep_error_label;
+ }
}
}
-
return true;
wsrep_error_label:
@@ -2610,6 +2623,23 @@ static int wsrep_RSU_begin(THD *thd, const char *db_, const char *table_)
{
WSREP_DEBUG("RSU BEGIN: %lld, : %s", wsrep_thd_trx_seqno(thd),
wsrep_thd_query(thd));
+
+ if (thd->variables.wsrep_OSU_method == WSREP_OSU_RSU &&
+ thd->variables.sql_log_bin == 1 &&
+ wsrep_check_mode(WSREP_MODE_DISALLOW_LOCAL_GTID))
+ {
+ /* wsrep_mode = WSREP_MODE_DISALLOW_LOCAL_GTID, treat as error */
+ my_error(ER_GALERA_REPLICATION_NOT_SUPPORTED, MYF(0));
+ push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
+ ER_OPTION_PREVENTS_STATEMENT,
+ "You can't execute statements that would generate local "
+ "GTIDs when wsrep_mode = DISALLOW_LOCAL_GTID is set. "
+ "Try disabling binary logging with SET sql_log_bin=0 "
+ "to execute this statement.");
+
+ return -1;
+ }
+
if (thd->wsrep_cs().begin_rsu(5000))
{
WSREP_WARN("RSU begin failed");
@@ -2985,7 +3015,7 @@ void wsrep_close_client_connections(my_bool wait_to_end, THD* except_caller_thd)
{
/* Clear thread cache */
thread_cache.final_flush();
-
+
/*
First signal all threads that it's time to die
*/
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index b1d5373b3b4..d49e8ce9907 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -140,7 +140,8 @@ enum enum_wsrep_mode {
WSREP_MODE_BINLOG_ROW_FORMAT_ONLY= (1ULL << 1),
WSREP_MODE_REQUIRED_PRIMARY_KEY= (1ULL << 2),
WSREP_MODE_REPLICATE_MYISAM= (1ULL << 3),
- WSREP_MODE_REPLICATE_ARIA= (1ULL << 4)
+ WSREP_MODE_REPLICATE_ARIA= (1ULL << 4),
+ WSREP_MODE_DISALLOW_LOCAL_GTID= (1ULL << 5)
};
// Streaming Replication
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 22a434e304d..7888c7d563d 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -91,8 +91,10 @@ static bool refresh_provider_options()
}
}
-static void wsrep_set_wsrep_on()
+static void wsrep_set_wsrep_on(THD* thd)
{
+ if (thd)
+ thd->wsrep_was_on= WSREP_ON_;
WSREP_ON_= global_system_variables.wsrep_on && wsrep_provider &&
strcmp(wsrep_provider, WSREP_NONE);
}
@@ -125,7 +127,7 @@ bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type)
thd->variables.wsrep_on= global_system_variables.wsrep_on= saved_wsrep_on;
}
- wsrep_set_wsrep_on();
+ wsrep_set_wsrep_on(thd);
return false;
}
@@ -445,7 +447,7 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type)
if (!rcode)
refresh_provider_options();
- wsrep_set_wsrep_on();
+ wsrep_set_wsrep_on(thd);
mysql_mutex_lock(&LOCK_global_system_variables);
return rcode;
@@ -465,7 +467,7 @@ void wsrep_provider_init (const char* value)
if (wsrep_provider) my_free((void *)wsrep_provider);
wsrep_provider= my_strdup(PSI_INSTRUMENT_MEM, value, MYF(0));
- wsrep_set_wsrep_on();
+ wsrep_set_wsrep_on(NULL);
}
bool wsrep_provider_options_check(sys_var *self, THD* thd, set_var* var)