From bef3ebb26f200031c9a0ae44202bbf718a7df5a9 Mon Sep 17 00:00:00 2001 From: zhjc1124 Date: Sat, 10 Feb 2024 04:25:01 +0000 Subject: [PATCH] finetune observer start for easier debug --- src/observer/main.cpp | 2 + src/observer/ob_server.cpp | 91 ++++++++++++++++++++++++++------------ src/observer/ob_server.h | 3 ++ 3 files changed, 68 insertions(+), 28 deletions(-) diff --git a/src/observer/main.cpp b/src/observer/main.cpp index 71580e5b64..b72be0eb96 100644 --- a/src/observer/main.cpp +++ b/src/observer/main.cpp @@ -584,8 +584,10 @@ int main(int argc, char *argv[]) ATOMIC_STORE(&palf::election::INIT_TS, palf::election::get_monotonic_ts()); if (OB_FAIL(observer.init(opts, log_cfg))) { LOG_ERROR("observer init fail", K(ret)); + raise(SIGKILL); // force stop when fail } else if (OB_FAIL(observer.start())) { LOG_ERROR("observer start fail", K(ret)); + raise(SIGKILL); // force stop when fail } else if (OB_FAIL(observer.wait())) { LOG_ERROR("observer wait fail", K(ret)); } diff --git a/src/observer/ob_server.cpp b/src/observer/ob_server.cpp index 6ba3474f52..4785b775c4 100644 --- a/src/observer/ob_server.cpp +++ b/src/observer/ob_server.cpp @@ -1018,37 +1018,26 @@ int ObServer::start() FLOG_INFO("success to refresh server configure"); } - bool synced = false; - while (OB_SUCC(ret) && !stop_ && !synced) { - synced = multi_tenant_.has_synced(); - if (!synced) { - SLEEP(1); - } - } - FLOG_INFO("check if multi tenant synced", KR(ret), K(stop_), K(synced)); - - bool schema_ready = false; - while (OB_SUCC(ret) && !stop_ && !schema_ready) { - schema_ready = schema_service_.is_sys_full_schema(); - if (!schema_ready) { - SLEEP(1); - } - } - FLOG_INFO("check if schema ready", KR(ret), K(stop_), K(schema_ready)); - - bool timezone_usable = false; - if (FAILEDx(tenant_timezone_mgr_.start())) { - LOG_ERROR("fail to start tenant timezone mgr", KR(ret)); + // check if multi tenant synced + if (FAILEDx(check_if_multi_tenant_synced())) { + LOG_ERROR("fail to check if multi tenant synced", KR(ret)); } else { - FLOG_INFO("success to start tenant timezone mgr"); + FLOG_INFO("success to check if multi tenant synced"); } - while (OB_SUCC(ret) && !stop_ && !timezone_usable) { - timezone_usable = tenant_timezone_mgr_.is_usable(); - if (!timezone_usable) { - SLEEP(1); - } + + // check if schema ready + if (FAILEDx(check_if_schema_ready())) { + LOG_ERROR("fail to check if schema ready", KR(ret)); + } else { + FLOG_INFO("success to check if schema ready"); + } + + // check if timezone usable + if (FAILEDx(check_if_timezone_usable())) { + LOG_ERROR("fail to check if timezone usable", KR(ret)); + } else { + FLOG_INFO("success to check if timezone usable"); } - FLOG_INFO("check if timezone usable", KR(ret), K(stop_), K(timezone_usable)); // check log replay and user tenant schema refresh status if (OB_SUCC(ret)) { @@ -1123,6 +1112,52 @@ int ObServer::try_update_hidden_sys() return ret; } +int ObServer::check_if_multi_tenant_synced() +{ + int ret = OB_SUCCESS; + bool synced = false; + while (OB_SUCC(ret) && !stop_ && !synced) { + synced = multi_tenant_.has_synced(); + if (!synced) { + SLEEP(1); + } + } + FLOG_INFO("check if multi tenant synced", KR(ret), K(stop_), K(synced)); + return ret; +} + +int ObServer::check_if_schema_ready() +{ + int ret = OB_SUCCESS; + bool schema_ready = false; + while (OB_SUCC(ret) && !stop_ && !schema_ready) { + schema_ready = schema_service_.is_sys_full_schema(); + if (!schema_ready) { + SLEEP(1); + } + } + FLOG_INFO("check if schema ready", KR(ret), K(stop_), K(schema_ready)); + return ret; +} + +int ObServer::check_if_timezone_usable() +{ + int ret = OB_SUCCESS; + bool timezone_usable = false; + if (FAILEDx(tenant_timezone_mgr_.start())) { + LOG_ERROR("fail to start tenant timezone mgr", KR(ret)); + } else { + FLOG_INFO("success to start tenant timezone mgr"); + } + while (OB_SUCC(ret) && !stop_ && !timezone_usable) { + timezone_usable = tenant_timezone_mgr_.is_usable(); + if (!timezone_usable) { + SLEEP(1); + } + } + FLOG_INFO("check if timezone usable", KR(ret), K(stop_), K(timezone_usable)); + return ret; +} void ObServer::prepare_stop() { prepare_stop_ = true; diff --git a/src/observer/ob_server.h b/src/observer/ob_server.h index 81988b8dc9..2471949f46 100644 --- a/src/observer/ob_server.h +++ b/src/observer/ob_server.h @@ -318,6 +318,9 @@ private: void check_user_tenant_schema_refreshed(const common::ObIArray &tenant_ids, const int64_t expire_time); void check_log_replay_over(const common::ObIArray &tenant_ids, const int64_t expire_time); int try_update_hidden_sys(); + int check_if_multi_tenant_synced(); + int check_if_schema_ready(); + int check_if_timezone_usable(); int parse_mode(); void deinit_zlib_lite_compressor();