|
17 | 17 | #define WSREP_INCLUDED |
18 | 18 |
|
19 | 19 | #include <my_config.h> |
| 20 | +#include "log.h" |
20 | 21 |
|
21 | 22 | #ifdef WITH_WSREP |
22 | 23 | #define IF_WSREP(A,B) A |
23 | 24 | #define DBUG_ASSERT_IF_WSREP(A) DBUG_ASSERT(A) |
24 | 25 |
|
25 | | -#define WSREP_MYSQL_DB (char *)"mysql" |
26 | | - |
27 | | -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) \ |
28 | | - if (WSREP_ON && WSREP(thd) && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) \ |
29 | | - goto wsrep_error_label; |
30 | | - |
31 | | -#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_) \ |
32 | | - if (WSREP(thd) && wsrep_thd_is_local(thd) && \ |
33 | | - wsrep_to_isolation_begin(thd, db_, table_, \ |
34 | | - table_list_, alter_info_, fk_tables_)) |
35 | | - |
36 | | -#define WSREP_TO_ISOLATION_END \ |
37 | | - if ((WSREP(thd) && wsrep_thd_is_local_toi(thd)) || \ |
38 | | - wsrep_thd_is_in_rsu(thd)) \ |
39 | | - wsrep_to_isolation_end(thd); |
40 | | - |
41 | | -/* |
42 | | - Checks if lex->no_write_to_binlog is set for statements that use LOCAL or |
43 | | - NO_WRITE_TO_BINLOG. |
44 | | -*/ |
45 | | -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) \ |
46 | | - if (WSREP(thd) && !thd->lex->no_write_to_binlog \ |
47 | | - && wsrep_to_isolation_begin(thd, db_, table_, table_list_)) goto wsrep_error_label; |
| 26 | +extern ulong wsrep_debug; // wsrep_mysqld.cc |
| 27 | +extern void WSREP_LOG(void (*fun)(const char* fmt, ...), const char* fmt, ...); |
48 | 28 |
|
49 | 29 | #define WSREP_DEBUG(...) \ |
50 | 30 | if (wsrep_debug) WSREP_LOG(sql_print_information, ##__VA_ARGS__) |
51 | 31 | #define WSREP_INFO(...) WSREP_LOG(sql_print_information, ##__VA_ARGS__) |
52 | 32 | #define WSREP_WARN(...) WSREP_LOG(sql_print_warning, ##__VA_ARGS__) |
53 | 33 | #define WSREP_ERROR(...) WSREP_LOG(sql_print_error, ##__VA_ARGS__) |
| 34 | +#define WSREP_UNKNOWN(fmt, ...) WSREP_ERROR("UNKNOWN: " fmt, ##__VA_ARGS__) |
| 35 | + |
| 36 | +#define WSREP_LOG_CONFLICT_THD(thd, role) \ |
| 37 | + WSREP_INFO("%s: \n " \ |
| 38 | + " THD: %lu, mode: %s, state: %s, conflict: %s, seqno: %lld\n " \ |
| 39 | + " SQL: %s", \ |
| 40 | + role, \ |
| 41 | + thd_get_thread_id(thd), \ |
| 42 | + wsrep_thd_client_mode_str(thd), \ |
| 43 | + wsrep_thd_client_state_str(thd), \ |
| 44 | + wsrep_thd_transaction_state_str(thd), \ |
| 45 | + wsrep_thd_trx_seqno(thd), \ |
| 46 | + wsrep_thd_query(thd) \ |
| 47 | + ); |
| 48 | + |
| 49 | +#define WSREP_LOG_CONFLICT(bf_thd, victim_thd, bf_abort) \ |
| 50 | + if (wsrep_debug || wsrep_log_conflicts) \ |
| 51 | + { \ |
| 52 | + WSREP_INFO("cluster conflict due to %s for threads:", \ |
| 53 | + (bf_abort) ? "high priority abort" : "certification failure" \ |
| 54 | + ); \ |
| 55 | + if (bf_thd) WSREP_LOG_CONFLICT_THD(bf_thd, "Winning thread"); \ |
| 56 | + if (victim_thd) WSREP_LOG_CONFLICT_THD(victim_thd, "Victim thread"); \ |
| 57 | + WSREP_INFO("context: %s:%d", __FILE__, __LINE__); \ |
| 58 | + } |
54 | 59 |
|
55 | | -#define WSREP_SYNC_WAIT(thd_, before_) \ |
56 | | - { if (WSREP_CLIENT(thd_) && \ |
57 | | - wsrep_sync_wait(thd_, before_)) goto wsrep_error_label; } |
58 | 60 |
|
59 | 61 | #else /* !WITH_WSREP */ |
60 | 62 |
|
|
67 | 69 | //#define WSREP_INFO(...) |
68 | 70 | //#define WSREP_WARN(...) |
69 | 71 | #define WSREP_ERROR(...) |
70 | | -#define WSREP_TO_ISOLATION_BEGIN(db_, table_, table_list_) do { } while(0) |
71 | | -#define WSREP_TO_ISOLATION_BEGIN_ALTER(db_, table_, table_list_, alter_info_, fk_tables_) |
72 | | -#define WSREP_TO_ISOLATION_END |
73 | | -#define WSREP_TO_ISOLATION_BEGIN_WRTCHK(db_, table_, table_list_) |
74 | | -#define WSREP_SYNC_WAIT(thd_, before_) |
75 | 72 | #endif /* WITH_WSREP */ |
76 | 73 |
|
77 | 74 | #endif /* WSREP_INCLUDED */ |
0 commit comments