summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDaniele Sciascia <daniele.sciascia@galeracluster.com>2022-02-15 14:36:02 +0100
committerJan Lindström <jan.lindstrom@mariadb.com>2022-08-31 11:05:23 +0300
commit2917bd0d2cf417cbf9c83b64ae2b7806bdb2f34e (patch)
tree1fb14efc031ed19f2637b98c0be6bac1457fcb10 /include
parentcf1a944f5b5496434ebe2c19e0f436e1bdd94871 (diff)
downloadmariadb-git-2917bd0d2cf417cbf9c83b64ae2b7806bdb2f34e.tar.gz
Reduce compilation dependencies on wsrep_mysqld.h
Making changes to wsrep_mysqld.h causes large parts of server code to be recompiled. The reason is that wsrep_mysqld.h is included by sql_class.h, even tough very little of wsrep_mysqld.h is needed in sql_class.h. This commit introduces a new header file, wsrep_on.h, which is meant to be included from sql_class.h, and contains only macros and variable declarations used to determine whether wsrep is enabled. Also, header wsrep.h should only contain definitions that are also used outside of sql/. Therefore, move WSREP_TO_ISOLATION* and WSREP_SYNC_WAIT macros to wsrep_mysqld.h. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
Diffstat (limited to 'include')
-rw-r--r--include/wsrep.h59
1 files changed, 28 insertions, 31 deletions
diff --git a/include/wsrep.h b/include/wsrep.h
index 1b645207f00..e4535deabfe 100644
--- a/include/wsrep.h
+++ b/include/wsrep.h
@@ -17,44 +17,46 @@
#define WSREP_INCLUDED
#include <my_config.h>
+#include "log.h"
#ifdef WITH_WSREP
#define IF_WSREP(A,B) A
#define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A)
-#define WSREP_MYSQL_DB (char *)"mysql"
-
-#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_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_TO_ISOLATION_END \
- if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \
- wsrep_thd_is_in_rsu(thd)) \
- wsrep_to_isolation_end(thd);
-
-/*
- 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;
+extern ulong wsrep_debug; // wsrep_mysqld.cc
+extern void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...);
#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_SYNC_WAIT(thd_, before_) \
- { if (WSREP_CLIENT(thd_) && \
- wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; }
#else /* !WITH_WSREP */
@@ -67,11 +69,6 @@
//#define WSREP_INFO(...)
//#define WSREP_WARN(...)
#define WSREP_ERROR(...)
-#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 */
#endif /* WSREP_INCLUDED */