提交 94e2cc67 编写于 作者: N nroskill 提交者: wangzelin.wzl

memory diagnose including deleted tenant

上级 4791a733
......@@ -25,6 +25,7 @@ using namespace oceanbase::lib;
using namespace oceanbase::common;
ObMallocAllocator* ObMallocAllocator::instance_ = NULL;
uint64_t ObMallocAllocator::max_used_tenant_id_ = 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 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) {
ret = OB_INVALID_ARGUMENT;
LOG_ERROR("invalid argument", K(lbt()), K(tenant_id), K(ret));
......
......@@ -66,7 +66,7 @@ public:
int set_tenant_ctx_idle(
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);
static uint64_t get_max_used_tenant_id() { return max_used_tenant_id_; }
private:
using InvokeFunc = std::function<int(ObTenantMemoryMgr*)>;
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];
int64_t reserved_;
int64_t urgent_;
static uint64_t max_used_tenant_id_;
static ObMallocAllocator* instance_;
}; // end of class ObMallocAllocator
......
......@@ -194,31 +194,11 @@ using namespace oceanbase::storage;
void get_tenant_ids(uint64_t* ids, int cap, int& cnt)
{
int ret = OB_SUCCESS;
auto *instance = ObMallocAllocator::get_instance();
cnt = 0;
omt::ObMultiTenant* omt = GCTX.omt_;
if (OB_ISNULL(omt)) {
if (ObTenantManager::get_instance().is_inited()) {
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;
for (uint64_t tenant_id = 1; tenant_id <= ObMallocAllocator::get_max_used_tenant_id() && cnt < cap; ++tenant_id) {
if (nullptr != instance->get_tenant_ctx_allocator(tenant_id, 0)) {
ids[cnt++] = tenant_id;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册