From 5e392ca75ef7fe2cf19e3300cffbfbb4549903a0 Mon Sep 17 00:00:00 2001 From: yu34po Date: Fri, 11 Feb 2022 15:32:15 +0800 Subject: [PATCH] add request follower config --- src/obproxy/obutils/ob_proxy_config.h | 1 + src/obproxy/proxy/mysql/ob_mysql_client_session.cpp | 5 +++++ src/obproxy/proxy/mysqllib/ob_mysql_config_processor.cpp | 5 ++++- src/obproxy/proxy/mysqllib/ob_mysql_config_processor.h | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/obproxy/obutils/ob_proxy_config.h b/src/obproxy/obutils/ob_proxy_config.h index 60d46b82..2fc3ac5d 100644 --- a/src/obproxy/obutils/ob_proxy_config.h +++ b/src/obproxy/obutils/ob_proxy_config.h @@ -193,6 +193,7 @@ class ObProxyConfig : public common::ObCommonConfig DEF_BOOL(enable_cluster_checkout, "true", "if enable cluster checkout, proxy will send cluster name when login and server will check it", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER); DEF_BOOL(enable_proxy_scramble, "false", "if enable proxy scramble, proxy will send client its variable scramble num, not support old observer", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS); DEF_BOOL(enable_client_ip_checkout, "true", "if enabled, proxy send client ip when login", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER); + DEF_BOOL(enable_force_request_follower, "false", "force request follower ", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_SYS); //connection related DEF_INT(connect_observer_max_retries, "3", "[2,5]", "max retries to do connect", CFG_NO_NEED_REBOOT, CFG_SECTION_OBPROXY, CFG_VISIBLE_LEVEL_USER); diff --git a/src/obproxy/proxy/mysql/ob_mysql_client_session.cpp b/src/obproxy/proxy/mysql/ob_mysql_client_session.cpp index 0673c554..7b4b834a 100644 --- a/src/obproxy/proxy/mysql/ob_mysql_client_session.cpp +++ b/src/obproxy/proxy/mysql/ob_mysql_client_session.cpp @@ -342,6 +342,11 @@ int ObMysqlClientSession::new_connection( } } + // set weak read flag global + if (obutils::get_global_proxy_config().enable_force_request_follower) { + session_info_.set_is_request_follower_user(true); + } + // 2. handle_new_connection no matter convert vip to tenant result. handle_new_connection(); } diff --git a/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.cpp b/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.cpp index f3f5848f..f6a3f975 100644 --- a/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.cpp +++ b/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.cpp @@ -79,6 +79,7 @@ ObMysqlConfigParams::ObMysqlConfigParams() enable_bad_route_reject_(false), enable_cluster_checkout_(true), enable_client_ip_checkout_(true), + enable_force_request_follower_(false), enable_proxy_scramble_(false), enable_compression_protocol_(false), enable_ob_protocol_v2_(false), @@ -172,6 +173,7 @@ int ObMysqlConfigParams::assign_config(const ObProxyConfig &proxy_config) CONFIG_ITEM_ASSIGN(enable_bad_route_reject); CONFIG_ITEM_ASSIGN(enable_cluster_checkout); CONFIG_ITEM_ASSIGN(enable_client_ip_checkout); + CONFIG_ITEM_ASSIGN(enable_force_request_follower); CONFIG_ITEM_ASSIGN(enable_proxy_scramble); CONFIG_ITEM_ASSIGN(enable_compression_protocol); CONFIG_ITEM_ASSIGN(enable_ob_protocol_v2); @@ -317,7 +319,8 @@ DEF_TO_STRING(ObMysqlConfigParams) K_(proxy_service_mode), K_(server_routing_mode), K_(proxy_id), K_(proxy_idc_name), K_(client_max_memory_size), K_(default_inactivity_timeout), K_(enable_partition_table_route), K_(enable_pl_route), - K_(enable_cluster_checkout), K_(enable_client_ip_checkout), K_(enable_proxy_scramble), + K_(enable_cluster_checkout), K_(enable_client_ip_checkout), K_(enable_force_request_follower), + K_(enable_proxy_scramble), K_(enable_compression_protocol), K_(enable_ob_protocol_v2), K_(enable_reroute), K_(enable_index_route), K_(enable_causal_order_read)); J_OBJ_END(); diff --git a/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.h b/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.h index f46c00bf..2d5540b9 100644 --- a/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.h +++ b/src/obproxy/proxy/mysqllib/ob_mysql_config_processor.h @@ -107,6 +107,7 @@ struct ObMysqlConfigParams : public ObConfigInfo CfgBool enable_bad_route_reject_; CfgBool enable_cluster_checkout_; CfgBool enable_client_ip_checkout_; + CfgBool enable_force_request_follower_; CfgBool enable_proxy_scramble_; CfgBool enable_compression_protocol_; CfgBool enable_ob_protocol_v2_;