[CP] fix serialized packet and return less data

This commit is contained in:
obdev
2022-11-18 06:35:51 +00:00
committed by wangzelin.wzl
parent 0a20f5ca46
commit c5cff66ebe
22 changed files with 350 additions and 82 deletions

View File

@ -30,16 +30,13 @@ bool ObMallocAllocator::is_inited_ = false;
ObMallocAllocator::ObMallocAllocator() : locks_(), allocators_(), reserved_(0), urgent_(0)
{
for (int64_t i = 0; i < PRESERVED_TENANT_COUNT; ++i) {
locks_[i].enable_record_stat(false);
}
set_root_allocator();
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < ObCtxIds::MAX_CTX_ID; i++) {
if (OB_FAIL(create_tenant_ctx_allocator(OB_SYS_TENANT_ID, i))) {
//LOG_ERROR("create tenant allocator fail", K(ret), K(i));
LOG_ERROR("create tenant allocator fail", K(ret), K(i));
} else if (OB_FAIL(create_tenant_ctx_allocator(OB_SERVER_TENANT_ID, i))) {
//LOG_ERROR("create tenant allocator fail", K(ret), K(i));
LOG_ERROR("create tenant allocator fail", K(ret), K(i));
}
}
is_inited_ = true;
@ -177,7 +174,7 @@ ObTenantCtxAllocator *ObMallocAllocator::get_tenant_ctx_allocator(uint64_t tenan
} else {
// TODO: lock slot
const int64_t slot = tenant_id % PRESERVED_TENANT_COUNT;
SpinRLockGuard guard(locks_[slot]);
obsys::ObRLockGuard guard(locks_[slot]);
ObTenantCtxAllocator * const *cur = &allocators_[slot][ctx_id];
while (NULL != *cur && (*cur)->get_tenant_id() < tenant_id) {
cur = &(*cur)->get_next();
@ -227,7 +224,7 @@ int ObMallocAllocator::create_tenant_ctx_allocator(
cas_succeed = ATOMIC_BCAS(&allocators_[tenant_id][ctx_id], NULL, allocator);
} else {
const int64_t slot = tenant_id % PRESERVED_TENANT_COUNT;
SpinWLockGuard guard(locks_[slot]);
obsys::ObWLockGuard guard(locks_[slot]);
ObTenantCtxAllocator **cur = &allocators_[slot][ctx_id];
while ((NULL != *cur) && (*cur)->get_tenant_id() < tenant_id) {
cur = &((*cur)->get_next());
@ -245,7 +242,7 @@ int ObMallocAllocator::create_tenant_ctx_allocator(
if (OB_FAIL(ret) || !cas_succeed) {
allocator->~ObTenantCtxAllocator();
allocer->free(buf);
} else if (OB_SYS_TENANT_ID != tenant_id && OB_SERVER_TENANT_ID != tenant_id) {
} else {
LOG_INFO("tenant ctx allocator was created", K(tenant_id), K(ctx_id), KCSTRING(lbt()));
}
}
@ -259,7 +256,7 @@ void ObMallocAllocator::set_root_allocator()
int ret = OB_SUCCESS;
static ObTenantCtxAllocator allocator(OB_SERVER_TENANT_ID);
if (OB_FAIL(allocator.set_tenant_memory_mgr())) {
//LOG_ERROR("set_tenant_memory_mgr failed", K(ret));
LOG_ERROR("set_tenant_memory_mgr failed", K(ret));
} else {
allocators_[OB_SERVER_TENANT_ID][0] = &allocator;
}
@ -455,7 +452,7 @@ int ObMallocAllocator::get_chunks(AChunk **chunks, int cap, int &cnt)
{
int ret = OB_SUCCESS;
for (int64_t slot = 0; OB_SUCC(ret) && slot < PRESERVED_TENANT_COUNT; ++slot) {
SpinRLockGuard guard(locks_[slot]);
obsys::ObRLockGuard guard(locks_[slot]);
for (int64_t ctx_id = 0; OB_SUCC(ret) && ctx_id < ObCtxIds::MAX_CTX_ID; ctx_id++) {
ObTenantCtxAllocator *ta = allocators_[slot][ctx_id];
while (OB_SUCC(ret) && ta != nullptr) {