diff --git a/deps/oblib/src/lib/signal/ob_signal_handlers.cpp b/deps/oblib/src/lib/signal/ob_signal_handlers.cpp index 1d0fddb033..f3653208fc 100644 --- a/deps/oblib/src/lib/signal/ob_signal_handlers.cpp +++ b/deps/oblib/src/lib/signal/ob_signal_handlers.cpp @@ -32,7 +32,20 @@ namespace oceanbase namespace common { -int64_t FASTSTACK_MIN_INTERVAL = 30 * 60 * 1000 * 1000; // 30min +ObSigFaststack::ObSigFaststack() + : min_interval_(30 * 60 * 1000 * 1000UL) // 30min +{ +} + +ObSigFaststack::~ObSigFaststack() +{ +} + +ObSigFaststack &ObSigFaststack::get_instance() +{ + static ObSigFaststack sig_faststack; + return sig_faststack; +} static const int SIG_SET[] = {SIGABRT, SIGBUS, SIGFPE, SIGSEGV, SIGURG}; static constexpr char MINICORE_SHELL_PATH[] = "tools/minicore.sh"; @@ -268,7 +281,7 @@ int faststack() int64_t now = ObTimeUtility::fast_current_time(); int64_t last = ATOMIC_LOAD(&last_ts); int ret = OB_SUCCESS; - if (now - last < FASTSTACK_MIN_INTERVAL) { + if (now - last < ObSigFaststack::get_instance().get_min_interval()) { ret = OB_EAGAIN; } else if (!ATOMIC_BCAS(&last_ts, last, now)) { ret = OB_EAGAIN; diff --git a/deps/oblib/src/lib/signal/ob_signal_handlers.h b/deps/oblib/src/lib/signal/ob_signal_handlers.h index a0d59dc4a0..d7329a071e 100644 --- a/deps/oblib/src/lib/signal/ob_signal_handlers.h +++ b/deps/oblib/src/lib/signal/ob_signal_handlers.h @@ -21,6 +21,20 @@ namespace oceanbase { namespace common { +class ObSigFaststack +{ +public: + ObSigFaststack(const ObSigFaststack &) = delete; + ObSigFaststack& operator=(const ObSigFaststack &) = delete; + static ObSigFaststack &get_instance(); + inline int64_t get_min_interval() const { return min_interval_; } + inline void set_min_interval(int64_t interval) { min_interval_ = interval; } +private: + ObSigFaststack(); + ~ObSigFaststack(); +private: + int64_t min_interval_; +}; extern int minicoredump(int sig, int64_t tid, pid_t& pid); extern int faststack(); } // namespace common diff --git a/src/observer/ob_server_reload_config.cpp b/src/observer/ob_server_reload_config.cpp index 1fc67a3ddd..227126a62f 100644 --- a/src/observer/ob_server_reload_config.cpp +++ b/src/observer/ob_server_reload_config.cpp @@ -18,6 +18,7 @@ #include "lib/alloc/ob_malloc_sample_struct.h" #include "lib/allocator/ob_tc_malloc.h" #include "lib/allocator/ob_mem_leak_checker.h" +#include "lib/signal/ob_signal_handlers.h" #include "share/scheduler/ob_tenant_dag_scheduler.h" #include "rpc/obrpc/ob_rpc_handler.h" #include "share/ob_cluster_version.h" @@ -319,6 +320,10 @@ int ObServerReloadConfig::operator()() { ObMallocAllocator::get_instance()->force_malloc_for_absent_tenant_ = GCONF._force_malloc_for_absent_tenant; } + + { + ObSigFaststack::get_instance().set_min_interval(GCONF._faststack_min_interval.get_value()); + } return ret; } diff --git a/src/observer/omt/ob_tenant.cpp b/src/observer/omt/ob_tenant.cpp index fb3398fc89..c747ec98bc 100644 --- a/src/observer/omt/ob_tenant.cpp +++ b/src/observer/omt/ob_tenant.cpp @@ -67,8 +67,6 @@ using namespace oceanbase::obrpc; #define SHRINK_INTERVAL (1 * 1000 * 1000) #define SLEEP_INTERVAL (60 * 1000 * 1000) -int64_t FASTSTACK_REQ_QUEUE_SIZE_THRESHOLD = INT64_MAX; - extern "C" { int ob_pthread_create(void **ptr, void *(*start_routine) (void *), void *arg); int ob_pthread_tryjoin_np(void *ptr); @@ -1521,7 +1519,8 @@ int ObTenant::recv_request(ObRequest &req) EVENT_INC(REQUEST_ENQUEUE_COUNT); } - if (OB_SIZE_OVERFLOW == ret || req_queue_.size() >= FASTSTACK_REQ_QUEUE_SIZE_THRESHOLD) { + if (OB_SIZE_OVERFLOW == ret || (GCONF._faststack_req_queue_size_threshold.get_value() > 0 && + req_queue_.size() >= GCONF._faststack_req_queue_size_threshold.get_value())) { IGNORE_RETURN faststack(); } diff --git a/src/share/parameter/ob_parameter_seed.ipp b/src/share/parameter/ob_parameter_seed.ipp index 3dae87b3b7..e28b96663f 100644 --- a/src/share/parameter/ob_parameter_seed.ipp +++ b/src/share/parameter/ob_parameter_seed.ipp @@ -1862,3 +1862,12 @@ ERRSIM_DEF_INT(errsim_backup_task_batch_size, OB_CLUSTER_PARAMETER, "0", "[0,)", "the batch size backup task receive in errsim mode" "Range: [0,) in integer", ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); +// automatically faststack +DEF_INT(_faststack_req_queue_size_threshold, OB_CLUSTER_PARAMETER, "0", "[0,)", + "When the size of the req_queue reaches this threshold, the obstack will be " + "collected automatically. Default: 0, means set off. Range: [0, +∞)", + ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); +DEF_TIME(_faststack_min_interval, OB_CLUSTER_PARAMETER, "30m", "[1s,)", + "Minimum interval for OBServer to automatically collect the obstack. " + "Default: 30min. Range: [1s,+∞)", + ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE)); diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result index 0da7d27681..0f11eff344 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/all_virtual_sys_parameter_stat.result @@ -315,6 +315,8 @@ _enable_transaction_internal_routing _enable_values_table_folding _enable_var_assign_use_das _endpoint_tenant_mapping +_faststack_min_interval +_faststack_req_queue_size_threshold _fast_commit_callback_count _follower_snapshot_read_retry_duration _force_explict_500_malloc