From a0afc03a6217478f9ce3a31f516c95addad6e5cf Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 29 Oct 2024 04:52:49 +0000 Subject: [PATCH] fix some bug of tables, log show and tenant gc --- .../ob_shared_storage_net_throt_service.cpp | 4 + .../ob_all_virtual_io_status.cpp | 1 + .../ob_all_virtual_shared_storage_quota.cpp | 6 +- src/share/io/ob_io_manager.cpp | 86 +++++++++++++++++-- src/share/io/ob_io_manager.h | 2 + 5 files changed, 93 insertions(+), 6 deletions(-) diff --git a/src/observer/net/ob_shared_storage_net_throt_service.cpp b/src/observer/net/ob_shared_storage_net_throt_service.cpp index 2dd550ee7..163df578b 100644 --- a/src/observer/net/ob_shared_storage_net_throt_service.cpp +++ b/src/observer/net/ob_shared_storage_net_throt_service.cpp @@ -133,6 +133,10 @@ int ObSharedStorageNetThrotManager::clear_expired_infos() const int64_t current_time = ObTimeUtility::current_time(); ObSpinLockGuard guard(lock_); + if (OB_SUCCESS != OB_IO_MANAGER.get_tc().gc_tenant_infos()) { + LOG_WARN("SSNT:failed to gc tenant infos for IO MANAGER", K(ret)); + } + // clean up expired storages if (storage_key_limit_map_.size() == 0) { } else if (REACH_TIME_INTERVAL(1 * 60 * 1000L * 1000L)){ // 1min diff --git a/src/observer/virtual_table/ob_all_virtual_io_status.cpp b/src/observer/virtual_table/ob_all_virtual_io_status.cpp index 23ab55a5b..a1f3c849a 100644 --- a/src/observer/virtual_table/ob_all_virtual_io_status.cpp +++ b/src/observer/virtual_table/ob_all_virtual_io_status.cpp @@ -1249,6 +1249,7 @@ int ObAllVirtualFunctionIOStat::record_function_info(const uint64_t tenant_id, for (int i = 0; OB_SUCC(ret) && i < FUNC_NUM; ++i) { for (int j = 0; OB_SUCC(ret) && j < GROUP_MODE_NUM; ++j) { FuncInfo item; + item.tenant_id_ = tenant_id; item.function_type_ = static_cast(i); item.group_mode_ = static_cast(j); if (i >= func_usages.count()) { diff --git a/src/observer/virtual_table/ob_all_virtual_shared_storage_quota.cpp b/src/observer/virtual_table/ob_all_virtual_shared_storage_quota.cpp index d2377fb82..89dfbafbd 100644 --- a/src/observer/virtual_table/ob_all_virtual_shared_storage_quota.cpp +++ b/src/observer/virtual_table/ob_all_virtual_shared_storage_quota.cpp @@ -243,7 +243,11 @@ int ObVirtualSharedStorageQuota::add_row( break; } case ASSIGN: { - cells[i].set_int(limit.value_); + if (limit.value_ <= 0 || limit.value_ >= INT64_MAX) { + cells[i].set_int(INT64_MAX); + } else { + cells[i].set_int(limit.value_); + } break; } default: { diff --git a/src/share/io/ob_io_manager.cpp b/src/share/io/ob_io_manager.cpp index 12e8e940a..fd2cceed5 100644 --- a/src/share/io/ob_io_manager.cpp +++ b/src/share/io/ob_io_manager.cpp @@ -256,13 +256,13 @@ void ObTrafficControl::print_status() entry.first.get_tenant_id(), entry.first.get_storage_id(), bw_in / 1024, - entry.second.ibw_clock_.iops_ / 1024, + entry.second.ibw_clock_.iops_ == 0 ? INT64_MAX : entry.second.ibw_clock_.iops_ / 1024, bw_out / 1024, - entry.second.obw_clock_.iops_ / 1024, + entry.second.obw_clock_.iops_ == 0 ? INT64_MAX : entry.second.obw_clock_.iops_ / 1024, req_in, - entry.second.ips_clock_.iops_, + entry.second.ips_clock_.iops_ == 0 ? INT64_MAX : entry.second.ips_clock_.iops_, req_out, - entry.second.ops_clock_.iops_, + entry.second.ops_clock_.iops_ == 0 ? INT64_MAX : entry.second.ops_clock_.iops_, tag, entry.second.tagps_clock_.iops_ / 1024); } @@ -320,6 +320,82 @@ void ObTrafficControl::inner_calc_() } } +int ObTrafficControl::gc_tenant_infos() +{ + int ret = OB_SUCCESS; + if (REACH_TIME_INTERVAL(1 * 60 * 1000L * 1000L)) { // 60s + struct GCTenantSharedDeviceInfos + { + GCTenantSharedDeviceInfos( + const ObVector &tenant_ids, ObSEArray &gc_tenant_infos) + : tenant_ids_(tenant_ids), gc_tenant_infos_(gc_tenant_infos) + {} + int operator()(hash::HashMapPair &pair) + { + bool is_find = false; + for (int i = 0; !is_find && i < tenant_ids_.size(); ++i) { + if (0 == pair.first.get_tenant_id() || tenant_ids_.at(i) == pair.first.get_tenant_id()) { + is_find = true; + } + } + if (false == is_find) { + gc_tenant_infos_.push_back(pair.first); + } + return OB_SUCCESS; + } + const ObVector &tenant_ids_; + ObSEArray &gc_tenant_infos_; + }; + struct GCTenantRecordInfos + { + GCTenantRecordInfos( + const ObVector &tenant_ids, ObSEArray &gc_tenant_infos) + : tenant_ids_(tenant_ids), gc_tenant_infos_(gc_tenant_infos) + {} + int operator()(hash::HashMapPair &pair) + { + bool is_find = false; + for (int i = 0; !is_find && i < tenant_ids_.size(); ++i) { + if (0 == pair.first.id_.get_tenant_id() || tenant_ids_.at(i) == pair.first.id_.get_tenant_id()) { + is_find = true; + } + } + if (false == is_find) { + gc_tenant_infos_.push_back(pair.first); + } + return OB_SUCCESS; + } + const ObVector &tenant_ids_; + ObSEArray &gc_tenant_infos_; + }; + ObVector tenant_ids; + ObSEArray gc_tenant_record_infos; + ObSEArray gc_tenant_shared_device_infos; + GCTenantRecordInfos fn(tenant_ids, gc_tenant_record_infos); + GCTenantSharedDeviceInfos fn2(tenant_ids, gc_tenant_shared_device_infos); + if(OB_ISNULL(GCTX.omt_)) { + } else if (FALSE_IT(GCTX.omt_->get_tenant_ids(tenant_ids))) { + } else if (OB_FAIL(io_record_map_.foreach_refactored(fn))) { + LOG_WARN("SSNT:failed to get gc tenant record infos", K(ret)); + } else if (OB_FAIL(shared_device_map_.foreach_refactored(fn2))) { + LOG_WARN("SSNT:failed to get gc tenant shared device infos", K(ret)); + } else { + for (int i = 0; i < gc_tenant_record_infos.count(); ++i) { + if (OB_SUCCESS != io_record_map_.erase_refactored(gc_tenant_record_infos.at(i))) { + LOG_WARN("SSNT:failed to erase gc tenant record infos", K(ret), K(gc_tenant_record_infos.at(i))); + } + } + for (int i = 0; i < gc_tenant_shared_device_infos.count(); ++i) { + if (OB_SUCCESS != shared_device_map_.erase_refactored(gc_tenant_shared_device_infos.at(i))) { + LOG_WARN( + "SSNT:failed to erase gc tenant shared device infos", K(ret), K(gc_tenant_shared_device_infos.at(i))); + } + } + } + } + return ret; +} + ObIOManager::ObIOManager() : is_inited_(false), is_working_(false), @@ -2349,4 +2425,4 @@ int ObTenantIOManager::get_throttled_time(uint64_t group_id, int64_t &throttled_ const ObIOFuncUsages& ObTenantIOManager::get_io_func_infos() { return io_func_infos_; -} +} \ No newline at end of file diff --git a/src/share/io/ob_io_manager.h b/src/share/io/ob_io_manager.h index cadf2d124..c594e0c6e 100644 --- a/src/share/io/ob_io_manager.h +++ b/src/share/io/ob_io_manager.h @@ -128,6 +128,7 @@ public: { return tenant_id_ == that.tenant_id_ && id_ == that.id_; } + TO_STRING_KV(K(tenant_id_), K(id_)); uint64_t tenant_id_; // tenant_id of req ObStorageKey id_; }; @@ -188,6 +189,7 @@ public: int64_t get_net_obw() { return net_obw_.calc(); } int64_t get_device_bandwidth() const { return device_bandwidth_; } void set_device_bandwidth(int64_t bw) { device_bandwidth_ = ibw_clock_.iops_ = obw_clock_.iops_ = bw; } + int gc_tenant_infos(); private: void inner_calc_(); private: