diff options
Diffstat (limited to 'storage/spider/spd_param.cc')
-rw-r--r-- | storage/spider/spd_param.cc | 310 |
1 files changed, 303 insertions, 7 deletions
diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc index c419e05a459..6970f19e85f 100644 --- a/storage/spider/spd_param.cc +++ b/storage/spider/spd_param.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2015 Kentoku Shiba +/* Copyright (C) 2008-2017 Kentoku Shiba This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11,11 +11,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #define MYSQL_SERVER 1 #include <my_global.h> -#include <my_global.h> #include "mysql_version.h" #include "spd_environ.h" #if MYSQL_VERSION_ID < 50500 @@ -89,6 +88,17 @@ static int spider_direct_aggregate(THD *thd, SHOW_VAR *var, char *buff) DBUG_RETURN(error_num); } +static int spider_parallel_search(THD *thd, SHOW_VAR *var, char *buff) +{ + int error_num = 0; + SPIDER_TRX *trx; + DBUG_ENTER("spider_parallel_search"); + var->type = SHOW_LONGLONG; + if ((trx = spider_get_trx(thd, TRUE, &error_num))) + var->value = (char *) &trx->parallel_search_count; + DBUG_RETURN(error_num); +} + #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) static int spider_hs_result_free(THD *thd, SHOW_VAR *var, char *buff) { @@ -122,11 +132,15 @@ struct st_mysql_show_var spider_status_variables[] = (char *) &spider_direct_order_limit, SHOW_SIMPLE_FUNC}, {"Spider_direct_aggregate", (char *) &spider_direct_aggregate, SHOW_SIMPLE_FUNC}, + {"Spider_parallel_search", + (char *) &spider_parallel_search, SHOW_SIMPLE_FUNC}, #else {"Spider_direct_order_limit", (char *) &spider_direct_order_limit, SHOW_FUNC}, {"Spider_direct_aggregate", (char *) &spider_direct_aggregate, SHOW_FUNC}, + {"Spider_parallel_search", + (char *) &spider_parallel_search, SHOW_FUNC}, #endif #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #ifdef SPIDER_HAS_SHOW_SIMPLE_FUNC @@ -411,6 +425,29 @@ uint spider_param_force_commit( } /* + 0: register all XA transaction + 1: register only write XA transaction + */ +static MYSQL_THDVAR_UINT( + xa_register_mode, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Mode of XA transaction register into system table", /* comment */ + NULL, /* check */ + NULL, /* update */ + 1, /* def */ + 0, /* min */ + 1, /* max */ + 0 /* blk */ +); + +uint spider_param_xa_register_mode( + THD *thd +) { + DBUG_ENTER("spider_param_xa_register_mode"); + DBUG_RETURN(THDVAR(thd, xa_register_mode)); +} + +/* -1 :use table parameter 0-:offset */ @@ -1668,7 +1705,8 @@ double spider_param_crd_weight( /* -1 :use table parameter 0 :Background confirmation is disabled - 1 :Background confirmation is enabled + 1 :Background confirmation is enabled (create thread per table/partition) + 2 :Background confirmation is enabled (use static threads) */ static MYSQL_THDVAR_INT( crd_bg_mode, /* name */ @@ -1678,7 +1716,7 @@ static MYSQL_THDVAR_INT( NULL, /* update */ -1, /* def */ -1, /* min */ - 1, /* max */ + 2, /* max */ 0 /* blk */ ); @@ -1779,7 +1817,8 @@ int spider_param_sts_sync( /* -1 :use table parameter 0 :Background confirmation is disabled - 1 :Background confirmation is enabled + 1 :Background confirmation is enabled (create thread per table/partition) + 2 :Background confirmation is enabled (use static threads) */ static MYSQL_THDVAR_INT( sts_bg_mode, /* name */ @@ -1789,7 +1828,7 @@ static MYSQL_THDVAR_INT( NULL, /* update */ -1, /* def */ -1, /* min */ - 1, /* max */ + 2, /* max */ 0 /* blk */ ); @@ -2704,6 +2743,34 @@ int spider_param_skip_default_condition( /* -1 :use table parameter + 0 :not skip + 1 :skip parallel search if query is not SELECT statement + 2 :skip parallel search if query has SQL_NO_CACHE + 3 :1+2 + */ +static MYSQL_THDVAR_INT( + skip_parallel_search, /* name */ + PLUGIN_VAR_RQCMDARG, /* opt */ + "Skip parallel search by specific conditions", /* comment */ + NULL, /* check */ + NULL, /* update */ + -1, /* def */ + -1, /* min */ + 3, /* max */ + 0 /* blk */ +); + +int spider_param_skip_parallel_search( + THD *thd, + int skip_parallel_search +) { + DBUG_ENTER("spider_param_skip_parallel_search"); + DBUG_RETURN(THDVAR(thd, skip_parallel_search) == -1 ? + skip_parallel_search : THDVAR(thd, skip_parallel_search)); +} + +/* + -1 :use table parameter 0 :not send directly 1-:send directly */ @@ -2829,6 +2896,66 @@ my_bool spider_param_general_log() DBUG_RETURN(spider_general_log); } +/* + FALSE: no pushdown hints + TRUE: pushdown hints + */ +static MYSQL_THDVAR_BOOL( + index_hint_pushdown, /* name */ + PLUGIN_VAR_OPCMDARG, /* opt */ + "switch to control if push down index hint, like force_index", /* comment */ + NULL, /* check */ + NULL, /* update */ + FALSE /* def */ +); + +my_bool spider_param_index_hint_pushdown( + THD *thd +) { + DBUG_ENTER("spider_param_index_hint_pushdown"); + DBUG_RETURN(THDVAR(thd, index_hint_pushdown)); +} + +static uint spider_max_connections; +static MYSQL_SYSVAR_UINT( + max_connections, + spider_max_connections, + PLUGIN_VAR_RQCMDARG, + "the values, as the max conncetion from spider to remote mysql. Default 0, mean unlimit the connections", + NULL, + NULL, + 0, /* def */ + 0, /* min */ + 99999, /* max */ + 0 /* blk */ +); + +uint spider_param_max_connections() +{ + DBUG_ENTER("spider_param_max_connections"); + DBUG_RETURN(spider_max_connections); +} + +static uint spider_conn_wait_timeout; +static MYSQL_SYSVAR_UINT( + conn_wait_timeout, + spider_conn_wait_timeout, + PLUGIN_VAR_RQCMDARG, + "the values, as the max waiting time when spider get a remote conn", + NULL, + NULL, + 10, /* def */ + 0, /* min */ + 1000, /* max */ + 0 /* blk */ +); + +uint spider_param_conn_wait_timeout() +{ + DBUG_ENTER("spider_param_conn_wait_timeout"); + DBUG_RETURN(spider_conn_wait_timeout); +} + static uint spider_log_result_errors; /* 0: no log @@ -3012,6 +3139,162 @@ int spider_param_bka_table_name_type( bka_table_name_type : THDVAR(thd, bka_table_name_type)); } +static int spider_store_last_sts; +/* + -1 : use table parameter + 0 : do not store + 1 : do store + */ +static MYSQL_SYSVAR_INT( + store_last_sts, + spider_store_last_sts, + PLUGIN_VAR_RQCMDARG, + "Store last sts result into system table", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_store_last_sts( + int store_last_sts +) { + DBUG_ENTER("spider_param_store_last_sts"); + DBUG_RETURN(spider_store_last_sts == -1 ? + store_last_sts : spider_store_last_sts); +} + +static int spider_store_last_crd; +/* + -1 : use table parameter + 0 : do not store + 1 : do store + */ +static MYSQL_SYSVAR_INT( + store_last_crd, + spider_store_last_crd, + PLUGIN_VAR_RQCMDARG, + "Store last crd result into system table", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_store_last_crd( + int store_last_crd +) { + DBUG_ENTER("spider_param_store_last_crd"); + DBUG_RETURN(spider_store_last_crd == -1 ? + store_last_crd : spider_store_last_crd); +} + +static int spider_load_sts_at_startup; +/* + -1 : use table parameter + 0 : do not load + 1 : do load + */ +static MYSQL_SYSVAR_INT( + load_sts_at_startup, + spider_load_sts_at_startup, + PLUGIN_VAR_RQCMDARG, + "Load sts from system table at startup", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_load_sts_at_startup( + int load_sts_at_startup +) { + DBUG_ENTER("spider_param_load_sts_at_startup"); + DBUG_RETURN(spider_load_sts_at_startup == -1 ? + load_sts_at_startup : spider_load_sts_at_startup); +} + +static int spider_load_crd_at_startup; +/* + -1 : use table parameter + 0 : do not load + 1 : do load + */ +static MYSQL_SYSVAR_INT( + load_crd_at_startup, + spider_load_crd_at_startup, + PLUGIN_VAR_RQCMDARG, + "Load crd from system table at startup", + NULL, + NULL, + -1, + -1, + 1, + 0 +); + +int spider_param_load_crd_at_startup( + int load_crd_at_startup +) { + DBUG_ENTER("spider_param_load_crd_at_startup"); + DBUG_RETURN(spider_load_crd_at_startup == -1 ? + load_crd_at_startup : spider_load_crd_at_startup); +} + +#ifndef WITHOUT_SPIDER_BG_SEARCH +static uint spider_table_sts_thread_count; +/* + 1-: thread count + */ +static MYSQL_SYSVAR_UINT( + table_sts_thread_count, + spider_table_sts_thread_count, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Static thread count of table sts", + NULL, + NULL, + 10, + 1, + 4294967295U, + 0 +); + +uint spider_param_table_sts_thread_count() +{ + DBUG_ENTER("spider_param_table_sts_thread_count"); + DBUG_RETURN(spider_table_sts_thread_count); +} + +static uint spider_table_crd_thread_count; +/* + 1-: thread count + */ +static MYSQL_SYSVAR_UINT( + table_crd_thread_count, + spider_table_crd_thread_count, + PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, + "Static thread count of table crd", + NULL, + NULL, + 10, + 1, + 4294967295U, + 0 +); + +uint spider_param_table_crd_thread_count() +{ + DBUG_ENTER("spider_param_table_crd_thread_count"); + DBUG_RETURN(spider_table_crd_thread_count); +} +#endif + static struct st_mysql_storage_engine spider_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; @@ -3026,6 +3309,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(internal_xa), MYSQL_SYSVAR(internal_xa_snapshot), MYSQL_SYSVAR(force_commit), + MYSQL_SYSVAR(xa_register_mode), MYSQL_SYSVAR(internal_offset), MYSQL_SYSVAR(internal_limit), MYSQL_SYSVAR(split_read), @@ -3077,6 +3361,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = { #ifdef WITH_PARTITION_STORAGE_ENGINE MYSQL_SYSVAR(crd_sync), #endif + MYSQL_SYSVAR(store_last_crd), + MYSQL_SYSVAR(load_crd_at_startup), MYSQL_SYSVAR(crd_type), MYSQL_SYSVAR(crd_weight), #ifndef WITHOUT_SPIDER_BG_SEARCH @@ -3087,6 +3373,8 @@ static struct st_mysql_sys_var* spider_system_variables[] = { #ifdef WITH_PARTITION_STORAGE_ENGINE MYSQL_SYSVAR(sts_sync), #endif + MYSQL_SYSVAR(store_last_sts), + MYSQL_SYSVAR(load_sts_at_startup), #ifndef WITHOUT_SPIDER_BG_SEARCH MYSQL_SYSVAR(sts_bg_mode), #endif @@ -3128,6 +3416,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(error_read_mode), MYSQL_SYSVAR(error_write_mode), MYSQL_SYSVAR(skip_default_condition), + MYSQL_SYSVAR(skip_parallel_search), MYSQL_SYSVAR(direct_order_limit), MYSQL_SYSVAR(read_only_mode), #ifdef HA_CAN_BULK_ACCESS @@ -3138,6 +3427,9 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(udf_ds_use_real_table), #endif MYSQL_SYSVAR(general_log), + MYSQL_SYSVAR(index_hint_pushdown), + MYSQL_SYSVAR(max_connections), + MYSQL_SYSVAR(conn_wait_timeout), MYSQL_SYSVAR(log_result_errors), MYSQL_SYSVAR(log_result_error_with_sql), MYSQL_SYSVAR(version), @@ -3147,6 +3439,10 @@ static struct st_mysql_sys_var* spider_system_variables[] = { MYSQL_SYSVAR(delete_all_rows_type), MYSQL_SYSVAR(bka_table_name_type), MYSQL_SYSVAR(connect_error_interval), +#ifndef WITHOUT_SPIDER_BG_SEARCH + MYSQL_SYSVAR(table_sts_thread_count), + MYSQL_SYSVAR(table_crd_thread_count), +#endif NULL }; |