diff options
Diffstat (limited to 'sql/wsrep_mysqld.h')
-rw-r--r-- | sql/wsrep_mysqld.h | 107 |
1 files changed, 32 insertions, 75 deletions
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index 12151e9a887..3fc0e397514 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -19,8 +19,6 @@ #include <wsrep.h> #ifdef WITH_WSREP -extern bool WSREP_ON_; -extern bool WSREP_PROVIDER_EXISTS_; #include <mysql/plugin.h> #include "mysql/service_wsrep.h" @@ -39,20 +37,11 @@ typedef struct st_mysql_show_var SHOW_VAR; #include "wsrep/provider.hpp" #include "wsrep/streaming_context.hpp" #include "wsrep_api.h" -#include <vector> -#include "wsrep_server_state.h" #define WSREP_UNDEFINED_TRX_ID ULONGLONG_MAX -class set_var; class THD; -enum wsrep_consistency_check_mode { - NO_CONSISTENCY_CHECK, - CONSISTENCY_CHECK_DECLARED, - CONSISTENCY_CHECK_RUNNING, -}; - // Global wsrep parameters // MySQL wsrep options @@ -79,7 +68,6 @@ extern ulong wsrep_max_ws_rows; extern const char* wsrep_notify_cmd; extern my_bool wsrep_certify_nonPK; extern long int wsrep_protocol_version; -extern ulong wsrep_forced_binlog_format; extern my_bool wsrep_desync; extern ulong wsrep_reject_queries; extern my_bool wsrep_recovery; @@ -218,67 +206,40 @@ extern bool wsrep_reload_ssl(); /* Other global variables */ extern wsrep_seqno_t wsrep_locked_seqno; -#define WSREP_ON unlikely(WSREP_ON_) - -/* use xxxxxx_NNULL macros when thd pointer is guaranteed to be non-null to - * avoid compiler warnings (GCC 6 and later) */ -#define WSREP_NNULL(thd) \ - (WSREP_PROVIDER_EXISTS_ && thd->variables.wsrep_on) - -#define WSREP(thd) \ - (thd && WSREP_NNULL(thd)) +/* A wrapper function for MySQL log functions. The call will prefix + the log message with WSREP and forward the result buffer to fun. */ +void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...); -#define WSREP_CLIENT_NNULL(thd) \ - (WSREP_NNULL(thd) && thd->wsrep_client_thread) +#define WSREP_SYNC_WAIT(thd_, before_) \ + { if (WSREP_CLIENT(thd_) && \ + wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } -#define WSREP_CLIENT(thd) \ - (WSREP(thd) && thd->wsrep_client_thread) +#define WSREP_MYSQL_DB (char *)"mysql" -#define WSREP_EMULATE_BINLOG_NNULL(thd) \ - (WSREP_NNULL(thd) && wsrep_emulate_bin_log) +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ + if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ + goto wsrep_error_label; -#define WSREP_EMULATE_BINLOG(thd) \ - (WSREP(thd) && wsrep_emulate_bin_log) +#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_) \ + if (WSREP(thd) && wsrep_thd_is_local(thd) && \ + wsrep_to_isolation_begin(thd, db_, table_, \ + table_list_, alter_info_, fk_tables_)) -#define WSREP_BINLOG_FORMAT(my_format) \ - ((wsrep_forced_binlog_format != BINLOG_FORMAT_UNSPEC) ? \ - wsrep_forced_binlog_format : my_format) +#define WSREP_TO_ISOLATION_END \ + if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \ + wsrep_thd_is_in_rsu(thd)) \ + wsrep_to_isolation_end(thd); -/* A wrapper function for MySQL log functions. The call will prefix - the log message with WSREP and forward the result buffer to fun. */ -void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...); +/* + Checks if lex->no_write_to_binlog is set for statements that use LOCAL or + NO_WRITE_TO_BINLOG. +*/ +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ + if (WSREP(thd) && !thd->lex->no_write_to_binlog \ + && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ + goto wsrep_error_label; -#define WSREP_DEBUG(...) \ - if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__) -#define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) -#define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) -#define WSREP_UNKNOWN(fmt, ...) WSREP_ERROR("UNKNOWN: " fmt, ##__VA_ARGS__) - -#define WSREP_LOG_CONFLICT_THD(thd, role) \ - WSREP_INFO("%s: \n " \ - " THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \ - " SQL: %s", \ - role, \ - thd_get_thread_id(thd), \ - wsrep_thd_client_mode_str(thd), \ - wsrep_thd_client_state_str(thd), \ - wsrep_thd_transaction_state_str(thd), \ - wsrep_thd_trx_seqno(thd), \ - wsrep_thd_query(thd) \ - ); - -#define WSREP_LOG_CONFLICT(bf_thd, victim_thd, bf_abort) \ - if (wsrep_debug || wsrep_log_conflicts) \ - { \ - WSREP_INFO("cluster conflict due to %s for threads:", \ - (bf_abort) ? "high priority abort" : "certification failure" \ - ); \ - if (bf_thd) WSREP_LOG_CONFLICT_THD(bf_thd, "Winning thread"); \ - if (victim_thd) WSREP_LOG_CONFLICT_THD(victim_thd, "Victim thread"); \ - WSREP_INFO("context: %s:%d", __FILE__, __LINE__); \ - } #define WSREP_PROVIDER_EXISTS (WSREP_PROVIDER_EXISTS_) @@ -292,9 +253,6 @@ static inline bool wsrep_cluster_address_exists() extern my_bool wsrep_ready_get(); extern void wsrep_ready_wait(); -class Ha_trx_info; -struct THD_TRANS; - extern mysql_mutex_t LOCK_wsrep_ready; extern mysql_cond_t COND_wsrep_ready; extern mysql_mutex_t LOCK_wsrep_sst; @@ -317,7 +275,6 @@ extern mysql_mutex_t LOCK_wsrep_donor_monitor; extern mysql_cond_t COND_wsrep_joiner_monitor; extern mysql_cond_t COND_wsrep_donor_monitor; -extern my_bool wsrep_emulate_bin_log; extern int wsrep_to_isolation; #ifdef GTID_SUPPORT extern rpl_sidno wsrep_sidno; @@ -489,12 +446,6 @@ wsrep::key wsrep_prepare_key_for_toi(const char* db, const char* table, /* These macros are needed to compile MariaDB without WSREP support * (e.g. embedded) */ -#define WSREP_ON false -#define WSREP(T) (0) -#define WSREP_NNULL(T) (0) -#define WSREP_EMULATE_BINLOG(thd) (0) -#define WSREP_EMULATE_BINLOG_NNULL(thd) (0) -#define WSREP_BINLOG_FORMAT(my_format) ((ulong)my_format) #define WSREP_PROVIDER_EXISTS (0) #define wsrep_emulate_bin_log (0) #define wsrep_to_isolation (0) @@ -506,6 +457,12 @@ wsrep::key wsrep_prepare_key_for_toi(const char* db, const char* table, #define wsrep_init_globals() do {} while(0) #define wsrep_create_appliers(X) do {} while(0) #define wsrep_cluster_address_exists() (false) +#define WSREP_MYSQL_DB (0) +#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0) +#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_) +#define WSREP_TO_ISOLATION_END +#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) +#define WSREP_SYNC_WAIT(thd_, before_) #endif /* WITH_WSREP */ |