memory diagnose including deleted tenant
This commit is contained in:
		| @ -25,6 +25,7 @@ using namespace oceanbase::lib; | |||||||
| using namespace oceanbase::common; | using namespace oceanbase::common; | ||||||
|  |  | ||||||
| ObMallocAllocator* ObMallocAllocator::instance_ = NULL; | ObMallocAllocator* ObMallocAllocator::instance_ = NULL; | ||||||
|  | uint64_t ObMallocAllocator::max_used_tenant_id_ = 0; | ||||||
|  |  | ||||||
| ObMallocAllocator::ObMallocAllocator() : locks_(), allocators_(), reserved_(0), urgent_(0) | ObMallocAllocator::ObMallocAllocator() : locks_(), allocators_(), reserved_(0), urgent_(0) | ||||||
| {} | {} | ||||||
| @ -206,6 +207,9 @@ ObTenantCtxAllocator* ObMallocAllocator::get_tenant_ctx_allocator(uint64_t tenan | |||||||
| int ObMallocAllocator::create_tenant_ctx_allocator(uint64_t tenant_id, uint64_t ctx_id) | int ObMallocAllocator::create_tenant_ctx_allocator(uint64_t tenant_id, uint64_t ctx_id) | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|  |   if (tenant_id > max_used_tenant_id_) { | ||||||
|  |     UNUSED(ATOMIC_BCAS(&max_used_tenant_id_, max_used_tenant_id_, tenant_id)); | ||||||
|  |   } | ||||||
|   if (INT64_MAX == tenant_id) { |   if (INT64_MAX == tenant_id) { | ||||||
|     ret = OB_INVALID_ARGUMENT; |     ret = OB_INVALID_ARGUMENT; | ||||||
|     LOG_ERROR("invalid argument", K(lbt()), K(tenant_id), K(ret)); |     LOG_ERROR("invalid argument", K(lbt()), K(tenant_id), K(ret)); | ||||||
|  | |||||||
| @ -66,7 +66,7 @@ public: | |||||||
|   int set_tenant_ctx_idle( |   int set_tenant_ctx_idle( | ||||||
|       const uint64_t tenant_id, const uint64_t ctx_id, const int64_t size, const bool reserve = false); |       const uint64_t tenant_id, const uint64_t ctx_id, const int64_t size, const bool reserve = false); | ||||||
|   int get_chunks(AChunk** chunks, int cap, int& cnt); |   int get_chunks(AChunk** chunks, int cap, int& cnt); | ||||||
|  |   static uint64_t get_max_used_tenant_id() { return max_used_tenant_id_; } | ||||||
| private: | private: | ||||||
|   using InvokeFunc = std::function<int(ObTenantMemoryMgr*)>; |   using InvokeFunc = std::function<int(ObTenantMemoryMgr*)>; | ||||||
|   static int with_resource_handle_invoke(uint64_t tenant_id, InvokeFunc func); |   static int with_resource_handle_invoke(uint64_t tenant_id, InvokeFunc func); | ||||||
| @ -79,6 +79,7 @@ private: | |||||||
|   ObTenantCtxAllocator* allocators_[PRESERVED_TENANT_COUNT][common::ObCtxIds::MAX_CTX_ID]; |   ObTenantCtxAllocator* allocators_[PRESERVED_TENANT_COUNT][common::ObCtxIds::MAX_CTX_ID]; | ||||||
|   int64_t reserved_; |   int64_t reserved_; | ||||||
|   int64_t urgent_; |   int64_t urgent_; | ||||||
|  |   static uint64_t max_used_tenant_id_; | ||||||
|  |  | ||||||
|   static ObMallocAllocator* instance_; |   static ObMallocAllocator* instance_; | ||||||
| };  // end of class ObMallocAllocator | };  // end of class ObMallocAllocator | ||||||
|  | |||||||
| @ -194,31 +194,11 @@ using namespace oceanbase::storage; | |||||||
| void get_tenant_ids(uint64_t* ids, int cap, int& cnt) | void get_tenant_ids(uint64_t* ids, int cap, int& cnt) | ||||||
| { | { | ||||||
|   int ret = OB_SUCCESS; |   int ret = OB_SUCCESS; | ||||||
|  |   auto *instance = ObMallocAllocator::get_instance(); | ||||||
|   cnt = 0; |   cnt = 0; | ||||||
|   omt::ObMultiTenant* omt = GCTX.omt_; |   for (uint64_t tenant_id = 1; tenant_id <= ObMallocAllocator::get_max_used_tenant_id() && cnt < cap; ++tenant_id) { | ||||||
|   if (OB_ISNULL(omt)) { |     if (nullptr != instance->get_tenant_ctx_allocator(tenant_id, 0)) { | ||||||
|     if (ObTenantManager::get_instance().is_inited()) { |       ids[cnt++] = tenant_id; | ||||||
|       common::ObArray<uint64_t> tmp_ids; |  | ||||||
|       if (OB_FAIL(ObTenantManager::get_instance().get_all_tenant_id(tmp_ids))) { |  | ||||||
|         SERVER_LOG(WARN, "get tenant id error", K(ret)); |  | ||||||
|       } else { |  | ||||||
|         for (auto it = tmp_ids.begin(); OB_SUCC(ret) && it != tmp_ids.end() && cnt < cap; it++) { |  | ||||||
|           ids[cnt++] = *it; |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|     } else { |  | ||||||
|       if (cnt < cap) { |  | ||||||
|         ids[cnt++] = OB_SYS_TENANT_ID; |  | ||||||
|       } |  | ||||||
|       if (cnt < cap) { |  | ||||||
|         ids[cnt++] = OB_SERVER_TENANT_ID; |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } else { |  | ||||||
|     omt::TenantIdList tmp_ids(nullptr, ObModIds::OMT); |  | ||||||
|     omt->get_tenant_ids(tmp_ids); |  | ||||||
|     for (auto it = tmp_ids.begin(); OB_SUCC(ret) && it != tmp_ids.end() && cnt < cap; it++) { |  | ||||||
|       ids[cnt++] = *it; |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 nroskill
					nroskill