From 062a57e12a5454dea266ce4cf1296d0c9ffadb15 Mon Sep 17 00:00:00 2001 From: obdev Date: Wed, 7 Sep 2022 05:02:36 +0000 Subject: [PATCH] [CP] add defense for drop tenant and trans desc reset --- src/storage/transaction/ob_trans_define.cpp | 12 ++++++++++++ src/storage/transaction/ob_ts_mgr.h | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/storage/transaction/ob_trans_define.cpp b/src/storage/transaction/ob_trans_define.cpp index 8994e3812..b76b236e3 100644 --- a/src/storage/transaction/ob_trans_define.cpp +++ b/src/storage/transaction/ob_trans_define.cpp @@ -1075,6 +1075,18 @@ void ObTransDesc::consistency_wait() void ObTransDesc::reset() { + if (OB_NOT_NULL(sche_ctx_)) { + need_print_trace_log_ = true; + if (EXECUTE_COUNT_PER_SEC(64)) { + TRANS_LOG(WARN, "reset trans desc without release sche ctx", K(*this), KP(sche_ctx_), "lbt", lbt()); + } + } + if (OB_NOT_NULL(part_ctx_)) { + need_print_trace_log_ = true; + if (EXECUTE_COUNT_PER_SEC(64)) { + TRANS_LOG(WARN, "reset trans desc without release part ctx", K(*this), KP(part_ctx_), "lbt", lbt()); + } + } if (need_print_trace_log_) { FORCE_PRINT_TRACE(&tlog_, "[trans error] "); } diff --git a/src/storage/transaction/ob_ts_mgr.h b/src/storage/transaction/ob_ts_mgr.h index 746bf802c..adad974fc 100644 --- a/src/storage/transaction/ob_ts_mgr.h +++ b/src/storage/transaction/ob_ts_mgr.h @@ -14,6 +14,7 @@ #define OCEANBASE_TRANSACTION_OB_TS_MGR_ #include +#include "common/ob_clock_generator.h" #include "lib/utility/ob_print_utils.h" #include "lib/lock/ob_drw_lock.h" #include "lib/hash/ob_link_hashmap.h" @@ -189,11 +190,16 @@ public: } int set_invalid(); int switch_ts_source(const uint64_t tenant_id, const int ts_type); + TO_STRING_KV(K_(tenant_id), K_(last_check_switch_ts), K_(last_obtain_switch_ts), K_(check_switch_interval), + K_(cur_ts_type), K_(last_access_ts)); private: int switch_ts_source_(const uint64_t tenant_id, const int ts_type); void revert_ts_source_(ObTsSourceGuard& guard); +public: + static const int64_t DEFAULT_NEED_PRINT_INTERVAL_US = 120 * 1000 * 1000; + private: static const int64_t DEFAULT_CHECK_SWITCH_INTERVAL_US = 100 * 1000; static const int64_t MAX_CHECK_SWITCH_INTERVAL_US = 3 * 1000 * 1000; @@ -265,6 +271,12 @@ public: ret = common::OB_ERR_UNEXPECTED; TRANS_LOG(ERROR, "ha gts source is null", KR(ret), K(gts_tenant_info)); } else { + if (common::ObClockGenerator::getClock() - ts_source_info->get_last_obtain_switch_ts() >= + ObTsSourceInfo::DEFAULT_NEED_PRINT_INTERVAL_US) { + if (EXECUTE_COUNT_PER_SEC(5)) { + TRANS_LOG(WARN, "gts source maybe need delete", K(gts_tenant_info), K(*ts_source_info)); + } + } if (OB_FAIL(gts_source->refresh_gts(false))) { if (EXECUTE_COUNT_PER_SEC(1)) { TRANS_LOG(WARN, "refresh gts failed", KR(ret), K(gts_tenant_info));