revision-id: 140fcab9571dbd15652ed7c7b798818556e3805d (mariadb-10.3.6-329-g140fcab9571) parent(s): 06fd4e7ffbeacbcd951d07eab30d7cef709940c5 author: Jan Lindström committer: Jan Lindström timestamp: 2019-01-18 16:19:31 +0200 message: Fixed compilation failure with dynamic InnoDB (-DPLUGIN_INNOBASE=DYNAMIC) Fixed test failure on galera_var_slave_threads --- include/mysql/service_wsrep.h | 60 ++- .../suite/galera/r/galera_var_slave_threads.result | 402 +-------------------- .../suite/galera/t/galera_var_slave_threads.cnf | 7 + .../suite/galera/t/galera_var_slave_threads.test | 10 +- sql/service_wsrep.cc | 10 + sql/sql_plugin_services.ic | 16 +- storage/innobase/buf/buf0dump.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 14 +- storage/innobase/row/row0ins.cc | 4 +- storage/innobase/row/row0sel.cc | 2 +- storage/innobase/row/row0upd.cc | 6 +- storage/innobase/srv/srv0conc.cc | 6 +- storage/innobase/srv/srv0start.cc | 2 +- 13 files changed, 108 insertions(+), 433 deletions(-) diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h index 4c485d92659..5aa97cdb47e 100644 --- a/include/mysql/service_wsrep.h +++ b/include/mysql/service_wsrep.h @@ -1,6 +1,14 @@ #ifndef MYSQL_SERVICE_WSREP_INCLUDED #define MYSQL_SERVICE_WSREP_INCLUDED +enum Wsrep_service_key_type +{ + WSREP_SERVICE_KEY_SHARED, + WSREP_SERVICE_KEY_REFERENCE, + WSREP_SERVICE_KEY_UPDATE, + WSREP_SERVICE_KEY_EXCLUSIVE +}; + #if (defined (MYSQL_DYNAMIC_PLUGIN) && defined(MYSQL_SERVICE_WSREP_DYNAMIC_INCLUDED)) || (!defined(MYSQL_DYNAMIC_PLUGIN) && defined(MYSQL_SERVICE_WSREP_STATIC_INCLUDED)) #else @@ -36,6 +44,10 @@ struct xid_t; struct wsrep_ws_handle; struct wsrep_buf; +/* Must match to definition in sql/mysqld.h */ +typedef int64 query_id_t; + + extern struct wsrep_service_st { my_bool (*get_wsrep_recovery_func)(); bool (*wsrep_consistency_check_func)(MYSQL_THD thd); @@ -52,6 +64,23 @@ extern struct wsrep_service_st { long long (*wsrep_thd_trx_seqno_func)(const MYSQL_THD thd); my_bool (*wsrep_thd_is_aborting_func)(const MYSQL_THD thd); void (*wsrep_set_data_home_dir_func)(const char *data_dir); + my_bool (*wsrep_thd_is_BF_func)(const MYSQL_THD thd, my_bool sync); + my_bool (*wsrep_thd_is_local_func)(const MYSQL_THD thd); + void (*wsrep_thd_self_abort_func)(MYSQL_THD thd); + int (*wsrep_thd_append_key_func)(MYSQL_THD thd, const struct wsrep_key* key, + int n_keys, enum Wsrep_service_key_type); + const char* (*wsrep_thd_client_state_str_func)(const MYSQL_THD thd); + const char* (*wsrep_thd_client_mode_str_func)(const MYSQL_THD thd); + const char* (*wsrep_thd_transaction_state_str_func)(const MYSQL_THD thd); + query_id_t (*wsrep_thd_transaction_id_func)(const MYSQL_THD thd); + my_bool (*wsrep_thd_bf_abort_func)(const MYSQL_THD bf_thd, + MYSQL_THD victim_thd, + my_bool signal); + my_bool (*wsrep_thd_order_before_func)(const MYSQL_THD left, const MYSQL_THD right); + void (*wsrep_handle_SR_rollback_func)(MYSQL_THD BF_thd, MYSQL_THD victim_thd); + my_bool (*wsrep_thd_skip_locking_func)(const MYSQL_THD thd); + const char* (*wsrep_get_sr_table_name_func)(); + my_bool (*wsrep_get_debug_func)(); } *wsrep_service; #define MYSQL_SERVICE_WSREP_INCLUDED @@ -66,7 +95,7 @@ extern struct wsrep_service_st { #define wsrep_xid_seqno(X) wsrep_service->wsrep_xid_seqno_func(X) #define wsrep_xid_uuid(X) wsrep_service->wsrep_xid_uuid_func(X) #define wsrep_on(X) wsrep_service->wsrep_on_func(X) -#define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F.G) +#define wsrep_prepare_key_for_innodb(A,B,C,D,E,F,G) wsrep_service->wsrep_prepare_key_for_innodb_func(A,B,C,D,E,F,G) #define wsrep_thd_LOCK(T) wsrep_service->wsrep_thd_LOCK_func(T) #define wsrep_thd_UNLOCK(T) wsrep_service->wsrep_thd_UNLOCK_func(T) #define wsrep_thd_query(T) wsrep_service->wsrep_thd_query_func(T) @@ -74,8 +103,21 @@ extern struct wsrep_service_st { #define wsrep_thd_ignore_table(T) wsrep_service->wsrep_thd_ignore_table_func(T) #define wsrep_thd_trx_seqno(T) wsrep_service->wsrep_thd_trx_seqno_func(T) #define wsrep_set_data_home_dir(A) wsrep_service->wsrep_set_data_home_dir_func(A) - #define wsrep_thd_is_BF(T,S) wsrep_service->wsrep_thd_is_BF_func(T,S) +#define wsrep_thd_is_aborting(T) wsrep_service->wsrep_thd_is_aborting_func(T) +#define wsrep_thd_is_local(T) wsrep_service->wsrep_thd_is_local_func(T) +#define wsrep_thd_self_abort(T) wsrep_service->wsrep_thd_self_abort_func(T) +#define wsrep_thd_append_key(T,W,N,K) wsrep_service->wsrep_thd_append_key_func(T,W,N,K) +#define wsrep_thd_client_state_str(T) wsrep_service->wsrep_thd_client_state_str_func(T) +#define wsrep_thd_client_mode_str(T) wsrep_service->wsrep_thd_client_mode_str_func(T) +#define wsrep_thd_transaction_state_str(T) wsrep_service->wsrep_thd_transaction_state_str_func(T) +#define wsrep_thd_transaction_id(T) wsrep_service->wsrep_thd_transaction_id_func(T) +#define wsrep_thd_bf_abort(T,T2,S) wsrep_service->wsrep_thd_bf_abort_func(T,T2,S) +#define wsrep_thd_order_before(L,R) wsrep_service->wsrep_thd_order_before_func(L,R) +#define wsrep_handle_SR_rollback(B,V) wsrep_service->wsrep_handle_SR_rollback_func(B,V) +#define wsrep_thd_skip_locking(T) wsrep_service->wsrep_thd_skip_locking_func(T) +#define wsrep_get_sr_table_name() wsrep_service->wsrep_get_sr_table_name_func() +#define wsrep_get_debug() wsrep_service->wsrep_get_debug_func() #else @@ -99,12 +141,9 @@ my_bool get_wsrep_recovery(); bool wsrep_thd_ignore_table(MYSQL_THD thd); void wsrep_set_data_home_dir(const char *data_dir); - /* from mysql wsrep-lib */ #include "my_global.h" #include "my_pthread.h" -/* Must match to definition in sql/mysqld.h */ -typedef int64 query_id_t; /* Return true if wsrep is enabled for a thd. This means that wsrep is enabled globally and the thd has wsrep on */ @@ -155,14 +194,6 @@ extern "C" my_bool wsrep_thd_skip_locking(const MYSQL_THD thd); /* Return true if thd is aborting */ extern "C" my_bool wsrep_thd_is_aborting(const MYSQL_THD thd); - -enum Wsrep_service_key_type -{ - WSREP_SERVICE_KEY_SHARED, - WSREP_SERVICE_KEY_REFERENCE, - WSREP_SERVICE_KEY_UPDATE, - WSREP_SERVICE_KEY_EXCLUSIVE -}; struct wsrep_key; struct wsrep_key_array; extern "C" int wsrep_thd_append_key(MYSQL_THD thd, @@ -172,5 +203,8 @@ extern "C" int wsrep_thd_append_key(MYSQL_THD thd, extern const char* wsrep_sr_table_name_full; +extern "C" const char* wsrep_get_sr_table_name(); + +extern "C" my_bool wsrep_get_debug(); #endif #endif /* MYSQL_SERVICE_WSREP_INCLUDED */ diff --git a/mysql-test/suite/galera/r/galera_var_slave_threads.result b/mysql-test/suite/galera/r/galera_var_slave_threads.result index 108908551f6..168b45154b8 100644 --- a/mysql-test/suite/galera/r/galera_var_slave_threads.result +++ b/mysql-test/suite/galera/r/galera_var_slave_threads.result @@ -27,8 +27,8 @@ SET GLOBAL wsrep_slave_threads = 64; connection node_1; INSERT INTO t1 VALUES (1); connection node_2; -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 +SELECT COUNT(*) FROM t1; +COUNT(*) 1 SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE '%wsrep aborter%'; COUNT(*) @@ -65,401 +65,19 @@ connection node_2; SET GLOBAL wsrep_slave_threads = 1; connection node_1; connection node_2; -SELECT * FROM t1; -f1 +SELECT COUNT(*) FROM t1; +COUNT(*) 1 -SELECT * FROM t2; -f1 -3 -5 -7 -9 -11 -13 -15 -17 -19 -21 -23 -25 -27 -29 -31 -33 -35 -37 -39 -41 -43 -45 -47 -49 -51 -53 -55 -57 -59 -61 -63 -65 -67 -69 -71 -73 -75 -77 -79 -81 -83 -85 -87 -89 -91 -93 -95 -97 -99 -101 -103 -105 -107 -109 -111 -113 -115 -117 -119 -121 -123 -125 -127 -129 -132 -134 -136 -138 -140 -142 -144 -146 -148 -150 -152 -154 -156 -158 -160 -162 -164 -166 -168 -170 -172 -174 -176 -178 -180 -182 -184 -186 -188 -190 +SELECT COUNT(*) FROM t2; +COUNT(*) 192 -194 -196 -198 -200 -202 -204 -206 -208 -210 -212 -214 -216 -218 -220 -222 -224 -226 -228 -230 -232 -234 -236 -238 -240 -242 -244 -246 -248 -250 -252 -254 -256 -258 -259 -261 -263 -265 -267 -269 -271 -273 -275 -277 -279 -281 -283 -285 -287 -289 -291 -293 -295 -297 -299 -301 -303 -305 -307 -309 -311 -313 -315 -317 -319 -321 -323 -325 -327 -329 -331 -333 -335 -337 -339 -341 -343 -345 -347 -349 -351 -353 -355 -357 -359 -361 -363 -365 -367 -369 -371 -373 -375 -377 -379 -381 -383 -385 connection node_1; -SELECT * FROM t1; -f1 +SELECT COUNT(*) FROM t1; +COUNT(*) 1 -SELECT * FROM t2; -f1 -3 -5 -7 -9 -11 -13 -15 -17 -19 -21 -23 -25 -27 -29 -31 -33 -35 -37 -39 -41 -43 -45 -47 -49 -51 -53 -55 -57 -59 -61 -63 -65 -67 -69 -71 -73 -75 -77 -79 -81 -83 -85 -87 -89 -91 -93 -95 -97 -99 -101 -103 -105 -107 -109 -111 -113 -115 -117 -119 -121 -123 -125 -127 -129 -132 -134 -136 -138 -140 -142 -144 -146 -148 -150 -152 -154 -156 -158 -160 -162 -164 -166 -168 -170 -172 -174 -176 -178 -180 -182 -184 -186 -188 -190 +SELECT COUNT(*) FROM t2; +COUNT(*) 192 -194 -196 -198 -200 -202 -204 -206 -208 -210 -212 -214 -216 -218 -220 -222 -224 -226 -228 -230 -232 -234 -236 -238 -240 -242 -244 -246 -248 -250 -252 -254 -256 -258 -259 -261 -263 -265 -267 -269 -271 -273 -275 -277 -279 -281 -283 -285 -287 -289 -291 -293 -295 -297 -299 -301 -303 -305 -307 -309 -311 -313 -315 -317 -319 -321 -323 -325 -327 -329 -331 -333 -335 -337 -339 -341 -343 -345 -347 -349 -351 -353 -355 -357 -359 -361 -363 -365 -367 -369 -371 -373 -375 -377 -379 -381 -383 -385 DROP TABLE t1; DROP TABLE t2; # End of tests diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.cnf b/mysql-test/suite/galera/t/galera_var_slave_threads.cnf new file mode 100644 index 00000000000..889c81b4a0a --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_slave_threads.cnf @@ -0,0 +1,7 @@ +!include ../galera_2nodes.cnf + +[mysqld.1] +auto_increment_offset=1 + +[mysqld.2] +auto_increment_offset=2 diff --git a/mysql-test/suite/galera/t/galera_var_slave_threads.test b/mysql-test/suite/galera/t/galera_var_slave_threads.test index d0784bfd871..12d8006db4b 100644 --- a/mysql-test/suite/galera/t/galera_var_slave_threads.test +++ b/mysql-test/suite/galera/t/galera_var_slave_threads.test @@ -39,7 +39,7 @@ SET GLOBAL wsrep_slave_threads = 64; INSERT INTO t1 VALUES (1); --connection node_2 -SELECT COUNT(*) = 1 FROM t1; +SELECT COUNT(*) FROM t1; # # note, in wsrep API #26, we have 2 rollbacker threads, counted as system user's @@ -177,13 +177,13 @@ while ($count) --let $wait_condition = SELECT VARIABLE_VALUE = @@wsrep_slave_threads + 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_thread_count'; --source include/wait_condition.inc -SELECT * FROM t1; -SELECT * FROM t2; +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; --connection node_1 -SELECT * FROM t1; -SELECT * FROM t2; +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t2; DROP TABLE t1; DROP TABLE t2; diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 3375073311f..f4cf49b9b84 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -80,6 +80,16 @@ extern "C" void wsrep_thd_self_abort(THD *thd) thd->wsrep_cs().bf_abort(wsrep::seqno(0)); } +extern "C" const char* wsrep_get_sr_table_name() +{ + return wsrep_sr_table_name_full; +} + +extern "C" my_bool wsrep_get_debug() +{ + return wsrep_debug; +} + extern "C" my_bool wsrep_thd_is_local(const THD *thd) { return thd->wsrep_cs().mode() == wsrep::client_state::m_local; diff --git a/sql/sql_plugin_services.ic b/sql/sql_plugin_services.ic index 0feecf219bd..8893ea361e3 100644 --- a/sql/sql_plugin_services.ic +++ b/sql/sql_plugin_services.ic @@ -156,7 +156,21 @@ static struct wsrep_service_st wsrep_handler = { wsrep_thd_ignore_table, wsrep_thd_trx_seqno, wsrep_thd_is_aborting, - wsrep_set_data_home_dir + wsrep_set_data_home_dir, + wsrep_thd_is_BF, + wsrep_thd_is_local, + wsrep_thd_self_abort, + wsrep_thd_append_key, + wsrep_thd_client_state_str, + wsrep_thd_client_mode_str, + wsrep_thd_transaction_state_str, + wsrep_thd_transaction_id, + wsrep_thd_bf_abort, + wsrep_thd_order_before, + wsrep_handle_SR_rollback, + wsrep_thd_skip_locking, + wsrep_get_sr_table_name, + wsrep_get_debug }; static struct thd_specifics_service_st thd_specifics_handler= diff --git a/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index c745bc9f4c3..2747a6fa338 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -856,7 +856,7 @@ DECLARE_THREAD(buf_dump_thread)(void*) "Dumping of buffer pool not started" " as load was incomplete"); #ifdef WITH_WSREP - } else if (wsrep_recovery) { + } else if (get_wsrep_recovery()) { #endif /* WITH_WSREP */ } else { buf_dump(FALSE/* do complete dump at shutdown */); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e194c47a518..9511051fbe2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -131,6 +131,9 @@ void close_thread_tables(THD* thd); #define tdc_size 400 #endif +#include <mysql/plugin.h> +#include <mysql/service_wsrep.h> + #include "ha_innodb.h" #include "i_s.h" #include "sync0sync.h" @@ -138,9 +141,6 @@ void close_thread_tables(THD* thd); #include <string> #include <sstream> -#include <mysql/plugin.h> -#include <mysql/service_wsrep.h> - #ifdef WITH_WSREP #include "dict0priv.h" #include <mysql/service_md5.h> @@ -148,14 +148,6 @@ void close_thread_tables(THD* thd); extern MYSQL_PLUGIN_IMPORT MYSQL_BIN_LOG mysql_bin_log; -extern bool wsrep_prepare_key_for_innodb( - THD* thd, - const uchar *cache_key, - size_t cache_key_len, - const uchar* row_id, - size_t row_id_len, - wsrep_buf_t* key, - size_t* key_len); #endif /* WITH_WSREP */ /** to force correct commit order in binlog */ diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 4acf244bf55..ed72f6d482b 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -3241,11 +3241,11 @@ row_ins_clust_index_entry( : (index->table->is_temporary() || skip_locking) ? BTR_NO_LOCKING_FLAG : 0; #ifdef UNIV_DEBUG - if (skip_locking && strcmp(wsrep_sr_table_name_full, + if (skip_locking && strcmp(wsrep_get_sr_table_name(), index->table->name.m_name)) { WSREP_ERROR("Record locking is disabled in this thread, " "but the table being modified is not " - "`%s`: `%s`.", wsrep_sr_table_name_full, + "`%s`: `%s`.", wsrep_get_sr_table_name(), index->table->name.m_name); ut_error; } diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index aeaa98b5676..2657839c93e 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4468,7 +4468,7 @@ row_search_mvcc( } #ifdef WITH_WSREP else if (wsrep_thd_skip_locking(trx->mysql_thd)) { - ut_ad(!strcmp(wsrep_sr_table_name_full, + ut_ad(!strcmp(wsrep_get_sr_table_name(), prebuilt->table->name.m_name)); set_also_gap_locks = FALSE; } diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 591ae238c43..a60210c77c8 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2458,7 +2458,7 @@ row_upd_sec_index_entry( err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::warn() << "WSREP: sec index FK check fail for deadlock" << " index " << index->name << " table " << index->table->name; @@ -2773,7 +2773,7 @@ row_upd_clust_rec_by_insert( err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::warn() << "WSREP: sec index FK check fail for deadlock" << " index " << index->name << " table " << index->table->name; @@ -3002,7 +3002,7 @@ row_upd_del_mark_clust_rec( err = DB_SUCCESS; break; case DB_DEADLOCK: - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::warn() << "WSREP: sec index FK check fail for deadlock" << " index " << index->name << " table " << index->table->name; diff --git a/storage/innobase/srv/srv0conc.cc b/storage/innobase/srv/srv0conc.cc index ec1e151c03b..b2b464e31fa 100644 --- a/storage/innobase/srv/srv0conc.cc +++ b/storage/innobase/srv/srv0conc.cc @@ -120,7 +120,7 @@ srv_conc_enter_innodb_with_atomics( #ifdef WITH_WSREP if (wsrep_on(trx->mysql_thd) && wsrep_thd_is_aborting(trx->mysql_thd)) { - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::info() << "srv_conc_enter due to MUST_ABORT"; } @@ -308,14 +308,14 @@ wsrep_srv_conc_cancel_wait( srv_conc_enter_innodb_with_atomics(). No need to cancel here, thr will wake up after os_sleep and let to enter innodb */ - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::info() << "WSREP: conc slot cancel, no atomics"; } #else // JAN: TODO: MySQL 5.7 //os_fast_mutex_lock(&srv_conc_mutex); if (trx->wsrep_event) { - if (wsrep_debug) { + if (wsrep_get_debug()) { ib::info() << "WSREP: conc slot cancel"; } os_event_set(trx->wsrep_event); diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index 54b0e75fd80..e15afcf9cd7 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -2328,7 +2328,7 @@ dberr_t srv_start(bool create_new_db) Create the dump/load thread only when not running with --wsrep-recover. */ - if (!wsrep_recovery) { + if (!get_wsrep_recovery()) { #endif /* WITH_WSREP */ /* Create the buffer pool dump/load thread */