From f5fb2760c9fc9b2459b838b4abd34e393d33b448 Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 16 Feb 2023 04:12:28 +0000 Subject: [PATCH] fix: add recycle config latency check --- src/observer/omt/ob_tenant_config.cpp | 3 ++- src/observer/omt/ob_tenant_config.h | 2 ++ src/observer/omt/ob_tenant_config_mgr.cpp | 2 +- src/observer/omt/ob_tenant_config_mgr.h | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/observer/omt/ob_tenant_config.cpp b/src/observer/omt/ob_tenant_config.cpp index a1ebb32343..de533f609b 100644 --- a/src/observer/omt/ob_tenant_config.cpp +++ b/src/observer/omt/ob_tenant_config.cpp @@ -37,7 +37,7 @@ ObTenantConfig::ObTenantConfig(uint64_t tenant_id) : tenant_id_(tenant_id), current_version_(INITIAL_TENANT_CONF_VERSION), mutex_(), update_task_(), system_config_(), config_mgr_(nullptr), - lock_(ObLatchIds::CONFIG_LOCK), is_deleting_(false) + lock_(ObLatchIds::CONFIG_LOCK), is_deleting_(false), create_timestamp_(0L) { } @@ -45,6 +45,7 @@ int ObTenantConfig::init(ObTenantConfigMgr *config_mgr) { int ret = OB_SUCCESS; config_mgr_ = config_mgr; + create_timestamp_ = ObTimeUtility::current_time(); if (OB_FAIL(system_config_.init())) { LOG_ERROR("init system config failed", K(ret)); } else if (OB_FAIL(update_task_.init(config_mgr, this))) { diff --git a/src/observer/omt/ob_tenant_config.h b/src/observer/omt/ob_tenant_config.h index f6eb5ddf18..575adfeac7 100644 --- a/src/observer/omt/ob_tenant_config.h +++ b/src/observer/omt/ob_tenant_config.h @@ -88,6 +88,7 @@ public: uint64_t get_tenant_id() const { return tenant_id_; } int64_t get_current_version() const { return current_version_; } const TenantConfigUpdateTask &get_update_task() const { return update_task_; } + int64_t get_create_timestamp() const { return create_timestamp_; } int got_version(int64_t version, const bool remove_repeat); int update_local(int64_t expected_version, common::ObMySQLProxy::MySQLResult &result, bool save2file = true); @@ -106,6 +107,7 @@ private: // protect this object from being deleted in OTC_MGR.del_tenant_config mutable common::DRWLock lock_; bool is_deleting_; + int64_t create_timestamp_; public: /////////////////////////////////////////////////////////////////////////////// diff --git a/src/observer/omt/ob_tenant_config_mgr.cpp b/src/observer/omt/ob_tenant_config_mgr.cpp index 7591faa115..7c2b661d43 100644 --- a/src/observer/omt/ob_tenant_config_mgr.cpp +++ b/src/observer/omt/ob_tenant_config_mgr.cpp @@ -307,7 +307,7 @@ int ObTenantConfigMgr::del_tenant_config(uint64_t tenant_id) LOG_WARN("get tenant config failed", K(tenant_id), K(ret)); } else if (OB_FAIL(GSCHEMASERVICE.check_if_tenant_has_been_dropped(tenant_id, has_dropped))) { LOG_WARN("failed to check tenant has been dropped", K(tenant_id)); - } else if (!has_dropped) { + } else if (!has_dropped && ObTimeUtility::current_time() - config->get_create_timestamp() < RECYCLE_LATENCY) { LOG_WARN("tenant still exist, try to delete tenant config later...", K(tenant_id)); } else { static const int DEL_TRY_TIMES = 30; diff --git a/src/observer/omt/ob_tenant_config_mgr.h b/src/observer/omt/ob_tenant_config_mgr.h index d3820c846c..e7b0756610 100644 --- a/src/observer/omt/ob_tenant_config_mgr.h +++ b/src/observer/omt/ob_tenant_config_mgr.h @@ -166,6 +166,7 @@ public: OB_UNIS_VERSION(1); private: + static const int64_t RECYCLE_LATENCY = 30L * 60L * 1000L * 1000L; ObTenantConfigMgr(); bool inited_; common::ObAddr self_;