add a new config, which can force malloc even if tenant not exist in observer
This commit is contained in:
2
deps/oblib/src/lib/alloc/alloc_struct.h
vendored
2
deps/oblib/src/lib/alloc/alloc_struct.h
vendored
@ -619,6 +619,8 @@ extern bool is_ob_mem_mgr_path();
|
||||
#define FORCE_EXPLICT_500_MALLOC() \
|
||||
OB_UNLIKELY(oceanbase::lib::ObMallocAllocator::get_instance()->force_explict_500_malloc_)
|
||||
|
||||
#define FORCE_MALLOC_FOR_ABSENT_TENANT() \
|
||||
OB_UNLIKELY(oceanbase::lib::ObMallocAllocator::get_instance()->force_malloc_for_absent_tenant_)
|
||||
} // end of namespace lib
|
||||
} // end of namespace oceanbase
|
||||
|
||||
|
||||
@ -153,6 +153,15 @@ void *ObMallocAllocator::alloc(const int64_t size, const oceanbase::lib::ObMemAt
|
||||
ptr = allocator->alloc(size, inner_attr);
|
||||
}
|
||||
}
|
||||
} else if (OB_ENTRY_NOT_EXIST == ret && FORCE_MALLOC_FOR_ABSENT_TENANT()) {
|
||||
ret = OB_SUCCESS;
|
||||
LOG_INFO("force malloc when tenant allocator does not exist");
|
||||
inner_attr.tenant_id_ = OB_SERVER_TENANT_ID;
|
||||
allocator = get_tenant_ctx_allocator(inner_attr.tenant_id_, inner_attr.ctx_id_);
|
||||
if (OB_ISNULL(allocator)) {
|
||||
} else {
|
||||
ptr = allocator->alloc(size, inner_attr);
|
||||
}
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
||||
@ -161,6 +161,7 @@ public:
|
||||
public:
|
||||
bool force_explict_500_malloc_ = false;
|
||||
bool pl_leaked_times_ = 0;
|
||||
bool force_malloc_for_absent_tenant_ = false;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObMallocAllocator);
|
||||
class BucketLock
|
||||
|
||||
20
deps/oblib/src/lib/allocator/ob_allocator_v2.cpp
vendored
20
deps/oblib/src/lib/allocator/ob_allocator_v2.cpp
vendored
@ -30,26 +30,20 @@ void *ObAllocator::alloc(const int64_t size, const ObMemAttr &attr)
|
||||
ret = init();
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (do_not_use_me_) {
|
||||
ObMemAttr inner_attr = nattr_;
|
||||
if (attr.label_.is_valid()) {
|
||||
inner_attr.label_ = attr.label_;
|
||||
}
|
||||
auto ta = lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(inner_attr.tenant_id_,
|
||||
inner_attr.ctx_id_);
|
||||
if (ta != NULL) {
|
||||
ptr = ObTenantCtxAllocator::common_alloc(size, inner_attr, *(ta.ref_allocator()), nos_);
|
||||
}
|
||||
}
|
||||
if (OB_LIKELY(!ptr)) {
|
||||
ObMemAttr inner_attr = attr_;
|
||||
if (attr.label_.is_valid()) {
|
||||
inner_attr.label_ = attr.label_;
|
||||
}
|
||||
auto ta = lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(inner_attr.tenant_id_,
|
||||
inner_attr.ctx_id_);
|
||||
if (ta != NULL) {
|
||||
if (OB_LIKELY(NULL != ta)) {
|
||||
ptr = ObTenantCtxAllocator::common_alloc(size, inner_attr, *(ta.ref_allocator()), os_);
|
||||
} else if (FORCE_MALLOC_FOR_ABSENT_TENANT()) {
|
||||
inner_attr.tenant_id_ = OB_SERVER_TENANT_ID;
|
||||
ta = lib::ObMallocAllocator::get_instance()->get_tenant_ctx_allocator(inner_attr.tenant_id_,
|
||||
inner_attr.ctx_id_);
|
||||
if (NULL != ta) {
|
||||
ptr = ObTenantCtxAllocator::common_alloc(size, inner_attr, *(ta.ref_allocator()), nos_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
deps/oblib/src/lib/allocator/ob_allocator_v2.h
vendored
22
deps/oblib/src/lib/allocator/ob_allocator_v2.h
vendored
@ -67,9 +67,7 @@ private:
|
||||
void reset() override { os_.reset(); }
|
||||
private:
|
||||
__MemoryContext__ *mem_context_;
|
||||
bool do_not_use_me_;
|
||||
ObMemAttr attr_;
|
||||
ObMemAttr nattr_;
|
||||
const bool use_pm_;
|
||||
void *pm_;
|
||||
lib::ISetLocker *locker_;
|
||||
@ -123,7 +121,6 @@ public:
|
||||
inline ObAllocator::ObAllocator(__MemoryContext__ *mem_context, const ObMemAttr &attr, const bool use_pm,
|
||||
const uint32_t ablock_size)
|
||||
: mem_context_(mem_context),
|
||||
do_not_use_me_(false),
|
||||
attr_(attr),
|
||||
use_pm_(use_pm),
|
||||
pm_(nullptr),
|
||||
@ -134,16 +131,6 @@ inline ObAllocator::ObAllocator(__MemoryContext__ *mem_context, const ObMemAttr
|
||||
nos_(mem_context_, ablock_size),
|
||||
is_inited_(false)
|
||||
{
|
||||
nattr_ = attr_;
|
||||
do_not_use_me_ = false;
|
||||
if (FORCE_EXPLICT_500_MALLOC()) {
|
||||
do_not_use_me_ = OB_SERVER_TENANT_ID == attr.tenant_id_ && !attr.use_500() &&
|
||||
ob_thread_tenant_id() != OB_SERVER_TENANT_ID;
|
||||
if (do_not_use_me_) {
|
||||
nattr_.tenant_id_ = ob_thread_tenant_id();
|
||||
nattr_.ctx_id_ = ObCtxIds::DO_NOT_USE_ME;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline int ObAllocator::init()
|
||||
@ -165,13 +152,12 @@ inline int ObAllocator::init()
|
||||
blk_mgr_.set_tenant_id(attr_.tenant_id_);
|
||||
blk_mgr_.set_ctx_id(attr_.ctx_id_);
|
||||
blk_mgr = &blk_mgr_;
|
||||
if (do_not_use_me_) {
|
||||
nblk_mgr_.set_tenant_id(nattr_.tenant_id_);
|
||||
nblk_mgr_.set_ctx_id(nattr_.ctx_id_);
|
||||
nblk_mgr = &nblk_mgr_;
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
nblk_mgr_.set_tenant_id(OB_SERVER_TENANT_ID);
|
||||
nblk_mgr_.set_ctx_id(attr_.ctx_id_);
|
||||
nblk_mgr = &nblk_mgr_;
|
||||
os_.set_block_mgr(blk_mgr);
|
||||
os_.set_locker(locker_);
|
||||
nos_.set_block_mgr(nblk_mgr);
|
||||
|
||||
@ -318,6 +318,10 @@ int ObServerReloadConfig::operator()()
|
||||
{
|
||||
common::g_enable_backtrace = GCONF._enable_backtrace_function;
|
||||
}
|
||||
|
||||
{
|
||||
ObMallocAllocator::get_instance()->force_malloc_for_absent_tenant_ = GCONF._force_malloc_for_absent_tenant;
|
||||
}
|
||||
return real_ret;
|
||||
}
|
||||
|
||||
|
||||
@ -1589,6 +1589,9 @@ DEF_BOOL(_enable_system_tenant_memory_limit, OB_CLUSTER_PARAMETER, "True",
|
||||
"specifies whether allowed to limit the memory of tenant 500",
|
||||
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
#endif
|
||||
DEF_BOOL(_force_malloc_for_absent_tenant, OB_CLUSTER_PARAMETER, "False",
|
||||
"force malloc even if tenant does not exist in observer",
|
||||
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
|
||||
ERRSIM_DEF_TIME(errsim_transfer_backfill_error_time, OB_TENANT_PARAMETER, "0", "[0s,1h]",
|
||||
"the duration of the error happened to transfer backfill. "
|
||||
"Range: [0s, 1h] in duration",
|
||||
|
||||
@ -295,6 +295,7 @@ _follower_snapshot_read_retry_duration
|
||||
_force_explict_500_malloc
|
||||
_force_hash_groupby_dump
|
||||
_force_hash_join_spill
|
||||
_force_malloc_for_absent_tenant
|
||||
_force_skip_encoding_partition_id
|
||||
_hash_area_size
|
||||
_hash_join_enabled
|
||||
|
||||
Reference in New Issue
Block a user