diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 36 | ||||
-rw-r--r-- | sql/sql_class.cc | 1 | ||||
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sys_vars.cc | 1 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 38 | ||||
-rw-r--r-- | sql/wsrep_mysqld.h | 3 | ||||
-rw-r--r-- | sql/wsrep_var.cc | 10 |
7 files changed, 81 insertions, 10 deletions
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) |