From f1094939771046cfd9c77dbabdf3271f81bc704c Mon Sep 17 00:00:00 2001 From: liucc1997 <1192520566@qq.com> Date: Thu, 13 Jul 2023 06:48:09 +0000 Subject: [PATCH] arbitration_mode support authentication and adjust default net thread count --- deps/ussl-hook/loop/auth-methods.c | 2 +- src/observer/ob_srv_network_frame.cpp | 19 ------------------- src/observer/ob_srv_network_frame.h | 10 +++++----- src/share/config/ob_server_config.cpp | 18 ++++++++++++++---- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/deps/ussl-hook/loop/auth-methods.c b/deps/ussl-hook/loop/auth-methods.c index 138d8233e..bdbbfe934 100644 --- a/deps/ussl-hook/loop/auth-methods.c +++ b/deps/ussl-hook/loop/auth-methods.c @@ -37,7 +37,7 @@ int get_server_auth_methods() void set_client_auth_methods(const int methods) { - g_ussl_client_auth_methods = methods; + ATOMIC_STORE(&g_ussl_client_auth_methods, methods); } int get_client_auth_methods() diff --git a/src/observer/ob_srv_network_frame.cpp b/src/observer/ob_srv_network_frame.cpp index f56f041b1..82827279e 100644 --- a/src/observer/ob_srv_network_frame.cpp +++ b/src/observer/ob_srv_network_frame.cpp @@ -69,25 +69,6 @@ static bool enable_new_sql_nio() return GCONF._enable_new_sql_nio; } -static int get_default_net_thread_count() -{ - int cnt = 1; - int cpu_num = get_cpu_num(); - - if (cpu_num <= 4) { - cnt = 1; - } else if (cpu_num <= 8) { - cnt = 2; - } else if (cpu_num <= 16) { - cnt = 4; - } else if (cpu_num <= 32) { - cnt = 7; - } else { - cnt = max(8, get_cpu_num() / 6); - } - return cnt; -} - static int update_tcp_keepalive_parameters_for_sql_nio_server(int tcp_keepalive_enabled, int64_t tcp_keepidle, int64_t tcp_keepintvl, int64_t tcp_keepcnt) { int ret = OB_SUCCESS; diff --git a/src/observer/ob_srv_network_frame.h b/src/observer/ob_srv_network_frame.h index 9544a7f44..4b60ab5a3 100644 --- a/src/observer/ob_srv_network_frame.h +++ b/src/observer/ob_srv_network_frame.h @@ -120,18 +120,18 @@ ObSrvNetworkFrame::get_xlator() { static int get_default_net_thread_count() { int cnt = 1; - int cpu_num = static_cast(get_cpu_num()); + int cpu_num = static_cast(get_cpu_count()); if (cpu_num <= 4) { - cnt = 2; + cnt = 1; } else if (cpu_num <= 8) { - cnt = 3; + cnt = 2; } else if (cpu_num <= 16) { - cnt = 5; + cnt = 4; } else if (cpu_num <= 32) { cnt = 7; } else { - cnt = max(8, static_cast(get_cpu_num()) / 6); + cnt = max(8, cpu_num / 6); } return cnt; } diff --git a/src/share/config/ob_server_config.cpp b/src/share/config/ob_server_config.cpp index d04b4596c..33b94c90a 100644 --- a/src/share/config/ob_server_config.cpp +++ b/src/share/config/ob_server_config.cpp @@ -28,6 +28,10 @@ #include "observer/omt/ob_tenant_config_mgr.h" #include "share/ob_rpc_struct.h" #include "observer/ob_server_struct.h" +extern "C" { +#include "ussl-hook.h" +#include "auth-methods.h" +} namespace oceanbase { namespace common @@ -415,15 +419,21 @@ OB_DEF_SERIALIZE_SIZE(ObServerConfig) } // end of namespace common namespace obrpc { bool enable_pkt_nio() { - return GCONF._enable_pkt_nio - && (!OBSERVER.is_arbitration_mode()) - && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_0_0; + bool bool_ret = false; + if (OB_UNLIKELY(OBSERVER.is_arbitration_mode())) { + bool enable_clent_auth = (get_client_auth_methods() != USSL_AUTH_NONE); + bool_ret = GCONF._enable_pkt_nio && enable_clent_auth; + } else { + bool_ret = GCONF._enable_pkt_nio && GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_2_0_0; + } + return bool_ret; } + int64_t get_max_rpc_packet_size() { return GCONF._max_rpc_packet_size; } -} +} // end of namespace obrpc } // end of namespace oceanbase namespace easy