9
3

service_wsrep.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #ifndef MYSQL_SERVICE_WSREP_INCLUDED
  2. /* Copyright (c) 2015 MariaDB Corporation Ab
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; version 2 of the License.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program; if not, write to the Free Software
  12. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  13. /**
  14. @file
  15. wsrep service
  16. Interface to WSREP functionality in the server.
  17. For engines that want to support galera.
  18. */
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. enum wsrep_conflict_state {
  23. NO_CONFLICT,
  24. MUST_ABORT,
  25. ABORTING,
  26. ABORTED,
  27. MUST_REPLAY,
  28. REPLAYING,
  29. RETRY_AUTOCOMMIT,
  30. CERT_FAILURE,
  31. };
  32. enum wsrep_exec_mode {
  33. /* Transaction processing before replication. */
  34. LOCAL_STATE,
  35. /* Slave thread applying write sets from other nodes or replaying thread. */
  36. REPL_RECV,
  37. /* Total-order-isolation mode. */
  38. TOTAL_ORDER,
  39. /*
  40. Transaction procession after it has been replicated in prepare stage and
  41. has passed certification.
  42. */
  43. LOCAL_COMMIT
  44. };
  45. enum wsrep_query_state {
  46. QUERY_IDLE,
  47. QUERY_EXEC,
  48. QUERY_COMMITTING,
  49. QUERY_EXITING,
  50. QUERY_ROLLINGBACK,
  51. };
  52. enum wsrep_trx_status {
  53. WSREP_TRX_OK,
  54. WSREP_TRX_CERT_FAIL, /* certification failure, must abort */
  55. WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */
  56. WSREP_TRX_ERROR, /* native mysql error */
  57. };
  58. struct xid_t;
  59. struct wsrep;
  60. struct wsrep_ws_handle;
  61. struct wsrep_buf;
  62. extern struct wsrep_service_st {
  63. struct wsrep * (*get_wsrep_func)();
  64. my_bool (*get_wsrep_certify_nonPK_func)();
  65. my_bool (*get_wsrep_debug_func)();
  66. my_bool (*get_wsrep_drupal_282555_workaround_func)();
  67. my_bool (*get_wsrep_recovery_func)();
  68. my_bool (*get_wsrep_load_data_splitting_func)();
  69. my_bool (*get_wsrep_log_conflicts_func)();
  70. long (*get_wsrep_protocol_version_func)();
  71. my_bool (*wsrep_aborting_thd_contains_func)(THD *thd);
  72. void (*wsrep_aborting_thd_enqueue_func)(THD *thd);
  73. bool (*wsrep_consistency_check_func)(THD *thd);
  74. int (*wsrep_is_wsrep_xid_func)(const struct xid_t *xid);
  75. void (*wsrep_lock_rollback_func)();
  76. int (*wsrep_on_func)(MYSQL_THD);
  77. void (*wsrep_post_commit_func)(THD* thd, bool all);
  78. bool (*wsrep_prepare_key_func)(const unsigned char*, size_t, const unsigned char*, size_t, struct wsrep_buf*, size_t*);
  79. enum wsrep_trx_status (*wsrep_run_wsrep_commit_func)(THD *thd, bool all);
  80. void (*wsrep_thd_LOCK_func)(THD *thd);
  81. void (*wsrep_thd_UNLOCK_func)(THD *thd);
  82. void (*wsrep_thd_awake_func)(THD *thd, my_bool signal);
  83. enum wsrep_conflict_state (*wsrep_thd_conflict_state_func)(MYSQL_THD, my_bool);
  84. const char * (*wsrep_thd_conflict_state_str_func)(THD *thd);
  85. enum wsrep_exec_mode (*wsrep_thd_exec_mode_func)(THD *thd);
  86. const char * (*wsrep_thd_exec_mode_str_func)(THD *thd);
  87. enum wsrep_conflict_state (*wsrep_thd_get_conflict_state_func)(MYSQL_THD);
  88. my_bool (*wsrep_thd_is_BF_func)(MYSQL_THD , my_bool);
  89. my_bool (*wsrep_thd_is_wsrep_func)(MYSQL_THD thd);
  90. char * (*wsrep_thd_query_func)(THD *thd);
  91. enum wsrep_query_state (*wsrep_thd_query_state_func)(THD *thd);
  92. const char * (*wsrep_thd_query_state_str_func)(THD *thd);
  93. int (*wsrep_thd_retry_counter_func)(THD *thd);
  94. void (*wsrep_thd_set_conflict_state_func)(THD *thd, enum wsrep_conflict_state state);
  95. bool (*wsrep_thd_ignore_table_func)(THD *thd);
  96. long long (*wsrep_thd_trx_seqno_func)(THD *thd);
  97. struct wsrep_ws_handle * (*wsrep_thd_ws_handle_func)(THD *thd);
  98. int (*wsrep_trx_is_aborting_func)(MYSQL_THD thd);
  99. int (*wsrep_trx_order_before_func)(MYSQL_THD, MYSQL_THD);
  100. void (*wsrep_unlock_rollback_func)();
  101. } *wsrep_service;
  102. #ifdef MYSQL_DYNAMIC_PLUGIN
  103. #define get_wsrep() wsrep_service->get_wsrep_func()
  104. #define get_wsrep_certify_nonPK() wsrep_service->get_wsrep_certify_nonPK_func()
  105. #define get_wsrep_debug() wsrep_service->get_wsrep_debug_func()
  106. #define get_wsrep_drupal_282555_workaround() wsrep_service->get_wsrep_drupal_282555_workaround_func()
  107. #define get_wsrep_recovery() wsrep_service->get_wsrep_recovery_func()
  108. #define get_wsrep_load_data_splitting() wsrep_service->get_wsrep_load_data_splitting_func()
  109. #define get_wsrep_log_conflicts() wsrep_service->get_wsrep_log_conflicts_func()
  110. #define get_wsrep_protocol_version() wsrep_service->get_wsrep_protocol_version_func()
  111. #define wsrep_aborting_thd_contains(T) wsrep_service->wsrep_aborting_thd_contains_func(T)
  112. #define wsrep_aborting_thd_enqueue(T) wsrep_service->wsrep_aborting_thd_enqueue_func(T)
  113. #define wsrep_consistency_check(T) wsrep_service->wsrep_consistency_check_func(T)
  114. #define wsrep_is_wsrep_xid(X) wsrep_service->wsrep_is_wsrep_xid_func(X)
  115. #define wsrep_lock_rollback() wsrep_service->wsrep_lock_rollback_func()
  116. #define wsrep_on(X) wsrep_service->wsrep_on_func(X)
  117. #define wsrep_post_commit(T,A) wsrep_service->wsrep_post_commit_func(T,A)
  118. #define wsrep_prepare_key(A,B,C,D,E,F) wsrep_service->wsrep_prepare_key_func(A,B,C,D,E,F)
  119. #define wsrep_run_wsrep_commit(T,A) wsrep_service->wsrep_run_wsrep_commit_func(T,A)
  120. #define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T)
  121. #define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T)
  122. #define wsrep_thd_awake(T,S) wsrep_service->wsrep_thd_awake_func(T,S)
  123. #define wsrep_thd_conflict_state(T,S) wsrep_service->wsrep_thd_conflict_state_func(T,S)
  124. #define wsrep_thd_conflict_state_str(T) wsrep_service->wsrep_thd_conflict_state_str_func(T)
  125. #define wsrep_thd_exec_mode(T) wsrep_service->wsrep_thd_exec_mode_func(T)
  126. #define wsrep_thd_exec_mode_str(T) wsrep_service->wsrep_thd_exec_mode_str_func(T)
  127. #define wsrep_thd_get_conflict_state(T) wsrep_service->wsrep_thd_get_conflict_state_func(T)
  128. #define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S)
  129. #define wsrep_thd_is_wsrep(T) wsrep_service->wsrep_thd_is_wsrep_func(T)
  130. #define wsrep_thd_query(T) wsrep_service->wsrep_thd_query_func(T)
  131. #define wsrep_thd_query_state(T) wsrep_service->wsrep_thd_query_state_func(T)
  132. #define wsrep_thd_query_state_str(T) wsrep_service->wsrep_thd_query_state_str_func(T)
  133. #define wsrep_thd_retry_counter(T) wsrep_service->wsrep_thd_retry_counter_func(T)
  134. #define wsrep_thd_set_conflict_state(T,S) wsrep_service->wsrep_thd_set_conflict_state_func(T,S)
  135. #define wsrep_thd_ignore_table(T) wsrep_service->wsrep_thd_ignore_table_func(T)
  136. #define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T)
  137. #define wsrep_thd_ws_handle(T) wsrep_service->wsrep_thd_ws_handle_func(T)
  138. #define wsrep_trx_is_aborting(T) wsrep_service->wsrep_trx_is_aborting_func(T)
  139. #define wsrep_trx_order_before(T1,T2) wsrep_service->wsrep_trx_order_before_func(T1,T2)
  140. #define wsrep_unlock_rollback() wsrep_service->wsrep_unlock_rollback_func()
  141. #define wsrep_debug get_wsrep_debug()
  142. #define wsrep_log_conflicts get_wsrep_log_conflicts()
  143. #define wsrep_certify_nonPK get_wsrep_certify_nonPK()
  144. #define wsrep_load_data_splitting get_wsrep_load_data_splitting()
  145. #define wsrep_drupal_282555_workaround get_wsrep_drupal_282555_workaround()
  146. #define wsrep_recovery get_wsrep_recovery()
  147. #define wsrep_protocol_version get_wsrep_protocol_version()
  148. #else
  149. extern my_bool wsrep_debug;
  150. extern my_bool wsrep_log_conflicts;
  151. extern my_bool wsrep_certify_nonPK;
  152. extern my_bool wsrep_load_data_splitting;
  153. extern my_bool wsrep_drupal_282555_workaround;
  154. extern my_bool wsrep_recovery;
  155. extern long wsrep_protocol_version;
  156. bool wsrep_consistency_check(THD *thd);
  157. bool wsrep_prepare_key(const unsigned char* cache_key, size_t cache_key_len, const unsigned char* row_id, size_t row_id_len, struct wsrep_buf* key, size_t* key_len);
  158. char *wsrep_thd_query(THD *thd);
  159. const char *wsrep_thd_conflict_state_str(THD *thd);
  160. const char *wsrep_thd_exec_mode_str(THD *thd);
  161. const char *wsrep_thd_query_state_str(THD *thd);
  162. enum wsrep_conflict_state wsrep_thd_conflict_state(MYSQL_THD thd, my_bool sync);
  163. enum wsrep_conflict_state wsrep_thd_get_conflict_state(MYSQL_THD thd);
  164. enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
  165. enum wsrep_query_state wsrep_thd_query_state(THD *thd);
  166. enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, bool all);
  167. int wsrep_is_wsrep_xid(const struct xid_t* xid);
  168. int wsrep_on(MYSQL_THD thd);
  169. int wsrep_thd_retry_counter(THD *thd);
  170. int wsrep_trx_is_aborting(MYSQL_THD thd);
  171. int wsrep_trx_order_before(MYSQL_THD thd1, MYSQL_THD thd2);
  172. long get_wsrep_protocol_version();
  173. long long wsrep_thd_trx_seqno(THD *thd);
  174. my_bool get_wsrep_certify_nonPK();
  175. my_bool get_wsrep_debug();
  176. my_bool get_wsrep_drupal_282555_workaround();
  177. my_bool get_wsrep_recovery();
  178. my_bool get_wsrep_load_data_splitting();
  179. my_bool get_wsrep_log_conflicts();
  180. my_bool wsrep_aborting_thd_contains(THD *thd);
  181. my_bool wsrep_thd_is_BF(MYSQL_THD thd, my_bool sync);
  182. my_bool wsrep_thd_is_wsrep(MYSQL_THD thd);
  183. struct wsrep *get_wsrep();
  184. struct wsrep_ws_handle *wsrep_thd_ws_handle(THD *thd);
  185. void wsrep_aborting_thd_enqueue(THD *thd);
  186. void wsrep_lock_rollback();
  187. void wsrep_post_commit(THD* thd, bool all);
  188. void wsrep_thd_LOCK(THD *thd);
  189. void wsrep_thd_UNLOCK(THD *thd);
  190. void wsrep_thd_awake(THD *thd, my_bool signal);
  191. void wsrep_thd_set_conflict_state(THD *thd, enum wsrep_conflict_state state);
  192. bool wsrep_thd_ignore_table(THD *thd);
  193. void wsrep_unlock_rollback();
  194. #endif
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #define MYSQL_SERVICE_WSREP_INCLUDED
  199. #endif