diff --git a/deps/oblib/src/common/storage/ob_fd_simulator.cpp b/deps/oblib/src/common/storage/ob_fd_simulator.cpp index 34228ccd39..32921b7339 100644 --- a/deps/oblib/src/common/storage/ob_fd_simulator.cpp +++ b/deps/oblib/src/common/storage/ob_fd_simulator.cpp @@ -25,7 +25,7 @@ union ob_sim_fd_id int64_t op_type_ : 4; int64_t device_type_ : 4; fd_sim_id() : first_pos_(0), second_pos_(0), - op_type_(0), device_type_(0) + op_type_(0), device_type_(0) {} }; int64_t fd_id_; @@ -36,7 +36,7 @@ union ob_sim_fd_id int validate_fd(ObIOFd fd, bool expect); ObFdSimulator::ObFdSimulator() : array_size_(DEFAULT_ARRAY_SIZE), second_array_num_(0), - first_array_(NULL), allocator_("FdSimulator"), + first_array_(NULL), allocator_(SET_USE_500("FdSimulator")), lock_(ObLatchIds::DEFAULT_SPIN_LOCK),used_fd_cnt_(0),total_fd_cnt_(0),is_init_(false) { } @@ -105,7 +105,7 @@ int ObFdSimulator::init() is_init_ = true; } } - + return ret; } @@ -122,8 +122,8 @@ int ObFdSimulator::extend_second_array() OB_LOG(WARN, "fail to extend second array for fd mng!", K(second_array_num_), K(ret)); } else if (OB_FAIL(init_manager_array(second_array_p))) { OB_LOG(WARN, "fail to init extend second array for fd mng!", K(second_array_num_), K(ret)); - } - } + } + } return ret; } @@ -152,14 +152,14 @@ int try_get_fd_inner(ObFdSimulator::FirstArray* first_array, int32_t second_arra } if (i >= second_array_num) { - OB_LOG(WARN, "no enough fd entry, maybe need extend!", K(second_array_num)); + OB_LOG(WARN, "no enough fd entry, maybe need extend!", K(second_array_num)); ret = OB_BUF_NOT_ENOUGH ; } return ret; } /* -For object device, the fd(first_id_) is used to locate the ctx, +For object device, the fd(first_id_) is used to locate the ctx, the fd(second_id_) is used to record the version(validate the fd) */ int ObFdSimulator::get_fd(void* ctx, const int device_type, const int flag, ObIOFd &fd) @@ -171,8 +171,8 @@ int ObFdSimulator::get_fd(void* ctx, const int device_type, const int flag, ObIO ret = OB_NOT_INIT; OB_LOG(WARN, "fd simulater is not init!", K(ret)); } else if (OB_ISNULL(ctx)) { - OB_LOG(WARN, "fail to alloc fd with empty ctx!"); - ret = OB_INVALID_ARGUMENT; + OB_LOG(WARN, "fail to alloc fd with empty ctx!"); + ret = OB_INVALID_ARGUMENT; } else if (OB_FAIL(try_get_fd_inner(first_array_, second_array_num_, ctx, fd))) { OB_LOG(WARN, "fail to alloc fd, maybe need extend second array!"); /*after the first fail, try to extend*/ @@ -190,7 +190,7 @@ int ObFdSimulator::get_fd(void* ctx, const int device_type, const int flag, ObIO set_fd_flag(fd, flag); used_fd_cnt_++; } - + return ret; } @@ -239,7 +239,7 @@ void ObFdSimulator::get_fd_slot_id(const ObIOFd& fd, int64_t& first_id, int64_t& bool ObFdSimulator::validate_fd(const ObIOFd& fd, bool expect) { int64_t first_id = 0; - int64_t second_id = 0; + int64_t second_id = 0; int ret = OB_SUCCESS; int valid = false; get_fd_slot_id(fd, first_id, second_id); @@ -253,7 +253,7 @@ bool ObFdSimulator::validate_fd(const ObIOFd& fd, bool expect) if (OB_ISNULL(second_array)) { OB_LOG(WARN, "fd maybe wrong, second fd array is null!", K(first_id), K(second_id), K(total_fd_cnt_), K(used_fd_cnt_)); } else if (second_array[second_id].slot_version != fd.second_id_){ - OB_LOG(WARN, "fd slot_version is invalid, maybe double free!", K(first_id), K(fd.second_id_), + OB_LOG(WARN, "fd slot_version is invalid, maybe double free!", K(first_id), K(fd.second_id_), K(second_array[second_id].slot_version)); } else { valid = true; @@ -266,7 +266,7 @@ int ObFdSimulator::fd_to_ctx(const ObIOFd& fd, void*& ctx) { int ret = OB_SUCCESS; int64_t first_id = 0; - int64_t second_id = 0; + int64_t second_id = 0; ctx = NULL; /*validate the fd*/ get_fd_slot_id(fd, first_id, second_id); @@ -275,7 +275,7 @@ int ObFdSimulator::fd_to_ctx(const ObIOFd& fd, void*& ctx) ret = OB_NOT_INIT; OB_LOG(WARN, "fd simulater is not init!", K(ret)); } else if (!validate_fd(fd, true)) { - OB_LOG(WARN, "fail to get fd ctx, since fd is invalid!", K(first_id), K(second_id)); + OB_LOG(WARN, "fail to get fd ctx, since fd is invalid!", K(first_id), K(second_id)); } else { FdSlot *second_array = first_array_[first_id].second_array_p; ctx = second_array[second_id].pointer.ctx_pointer; @@ -292,8 +292,8 @@ int ObFdSimulator::release_fd(const ObIOFd& fd) { int ret = OB_SUCCESS; int64_t first_id = 0; - int64_t second_id = 0; - + int64_t second_id = 0; + common::ObSpinLockGuard guard(lock_); get_fd_slot_id(fd, first_id, second_id); if (!is_init_) { diff --git a/deps/oblib/src/lib/alloc/alloc_failed_reason.cpp b/deps/oblib/src/lib/alloc/alloc_failed_reason.cpp index 6cf2e3ed6e..78f8d759c9 100644 --- a/deps/oblib/src/lib/alloc/alloc_failed_reason.cpp +++ b/deps/oblib/src/lib/alloc/alloc_failed_reason.cpp @@ -66,6 +66,12 @@ char *alloc_failed_msg() char *msg = (&buf)->v_; auto &afc = g_alloc_failed_ctx(); switch (afc.reason_) { + case UNKNOWN: { + snprintf(msg, len, + "unknown(alloc_size: %ld)", + afc.alloc_size_); + break; + } case SINGLE_ALLOC_SIZE_OVERFLOW: { snprintf(msg, len, "single alloc size large than 4G is not allowed(alloc_size: %ld)", diff --git a/deps/oblib/src/lib/alloc/alloc_failed_reason.h b/deps/oblib/src/lib/alloc/alloc_failed_reason.h index 18c0e16059..58f09cb79b 100644 --- a/deps/oblib/src/lib/alloc/alloc_failed_reason.h +++ b/deps/oblib/src/lib/alloc/alloc_failed_reason.h @@ -22,7 +22,8 @@ namespace lib { enum AllocFailedReason { - SINGLE_ALLOC_SIZE_OVERFLOW = 0, + UNKNOWN = 0, + SINGLE_ALLOC_SIZE_OVERFLOW, CTX_HOLD_REACH_LIMIT, TENANT_HOLD_REACH_LIMIT, SERVER_HOLD_REACH_LIMIT, @@ -54,7 +55,7 @@ public: }; bool need_wash() const { - return reason_ == lib::CTX_HOLD_REACH_LIMIT || + return reason_ == lib::CTX_HOLD_REACH_LIMIT || reason_ == lib::TENANT_HOLD_REACH_LIMIT || reason_ == lib::SERVER_HOLD_REACH_LIMIT; } diff --git a/deps/oblib/src/lib/alloc/alloc_struct.h b/deps/oblib/src/lib/alloc/alloc_struct.h index 52b8e3be9b..25da6091c2 100644 --- a/deps/oblib/src/lib/alloc/alloc_struct.h +++ b/deps/oblib/src/lib/alloc/alloc_struct.h @@ -68,12 +68,20 @@ enum ObAllocPrio struct ObLabel { ObLabel() - : ObLabel(nullptr) + : str_(nullptr) {} - template - ObLabel(const T &t) + template + ObLabel(const char (&str)[N]) { - *this = t; + STATIC_ASSERT(N - 1 <= AOBJECT_LABEL_SIZE, + "label length longer than 15 is not allowed!"); + str_ = str; + } + template ::value>::type> + ObLabel(T str) + { + str_ = str; } // The caller needs to ensure that it ends with'\0' template @@ -111,6 +119,7 @@ struct ObLabel struct ObMemAttr { + friend ObMemAttr DoNotUseMe(ObMemAttr &attr); uint64_t tenant_id_; ObLabel label_; uint64_t ctx_id_; @@ -126,8 +135,33 @@ struct ObMemAttr ctx_id_(ctx_id), prio_(prio) {} int64_t to_string(char* buf, const int64_t buf_len) const; + bool use_500() const { return use_500_; } +private: + bool use_500_ = false; }; +inline ObMemAttr DoNotUseMe(ObMemAttr &attr) +{ +#ifdef ENABLE_500_FALLBACK + attr.use_500_ = true; +#endif + return attr; +} + +inline ObMemAttr DoNotUseMe(const ObMemAttr &&attr) +{ + ObMemAttr attr_cpy = attr; + return DoNotUseMe(attr_cpy); +} + +inline ObMemAttr DoNotUseMe(const ObLabel &label) +{ + ObMemAttr attr(OB_SERVER_TENANT_ID, label); + return DoNotUseMe(attr); +} + +#define SET_USE_500(args...) ::oceanbase::lib::DoNotUseMe(args) + struct AllocHelper { static uint32_t cells_per_block(uint32_t ablock_size) diff --git a/deps/oblib/src/lib/alloc/block_set.h b/deps/oblib/src/lib/alloc/block_set.h index 82c22a3cf8..b605ed0ac5 100644 --- a/deps/oblib/src/lib/alloc/block_set.h +++ b/deps/oblib/src/lib/alloc/block_set.h @@ -74,6 +74,7 @@ public: void set_locker(ISetLocker *locker) { locker_ = locker; } int64_t sync_wash(int64_t wash_size=INT64_MAX); bool check_has_unfree(); + ObTenantCtxAllocator *get_tenant_ctx_allocator() const { return tallocator_; } private: DISALLOW_COPY_AND_ASSIGN(BlockSet); diff --git a/deps/oblib/src/lib/alloc/malloc_hook.cpp b/deps/oblib/src/lib/alloc/malloc_hook.cpp index e4dfcf6143..e8ec975f12 100644 --- a/deps/oblib/src/lib/alloc/malloc_hook.cpp +++ b/deps/oblib/src/lib/alloc/malloc_hook.cpp @@ -57,7 +57,8 @@ void *ob_malloc_retry(size_t size) { void *ptr = nullptr; do { - static ObMemAttr attr(OB_SERVER_TENANT_ID, "glibc_malloc", ObCtxIds::GLIBC); + ObMemAttr attr(OB_SERVER_TENANT_ID, "glibc_malloc", ObCtxIds::GLIBC); + SET_USE_500(attr); ptr = ob_malloc(size, attr); if (OB_ISNULL(ptr)) { ::usleep(10000); // 10ms diff --git a/deps/oblib/src/lib/alloc/memory_dump.cpp b/deps/oblib/src/lib/alloc/memory_dump.cpp index 0209216ada..4d439cdabd 100644 --- a/deps/oblib/src/lib/alloc/memory_dump.cpp +++ b/deps/oblib/src/lib/alloc/memory_dump.cpp @@ -29,11 +29,18 @@ using namespace lib; namespace common { -void __attribute__((weak)) get_tenant_ids(uint64_t *ids, int cap, int &cnt) + +void get_tenant_ids(uint64_t *ids, int cap, int &cnt) { + auto *instance = ObMallocAllocator::get_instance(); cnt = 0; - if (cap > 0) { - ids[cnt++] = OB_SERVER_TENANT_ID; + for (uint64_t tenant_id = 1; tenant_id <= instance->get_max_used_tenant_id() && cnt < cap; ++tenant_id) { + if (nullptr != instance->get_tenant_ctx_allocator(tenant_id, + ObCtxIds::DEFAULT_CTX_ID) || + nullptr != instance->get_tenant_ctx_allocator_unrecycled(tenant_id, + ObCtxIds::DEFAULT_CTX_ID)) { + ids[cnt++] = tenant_id; + } } } diff --git a/deps/oblib/src/lib/alloc/memory_dump.h b/deps/oblib/src/lib/alloc/memory_dump.h index af31de06d3..3da8bb35fa 100644 --- a/deps/oblib/src/lib/alloc/memory_dump.h +++ b/deps/oblib/src/lib/alloc/memory_dump.h @@ -116,6 +116,7 @@ public: private: friend class observer::ObAllVirtualMemoryInfo; friend class lib::ObTenantCtxAllocator; +friend class lib::ObMallocAllocator; static const int64_t TASK_NUM = 8; static const int PRINT_BUF_LEN = 1L << 20; diff --git a/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp b/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp index c6991f5b58..ddc10f5ff2 100644 --- a/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp +++ b/deps/oblib/src/lib/alloc/ob_malloc_allocator.cpp @@ -102,10 +102,16 @@ void *ObMallocAllocator::alloc(const int64_t size, const oceanbase::lib::ObMemAt void *ptr = NULL; ObTenantCtxAllocatorGuard allocator = NULL; oceanbase::lib::ObMemAttr inner_attr = attr; - if (inner_attr.ctx_id_ == ObCtxIds::STORAGE_LONG_TERM_META_CTX_ID - || inner_attr.ctx_id_ == ObCtxIds::STORAGE_SHORT_TERM_META_CTX_ID) { - inner_attr.tenant_id_ = OB_SERVER_TENANT_ID; +#ifdef ENABLE_500_FALLBACK + const bool do_not_use_me = OB_SERVER_TENANT_ID == attr.tenant_id_ && !attr.use_500() && + mtl_id() != OB_SERVER_TENANT_ID; + if (do_not_use_me) { + inner_attr.tenant_id_ = mtl_id(); + inner_attr.ctx_id_ = ObCtxIds::DO_NOT_USE_ME; } +#else + const bool do_not_use_me = false; +#endif if (OB_SUCCESS != ret) { } else if (OB_UNLIKELY(0 == inner_attr.tenant_id_) || OB_UNLIKELY(INT64_MAX == inner_attr.tenant_id_)) { @@ -127,7 +133,15 @@ void *ObMallocAllocator::alloc(const int64_t size, const oceanbase::lib::ObMemAt } if (OB_SUCC(ret)) { - ptr = allocator->alloc(size, inner_attr); + if (do_not_use_me) { + if (OB_ISNULL(ptr = allocator->alloc(size, inner_attr))) { + inner_attr = attr; + allocator = get_tenant_ctx_allocator(inner_attr.tenant_id_, inner_attr.ctx_id_); + } + } + if (!ptr) { + ptr = allocator->alloc(size, inner_attr); + } } return ptr; @@ -157,10 +171,6 @@ void *ObMallocAllocator::realloc( } oceanbase::lib::ObMemAttr inner_attr = attr; ObTenantCtxAllocatorGuard allocator = NULL; - if (inner_attr.ctx_id_ == ObCtxIds::STORAGE_LONG_TERM_META_CTX_ID - || inner_attr.ctx_id_ == ObCtxIds::STORAGE_SHORT_TERM_META_CTX_ID) { - inner_attr.tenant_id_ = OB_SERVER_TENANT_ID; - } if (OB_FAIL(ret) && NULL == ptr) { // do nothing } else if (OB_ISNULL(allocator = get_tenant_ctx_allocator(inner_attr.tenant_id_, inner_attr.ctx_id_))) { @@ -302,6 +312,10 @@ int ObMallocAllocator::create_tenant_allocator(uint64_t tenant_id, void *buf, ObTenantCtxAllocator(tenant_id, ctx_id); if (OB_FAIL(ctx_allocator->set_tenant_memory_mgr())) { LOG_ERROR("set_tenant_memory_mgr failed", K(ret)); +#ifdef ENABLE_500_FALLBACK + } else if (ObCtxIds::DO_NOT_USE_ME == ctx_id) { + ctx_allocator->set_limit(50L<<20); +#endif } } if (OB_SUCC(ret)) { @@ -588,6 +602,11 @@ void ObMallocAllocator::add_tenant_allocator_unrecycled(ObTenantCtxAllocator *al if (enable_tenant_leak_memory_protection_) { modify_tenant_memory_access_permission(allocator, false); } +#endif +#ifdef ENABLE_500_FALLBACK + for (int64_t ctx_id = 0; ctx_id < ObCtxIds::MAX_CTX_ID; ctx_id++) { + allocator[ctx_id].set_deleted(true); + } #endif ObDisableDiagnoseGuard disable_diagnose_guard; ObLatchWGuard guard(unrecycled_lock_, ObLatchIds::OB_ALLOCATOR_LOCK); @@ -613,11 +632,16 @@ ObTenantCtxAllocator *ObMallocAllocator::take_off_tenant_allocator_unrecycled(ui *cur = (*cur)->get_next(); } } -#ifdef ENABLE_SANITY if (ta != NULL) { - modify_tenant_memory_access_permission(ta, true); - } +#ifdef ENABLE_500_FALLBACK + for (int64_t ctx_id = 0; ctx_id < ObCtxIds::MAX_CTX_ID; ctx_id++) { + ta[ctx_id].set_deleted(false); + } #endif +#ifdef ENABLE_SANITY + modify_tenant_memory_access_permission(ta, true); +#endif + } return ta; } @@ -748,5 +772,52 @@ void ObMallocAllocator::modify_tenant_memory_access_permission(ObTenantCtxAlloca } } #endif + +#ifdef ENABLE_500_FALLBACK +int64_t __attribute__((weak)) mtl_id() +{ + return OB_SERVER_TENANT_ID; +} +#endif + +void ObMallocAllocator::print_malloc_sample(uint64_t tenant_id) const +{ + UNUSED(tenant_id); +#ifdef ENABLE_500_FALLBACK + int ret = OB_SUCCESS; + auto &mem_dump = ObMemoryDump().get_instance(); + if (OB_UNLIKELY(!mem_dump.is_inited())) { + ret = OB_NOT_INIT; + SERVER_LOG(WARN, "mem dump not inited", K(ret)); + } else { + ObLatchRGuard guard(mem_dump.iter_lock_, common::ObLatchIds::MEM_DUMP_ITER_LOCK); + auto &sample_map = mem_dump.r_stat_->malloc_sample_map_; + char buf[4096]; + int64_t buf_len = sizeof(buf); + int64_t pos = 0; + for (auto it = sample_map.begin(); OB_SUCC(ret) && it != sample_map.end(); it++) { + if (it->first.tenant_id_ == tenant_id) { + void **bt[ARRAYSIZEOF(it->first.bt_)]; + MEMCPY(bt, it->first.bt_, sizeof(bt)); + char bt_str[512]; + parray(bt_str, sizeof(bt_str), (int64_t*)bt, ARRAYSIZEOF(bt)); + ret = databuff_printf(buf, buf_len, pos, + "[MEMORY][LEAK_INFO] tenant=%'10ld ctx=%20s mod=%15s alloc_bytes=%'10ld lbt=%s\n", + it->first.tenant_id_, + get_global_ctx_info().get_ctx_name(it->first.ctx_id_), + it->first.label_, it->second.alloc_bytes_, bt_str); + if (OB_SUCC(ret) && pos > sizeof(buf)/2) { + _LOG_INFO("\n%.*s", static_cast(pos), buf); + pos = 0; + } + } + } + if (OB_SUCC(ret) && pos > 0) { + _LOG_INFO("\n%.*s", static_cast(pos), buf); + } + } +#endif +} + } // end of namespace lib } // end of namespace oceanbase diff --git a/deps/oblib/src/lib/alloc/ob_malloc_allocator.h b/deps/oblib/src/lib/alloc/ob_malloc_allocator.h index a4ca14f986..13691475c3 100644 --- a/deps/oblib/src/lib/alloc/ob_malloc_allocator.h +++ b/deps/oblib/src/lib/alloc/ob_malloc_allocator.h @@ -131,6 +131,7 @@ public: void print_tenant_ctx_memory_usage(uint64_t tenant_id) const; void print_tenant_memory_usage(uint64_t tenant_id) const; + void print_malloc_sample(uint64_t tenant_id) const; int set_tenant_ctx_idle( const uint64_t tenant_id, const uint64_t ctx_id, const int64_t size, const bool reserve = false); int64_t sync_wash(uint64_t tenant_id, uint64_t from_ctx_id, int64_t wash_size); @@ -252,6 +253,8 @@ public: bool restore_; }; +extern int64_t mtl_id(); + } // end of namespace lib } // end of namespace oceanbase diff --git a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.cpp b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.cpp index 2434ec6706..7d996e8b51 100644 --- a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.cpp +++ b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.cpp @@ -503,17 +503,27 @@ void ObTenantCtxAllocator::common_free(void *ptr) SANITY_POISON(obj->data_, obj->alloc_bytes_); get_mem_leak_checker().on_free(*obj); - ABlock *block = obj->block(); + AChunk *chunk = AChunk::ptr2chunk(obj); + abort_unless(chunk->is_valid()); + ABlock *block = chunk->ptr2blk(obj); abort_unless(block); abort_unless(block->is_valid()); abort_unless(block->in_use_); abort_unless(block->obj_set_ != NULL); ObjectSet *os = block->obj_set_; - auto blk_mgr = os->get_block_mgr(); - int64_t tenant_id = blk_mgr->get_tenant_id(); - int64_t ctx_id = blk_mgr->get_ctx_id(); - ObFreeLogPrinter::get_instance().print_free_log(tenant_id, ctx_id, obj); - os->free_object(obj); +#ifdef ENABLE_500_FALLBACK + auto *ta = chunk->block_set_->get_tenant_ctx_allocator(); + const bool do_free = OB_LIKELY(!ta->has_deleted()) || ta->get_tenant_id() <= OB_USER_TENANT_ID; +#else + const bool do_free = true; +#endif + if (do_free) { + auto blk_mgr = os->get_block_mgr(); + int64_t tenant_id = blk_mgr->get_tenant_id(); + int64_t ctx_id = blk_mgr->get_ctx_id(); + ObFreeLogPrinter::get_instance().print_free_log(tenant_id, ctx_id, obj); + os->free_object(obj); + } } } diff --git a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h index d872d31b81..9a6586363f 100644 --- a/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h +++ b/deps/oblib/src/lib/alloc/ob_tenant_ctx_allocator.h @@ -41,7 +41,7 @@ using InvokeFunc = std::function; public: explicit ObTenantCtxAllocator(uint64_t tenant_id, uint64_t ctx_id = 0) : resource_handle_(), ref_cnt_(0), tenant_id_(tenant_id), - ctx_id_(ctx_id), obj_mgr_(*this, tenant_id_, ctx_id_), + ctx_id_(ctx_id), deleted_(false), obj_mgr_(*this, tenant_id_, ctx_id_), idle_size_(0), head_chunk_(), chunk_cnt_(0), chunk_freelist_mutex_(common::ObLatchIds::CHUNK_FREE_LIST_LOCK), using_list_mutex_(common::ObLatchIds::CHUNK_USING_LIST_LOCK), @@ -81,6 +81,8 @@ public: { return reinterpret_cast(next_); } + void set_deleted(bool deleted) { deleted_ = deleted; } + bool has_deleted() const { return deleted_; } // will delete it virtual void *alloc(const int64_t size) @@ -202,6 +204,7 @@ private: int64_t ref_cnt_; uint64_t tenant_id_; uint64_t ctx_id_; + bool deleted_; ObjectMgr obj_mgr_; int64_t idle_size_; AChunk head_chunk_; diff --git a/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.cpp b/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.cpp index a3fba03b20..f0946dcfac 100644 --- a/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.cpp +++ b/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.cpp @@ -85,6 +85,11 @@ void ObConcurrentFIFOAllocator::set_label(const lib::ObLabel &label) inner_allocator_.set_label(label); } +void ObConcurrentFIFOAllocator::set_attr(const lib::ObMemAttr &attr) +{ + inner_allocator_.set_attr(attr); +} + void ObConcurrentFIFOAllocator::set_tenant_id(const uint64_t tenant_id) { inner_allocator_.set_tenant_id(tenant_id); diff --git a/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.h b/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.h index 5b0d700676..f6a2999245 100644 --- a/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_concurrent_fifo_allocator.h @@ -35,6 +35,7 @@ public: void destroy(); public: void set_label(const lib::ObLabel &label); + void set_attr(const lib::ObMemAttr &attr); void set_tenant_id(const uint64_t tenant_id); void *alloc(const int64_t size); void *alloc(const int64_t size, const ObMemAttr &attr); diff --git a/deps/oblib/src/lib/allocator/ob_fixed_size_block_allocator.h b/deps/oblib/src/lib/allocator/ob_fixed_size_block_allocator.h index e186325abc..15eb9a3f39 100644 --- a/deps/oblib/src/lib/allocator/ob_fixed_size_block_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_fixed_size_block_allocator.h @@ -127,7 +127,7 @@ ObFixedSizeBlockAllocator::ObFixedSizeBlockAllocator() : lock_(common::ObLatchIds::FIXED_SIZE_ALLOCATOR_LOCK), total_block_num_(0), max_block_num_(0), - allocator_(ObModIds::OB_FIXED_SIZE_BLOCK_ALLOCATOR), + allocator_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_FIXED_SIZE_BLOCK_ALLOCATOR))), free_blocks_(), block_buf_list_(allocator_) { @@ -146,12 +146,14 @@ int ObFixedSizeBlockAllocator::init(const int64_t block_num, const lib::Ob } else if (OB_FAIL(init_max_block_num())) { COMMON_LOG(WARN, "init max block number fail", K(ret)); } else { + ObMemAttr attr(OB_SERVER_TENANT_ID, label); + SET_USE_500(attr); ObSpinLockGuard guard(lock_); if (IS_NOT_INIT) { - if (OB_FAIL(free_blocks_.init(max_block_num_))) { + if (OB_FAIL(free_blocks_.init(max_block_num_, global_default_allocator, attr))) { COMMON_LOG(WARN, "fail to init free blocks queue", K(ret)); } else { - allocator_.set_label(label); + allocator_.set_attr(attr); if (OB_FAIL(expand(block_num))) { COMMON_LOG(WARN, "fail to init cached block buffer", K(ret), K(block_num)); } diff --git a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h index 08c540d792..6885f9fa4e 100644 --- a/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_lf_fifo_allocator.h @@ -27,14 +27,12 @@ public: ObLfFIFOAllocator() {} virtual ~ObLfFIFOAllocator() { destroy(); } int init(const int64_t page_size, - const lib::ObLabel &label, - const uint64_t tenant_id = OB_SERVER_TENANT_ID, + const lib::ObMemAttr &attr, const int64_t cache_page_count = DEFAULT_CACHE_PAGE_COUNT, const int64_t total_limit = INT64_MAX) { int ret = OB_SUCCESS; - mattr_.label_ = label; - mattr_.tenant_id_ = tenant_id; + mattr_ = attr; block_alloc_.set_limit(total_limit); if (OB_FAIL(ObVSliceAlloc::init(page_size, block_alloc_, mattr_))) { } else if (cache_page_count < 0 || cache_page_count > INT32_MAX) { @@ -45,6 +43,16 @@ public: } return ret; } + int init(const int64_t page_size, + const lib::ObLabel &label, + const uint64_t tenant_id = OB_SERVER_TENANT_ID, + const int64_t cache_page_count = DEFAULT_CACHE_PAGE_COUNT, + const int64_t total_limit = INT64_MAX) + { + mattr_.label_ = label; + mattr_.tenant_id_ = tenant_id; + return init(page_size, mattr_, cache_page_count, total_limit); + } void destroy() { ObVSliceAlloc::purge_extra_cached_block(0); } public: void *alloc(const int64_t size) { return ObVSliceAlloc::alloc(size); } @@ -53,6 +61,7 @@ public: int64_t allocated() const { return block_alloc_.hold(); } void set_tenant_id(const uint64_t tenant_id) { mattr_.tenant_id_ = tenant_id; } void set_label(const lib::ObLabel &label) { mattr_.label_ = label; } + void set_attr(const lib::ObMemAttr &attr) { mattr_ = attr; } void set_total_limit(int64_t total_limit) { block_alloc_.set_limit(total_limit); } bool is_fragment(void* ptr) { return get_block_using_ratio(ptr) < 0.8; } private: diff --git a/deps/oblib/src/lib/allocator/ob_mod_define.h b/deps/oblib/src/lib/allocator/ob_mod_define.h index 63f1445a89..f92ce6635b 100644 --- a/deps/oblib/src/lib/allocator/ob_mod_define.h +++ b/deps/oblib/src/lib/allocator/ob_mod_define.h @@ -12,29 +12,13 @@ #ifdef CTX_ITEM_DEF CTX_ITEM_DEF(DEFAULT_CTX_ID) +CTX_ITEM_DEF(DO_NOT_USE_ME) CTX_ITEM_DEF(MEMSTORE_CTX_ID) -CTX_ITEM_DEF(COMPILE_CTX_ID) -CTX_ITEM_DEF(PHY_PLAN_CTX_ID) CTX_ITEM_DEF(EXECUTE_CTX_ID) -CTX_ITEM_DEF(HASHJOIN_CTX_ID) -CTX_ITEM_DEF(SORT_CTX_ID) CTX_ITEM_DEF(TRANS_CTX_MGR_ID) -CTX_ITEM_DEF(ELECTION_CTX_ID) -CTX_ITEM_DEF(MEMSTORE_OBJECT_CTX_ID) -CTX_ITEM_DEF(PARTITION_CTX_ID) -CTX_ITEM_DEF(SSSTORE_CTX_ID) -CTX_ITEM_DEF(SSTABLE_CTX_ID) -CTX_ITEM_DEF(PARTITION_STORAGE_CTX_ID) -CTX_ITEM_DEF(PARTITION_CTX_MGR_CTX_ID) -CTX_ITEM_DEF(STORAGE_LONG_TERM_META_CTX_ID) -CTX_ITEM_DEF(STORAGE_SHORT_TERM_META_CTX_ID) -CTX_ITEM_DEF(PARTITION_LOG_SERVICE_CTX_ID) -CTX_ITEM_DEF(REPLAY_STATUS_CTX_ID) CTX_ITEM_DEF(PLAN_CACHE_CTX_ID) -CTX_ITEM_DEF(REQ_MANAGER_CTX_ID) CTX_ITEM_DEF(WORK_AREA) CTX_ITEM_DEF(GLIBC) -CTX_ITEM_DEF(LOG_INDEX_CTX_ID) CTX_ITEM_DEF(CO_STACK) CTX_ITEM_DEF(LIBEASY) CTX_ITEM_DEF(LOGGER_CTX_ID) @@ -46,6 +30,7 @@ CTX_ITEM_DEF(PS_CACHE_CTX_ID) CTX_ITEM_DEF(RPC_CTX_ID) CTX_ITEM_DEF(PKT_NIO) CTX_ITEM_DEF(TX_DATA_TABLE) +CTX_ITEM_DEF(STORAGE_LONG_TERM_META_CTX_ID) CTX_ITEM_DEF(MAX_CTX_ID) #endif diff --git a/deps/oblib/src/lib/allocator/ob_pooled_allocator.h b/deps/oblib/src/lib/allocator/ob_pooled_allocator.h index 405ac311da..be4c15ed8b 100644 --- a/deps/oblib/src/lib/allocator/ob_pooled_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_pooled_allocator.h @@ -27,6 +27,7 @@ public: ObPooledAllocator(int64_t block_size = common::OB_MALLOC_NORMAL_BLOCK_SIZE, const BlockAllocatorT &alloc = BlockAllocatorT(ObModIds::OB_POOL)); virtual ~ObPooledAllocator(); + void set_attr(const lib::ObMemAttr &attr) { the_pool_.set_attr(attr); } T *alloc(); void free(T *obj); diff --git a/deps/oblib/src/lib/allocator/ob_small_allocator.h b/deps/oblib/src/lib/allocator/ob_small_allocator.h index 801f7a6b9f..be5a8588bc 100644 --- a/deps/oblib/src/lib/allocator/ob_small_allocator.h +++ b/deps/oblib/src/lib/allocator/ob_small_allocator.h @@ -32,10 +32,19 @@ public: const int64_t block_size = OB_MALLOC_NORMAL_BLOCK_SIZE, const int64_t min_obj_count_on_block = DEFAULT_MIN_OBJ_COUNT_ON_BLOCK, const int64_t limit_num = INT64_MAX) { + lib::ObMemAttr attr; + attr.label_ = label; + attr.tenant_id_ = tenant_id; + return init(obj_size, attr, block_size, min_obj_count_on_block, limit_num); + } + int init(const int64_t obj_size, + const lib::ObMemAttr &attr, + const int64_t block_size = OB_MALLOC_NORMAL_BLOCK_SIZE, + const int64_t min_obj_count_on_block = DEFAULT_MIN_OBJ_COUNT_ON_BLOCK, + const int64_t limit_num = INT64_MAX) { int ret = OB_SUCCESS; + attr_ = attr; UNUSED(min_obj_count_on_block); - attr_.label_ = label; - attr_.tenant_id_ = tenant_id; if (limit_num < INT64_MAX) { block_alloc_.set_limit(limit_num * obj_size); } @@ -56,4 +65,3 @@ private: }; // end namespace oceanbase #endif /* OCEANBASE_ALLOCATOR_OB_SMALL_ALLOCATOR_V2_H_ */ - diff --git a/deps/oblib/src/lib/allocator/page_arena.h b/deps/oblib/src/lib/allocator/page_arena.h index 9ec1e78a6d..aad9b9d085 100644 --- a/deps/oblib/src/lib/allocator/page_arena.h +++ b/deps/oblib/src/lib/allocator/page_arena.h @@ -48,15 +48,13 @@ struct DefaultPageAllocator: public ObIAllocator { DefaultPageAllocator(const lib::ObLabel &label = ObModIds::OB_PAGE_ARENA, uint64_t tenant_id = OB_SERVER_TENANT_ID) - : label_(label), tenant_id_(tenant_id), ctx_id_(ObCtxIds::DEFAULT_CTX_ID) {}; + : attr_(tenant_id, label) {}; + DefaultPageAllocator(const lib::ObMemAttr &attr) + : attr_(attr) {}; virtual ~DefaultPageAllocator() {}; void *alloc(const int64_t sz) { - ObMemAttr malloc_attr; - malloc_attr.label_ = label_; - malloc_attr.tenant_id_ = tenant_id_; - malloc_attr.ctx_id_ = ctx_id_; - return alloc(sz, malloc_attr); + return alloc(sz, attr_); } void *alloc(const int64_t size, const ObMemAttr &attr) { @@ -64,21 +62,19 @@ struct DefaultPageAllocator: public ObIAllocator } void free(void *p) { ob_free(p); } void freed(const int64_t sz) {UNUSED(sz); /* mostly for effcient bulk stat reporting */ } - void set_label(const lib::ObLabel &label) {label_ = label;}; - void set_tenant_id(uint64_t tenant_id) {tenant_id_ = tenant_id;}; - void set_ctx_id(int64_t ctx_id) { ctx_id_ = ctx_id; } - lib::ObLabel get_label() const { return label_; }; + void set_label(const lib::ObLabel &label) {attr_.label_ = label;}; + void set_tenant_id(uint64_t tenant_id) {attr_.tenant_id_ = tenant_id;}; + void set_ctx_id(int64_t ctx_id) { attr_.ctx_id_ = ctx_id; } + void set_attr(const lib::ObMemAttr &attr) { attr_ = attr; } + lib::ObLabel get_label() const { return attr_.label_; }; void *mod_alloc(const int64_t sz, const lib::ObLabel &label) { - ObMemAttr malloc_attr; + ObMemAttr malloc_attr = attr_; malloc_attr.label_ = label; - malloc_attr.tenant_id_ = tenant_id_; return ob_malloc(sz, malloc_attr); } private: - lib::ObLabel label_; - uint64_t tenant_id_; - int64_t ctx_id_; + lib::ObMemAttr attr_; }; struct ModulePageAllocator: public ObIAllocator @@ -86,25 +82,26 @@ struct ModulePageAllocator: public ObIAllocator ModulePageAllocator(const lib::ObLabel &label = ObModIds::OB_MODULE_PAGE_ALLOCATOR, int64_t tenant_id = OB_SERVER_TENANT_ID, int64_t ctx_id = 0) - : allocator_(NULL), - label_(label), - tenant_id_(tenant_id), - ctx_id_(ctx_id) {} + : ModulePageAllocator(ObMemAttr(tenant_id, label, ctx_id)) {} + ModulePageAllocator(const lib::ObMemAttr &attr) + : allocator_(NULL) { attr_ = attr; } explicit ModulePageAllocator(ObIAllocator &allocator, const lib::ObLabel &label = ObModIds::OB_MODULE_PAGE_ALLOCATOR) - : allocator_(&allocator), - label_(label), - tenant_id_(OB_SERVER_TENANT_ID), - ctx_id_(0) {} + : allocator_(&allocator) + { + attr_.label_ = label; + attr_.tenant_id_ = OB_SERVER_TENANT_ID; + attr_.ctx_id_ = 0; + } virtual ~ModulePageAllocator() {} - void set_label(const lib::ObLabel &label) { label_ = label; } - void set_tenant_id(uint64_t tenant_id) {tenant_id_ = tenant_id;}; - void set_ctx_id(int64_t ctx_id) { ctx_id_ = ctx_id; } - lib::ObLabel get_label() const { return label_; } + void set_label(const lib::ObLabel &label) { attr_.label_ = label; } + void set_tenant_id(uint64_t tenant_id) {attr_.tenant_id_ = tenant_id;}; + void set_ctx_id(int64_t ctx_id) { attr_.ctx_id_ = ctx_id; } + void set_attr(const lib::ObMemAttr &attr) { attr_ = attr; } + lib::ObLabel get_label() const { return attr_.label_; } void *alloc(const int64_t sz) { - ObMemAttr malloc_attr(tenant_id_, label_, ctx_id_); - return alloc(sz, malloc_attr); + return alloc(sz, attr_); } void *alloc(const int64_t size, const ObMemAttr &attr) { @@ -116,17 +113,13 @@ struct ModulePageAllocator: public ObIAllocator ModulePageAllocator &operator=(const ModulePageAllocator &that) { if (this != &that) { allocator_ = that.allocator_; - label_ = that.label_; - tenant_id_ = that.tenant_id_; - ctx_id_ = that.ctx_id_; + attr_ = that.attr_; } return *this; } protected: ObIAllocator *allocator_; - lib::ObLabel label_; - uint64_t tenant_id_; - uint64_t ctx_id_; + lib::ObMemAttr attr_; }; /** @@ -530,6 +523,7 @@ public: // API lib::ObLabel get_label() const { return page_allocator_.get_label(); } void set_tenant_id(uint64_t tenant_id) { page_allocator_.set_tenant_id(tenant_id); } void set_ctx_id(int64_t ctx_id) { page_allocator_.set_ctx_id(ctx_id); } + void set_attr(const lib::ObMemAttr &attr) { page_allocator_.set_attr(attr); } /** allocate sz bytes */ CharT *_alloc(const int64_t sz) { @@ -1041,6 +1035,9 @@ public: ObArenaAllocator(ObIAllocator &allocator, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE, const bool enable_sanity = false) : arena_(page_size, ModulePageAllocator(allocator), enable_sanity) {}; + ObArenaAllocator(const lib::ObMemAttr &attr, + const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE) + : arena_(page_size, ModulePageAllocator(attr), true) {} virtual ~ObArenaAllocator() {}; public: virtual void *alloc(const int64_t sz) { return arena_.alloc_aligned(sz); } @@ -1068,9 +1065,7 @@ public: void set_ctx_id(int64_t ctx_id) { arena_.set_ctx_id(ctx_id); } void set_attr(const ObMemAttr &attr) override { - arena_.set_tenant_id(attr.tenant_id_); - arena_.set_ctx_id(attr.ctx_id_); - arena_.set_label(attr.label_); + arena_.set_attr(attr); } ModuleArena &get_arena() { return arena_; } int64_t to_string(char *buf, int64_t len) const @@ -1165,9 +1160,7 @@ public: virtual void set_attr(const ObMemAttr &attr) override { - arena_.set_tenant_id(attr.tenant_id_); - arena_.set_ctx_id(attr.ctx_id_); - arena_.set_label(attr.label_); + arena_.set_attr(attr); } private: ModuleArena arena_; diff --git a/deps/oblib/src/lib/container/ob_array.h b/deps/oblib/src/lib/container/ob_array.h index 745980fa33..9f4851001a 100644 --- a/deps/oblib/src/lib/container/ob_array.h +++ b/deps/oblib/src/lib/container/ob_array.h @@ -97,6 +97,7 @@ public: const BlockAllocatorT &alloc = BlockAllocatorT(ObNewModIds::OB_COMMON_ARRAY)); virtual ~ObArrayImpl() __attribute__((noinline)); inline void set_label(const lib::ObLabel &label) { block_allocator_.set_label(label); } + inline void set_attr(const lib::ObMemAttr &attr) { block_allocator_.set_attr(attr); } inline void set_block_size(const int64_t block_size) { block_size_ = block_size; } inline int64_t get_block_size() const {return block_size_; } inline void set_block_allocator(const BlockAllocatorT &alloc) { block_allocator_ = alloc; } diff --git a/deps/oblib/src/lib/container/ob_bit_set.h b/deps/oblib/src/lib/container/ob_bit_set.h index 01b57c08ae..d4da396bc8 100644 --- a/deps/oblib/src/lib/container/ob_bit_set.h +++ b/deps/oblib/src/lib/container/ob_bit_set.h @@ -449,6 +449,7 @@ public: bool operator==(const ObBitSet &other) const; bool equal(const ObBitSet &other) const; + void set_attr(const lib::ObMemAttr &attr) { bitset_word_array_.set_attr(attr); } int prepare_allocate(int64_t bits) { return bitset_word_array_.prepare_allocate((bits / PER_BITSETWORD_BITS) + 1); diff --git a/deps/oblib/src/lib/container/ob_se_array.h b/deps/oblib/src/lib/container/ob_se_array.h index a6387b8c29..6dad1b1e92 100644 --- a/deps/oblib/src/lib/container/ob_se_array.h +++ b/deps/oblib/src/lib/container/ob_se_array.h @@ -268,6 +268,7 @@ public: // deep copy explicit ObSEArrayImpl(const ObSEArrayImpl &other); + inline void set_attr(const lib::ObMemAttr &attr) { block_allocator_.set_attr(attr); } ObSEArrayImpl &operator=(const ObSEArrayImpl &other); int assign(const ObIArray &other); diff --git a/deps/oblib/src/lib/container/ob_vector.h b/deps/oblib/src/lib/container/ob_vector.h index ae5ff6294a..3316e3a237 100644 --- a/deps/oblib/src/lib/container/ob_vector.h +++ b/deps/oblib/src/lib/container/ob_vector.h @@ -91,6 +91,8 @@ public: explicit ObVector(Allocator *alloc = NULL, const lib::ObLabel &label = ObModIds::OB_MOD_DO_NOT_USE_ME); explicit ObVector(int64_t size, Allocator *alloc = NULL, const lib::ObLabel &label = ObModIds::OB_MOD_DO_NOT_USE_ME); + explicit ObVector(int64_t size, Allocator *alloc, + const lib::ObMemAttr &attr); virtual ~ObVector(); int assign(const ObVector &other); ObVector &operator=(const ObVector &other); @@ -184,6 +186,9 @@ public: explicit ObSortedVector(int64_t size, Allocator *alloc = NULL, const lib::ObLabel &label = ObModIds::OB_MOD_DO_NOT_USE_ME) : vector_(size, alloc, label) {} + ObSortedVector(int64_t size, Allocator *alloc, + const lib::ObMemAttr &attr) + : vector_(size, alloc, attr) {} virtual ~ObSortedVector() {} int assign(const ObSortedVector &other) { diff --git a/deps/oblib/src/lib/container/ob_vector.ipp b/deps/oblib/src/lib/container/ob_vector.ipp index c9c15ebbca..f5c03d7de1 100644 --- a/deps/oblib/src/lib/container/ob_vector.ipp +++ b/deps/oblib/src/lib/container/ob_vector.ipp @@ -34,11 +34,15 @@ ObVector::ObVector(Allocator *alloc, const lib::ObLabel &label) template ObVector::ObVector(int64_t size, Allocator *alloc, const lib::ObLabel &label) + : ObVector(size, alloc, ObMemAttr(common::OB_SERVER_TENANT_ID, label)) {} + +template +ObVector::ObVector(int64_t size, Allocator *alloc, const lib::ObMemAttr &attr) : mem_begin_(NULL), mem_end_(NULL), mem_end_of_storage_(NULL) { if (NULL == alloc) { pallocator_ = &default_allocator_; - pallocator_->set_label(label); + pallocator_->set_attr(attr); } else { pallocator_ = alloc; } diff --git a/deps/oblib/src/lib/function/ob_function.h b/deps/oblib/src/lib/function/ob_function.h index 1724b56728..d0546dea66 100644 --- a/deps/oblib/src/lib/function/ob_function.h +++ b/deps/oblib/src/lib/function/ob_function.h @@ -16,11 +16,11 @@ * ObFunction is a basic abstruct tool, just behave like std::function. * ObFunction is a template class, it can only be used with template specialization. * User need specify Function input args' types and return type when specialization. - * All callable object, no matter function pointer, functor class, or lambda, as long as they have - * same input args' types and return type, they could be described as the same type using + * All callable object, no matter function pointer, functor class, or lambda, as long as they have + * same input args' types and return type, they could be described as the same type using * ObFunction. * ObFunction has value semantics. - * + * * * When to use: * - you want to describe a callable object. @@ -122,7 +122,9 @@ struct DefaultFunctionAllocator : public ObIAllocator { #ifdef UNIITTEST_DEBUG total_alive_num++; #endif - return ob_malloc(size, "ObFunction"); + static lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "ObFunction"); + SET_USE_500(attr); + return ob_malloc(size, attr); } void* alloc(const int64_t size, const ObMemAttr &attr) override { UNUSED(attr); @@ -301,7 +303,7 @@ public: RECORDER.function_copy_assign_time++; #endif return base_assign_(rhs.base_); - } + } // move assign int assign(ObFunction &&rhs) { #ifdef UNIITTEST_DEBUG diff --git a/deps/oblib/src/lib/guard/ob_shared_guard.h b/deps/oblib/src/lib/guard/ob_shared_guard.h index 712624f23e..5dcaab8b2e 100644 --- a/deps/oblib/src/lib/guard/ob_shared_guard.h +++ b/deps/oblib/src/lib/guard/ob_shared_guard.h @@ -36,12 +36,12 @@ * ObSharedGuard * * ObSharedGuard protect a raw pointer's ownership, promise if there is at least one owner holding - * the guard, pointer will not be deleted, and if there is no holder, pointer will be deleted + * the guard, pointer will not be deleted, and if there is no holder, pointer will be deleted * properly. * - * + * * When to use: - * - hope a pointer has shared ownership, and could delete(both logically and physically) it + * - hope a pointer has shared ownership, and could delete(both logically and physically) it * customized under RAII. * * When not to use: @@ -49,7 +49,7 @@ * * Memory usage: * - sizeof(ObSharedGuard) is 16 Bytes in common, including 2 pointers. - * - if ObSharedGuard is assigned by a raw pointer, a piece of heap memory for control block will + * - if ObSharedGuard is assigned by a raw pointer, a piece of heap memory for control block will * be allocated, to avoid this, using ob_make_shared() or ob_alloc_shared() to ceate a * ObSharedGuard and object with only one time alloc. * @@ -74,8 +74,8 @@ * + int assign(const ObSharedGuard &) * success always * + template - * int assign(T *, FUNC &&, ObIAllocator &) - * general assign, could assigned by a raw pointer, may return OB_INVALID_ARGUMENT or + * int assign(T *, FUNC &&, ObIAllocator &) + * general assign, could assigned by a raw pointer, may return OB_INVALID_ARGUMENT or * OB_ALLOCATE_MEMORY_FAILED. * 5. using * using ObSharedGuard obj just like using T* obj. @@ -83,11 +83,11 @@ * - CAUTION: * + MAKE SURE ObSharedGuard is valid before using it, or will CRASH. * + if the first ObSharedGuard is created by ob_make_shared() or ob_alloc_shared(), the delete - * action will be acted after the last ObSharedGuard destructed, and it's behavior is just - * call ptr's destruction method and call allocator's free method, WILL NOT CALL destory() + * action will be acted after the last ObSharedGuard destructed, and it's behavior is just + * call ptr's destruction method and call allocator's free method, WILL NOT CALL destory() * method even if ptr has one. - * + if ObSharedGuard is created by ob_make_shared() or ob_alloc_shared(), ptr's destruct - * method will be called immediately, but it's memory will be delay-freed after the last + * + if ObSharedGuard is created by ob_make_shared() or ob_alloc_shared(), ptr's destruct + * method will be called immediately, but it's memory will be delay-freed after the last * associated ObWeakGuard destructed. * * - Contact for help. @@ -126,7 +126,9 @@ struct DefaultSharedGuardAllocator : public ObIAllocator { #ifdef UNIITTEST_DEBUG total_alive_num++; #endif - return ob_malloc(size, "ObGuard"); + static lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "ObGuard"); + SET_USE_500(attr); + return ob_malloc(size, attr); } void* alloc(const int64_t size, const ObMemAttr &attr) override { UNUSED(attr); @@ -155,7 +157,7 @@ struct ControlBlock { allocator_(allocator), alloc_area_pointer_(alloc_area_pointer) {} template - ControlBlock(FUNC &&deleter, ObIAllocator &allocator, void *alloc_area_pointer) : + ControlBlock(FUNC &&deleter, ObIAllocator &allocator, void *alloc_area_pointer) : weak_count_(1), shared_count_(1), deleter_(std::forward(deleter), allocator), diff --git a/deps/oblib/src/lib/guard/ob_unique_guard.h b/deps/oblib/src/lib/guard/ob_unique_guard.h index 4e3adf87ca..30f22bc00b 100644 --- a/deps/oblib/src/lib/guard/ob_unique_guard.h +++ b/deps/oblib/src/lib/guard/ob_unique_guard.h @@ -38,9 +38,9 @@ * ObUniqueGuard protect a raw pointer's ownership, promise there is at most one owner holding the * guard, if there is no owner holding, the protected raw pointer will be deleted properly. * - * + * * When to use: - * - hope a pointer has unique ownership, and could delete(both logically and physically) it + * - hope a pointer has unique ownership, and could delete(both logically and physically) it * customized under RAII. * * When not to use: @@ -49,7 +49,7 @@ * Memory usage: * - sizeof(ObUniqueGuard) is 24 Bytes in common, including 3 pointers. * - if ObUniqueGuard is assigned by a raw pointer, a piece of heap memory for deleter will be al- - * located, to avoid this, using ob_make_unique() or ob_alloc_unique() to ceate a ObUniqueGuard + * located, to avoid this, using ob_make_unique() or ob_alloc_unique() to ceate a ObUniqueGuard * and object with only one time alloc. * * Manual: @@ -73,16 +73,16 @@ * + int assign(const ObUniqueGuard &) * success always * + template - * int assign(T *, FUNC &&, ObIAllocator &) - * general assign, could assigned by a raw pointer, may return OB_INVALID_ARGUMENT or + * int assign(T *, FUNC &&, ObIAllocator &) + * general assign, could assigned by a raw pointer, may return OB_INVALID_ARGUMENT or * OB_ALLOCATE_MEMORY_FAILED. * 5. using * using ObUniqueGuard obj just like using T* obj. * * - CAUTION: * + MAKE SURE ObUniqueGuard is valid before using it, or will CRASH. - * + if ObUniqueGuard is created by ob_make_unique() or ob_alloc_unique(), the delete action - * behavior is just call ptr's destuction method and call allocator's free method, WILL NOT + * + if ObUniqueGuard is created by ob_make_unique() or ob_alloc_unique(), the delete action + * behavior is just call ptr's destuction method and call allocator's free method, WILL NOT * CALL destory() method even if ptr has one. * * - Contact for help. @@ -116,7 +116,9 @@ struct DefaultUniqueGuardAllocator : public ObIAllocator { #ifdef UNIITTEST_DEBUG total_alive_num++; #endif - return ob_malloc(size, "ObGuard"); + static lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "ObGuard"); + SET_USE_500(attr); + return ob_malloc(size, attr); } void* alloc(const int64_t size, const ObMemAttr &attr) override { @@ -192,7 +194,7 @@ public: if (OB_ISNULL(data)) { ret = OB_INVALID_ARGUMENT; } else { - ObFunction* temp_ptr = + ObFunction* temp_ptr = (ObFunction*)alloc.alloc(sizeof(ObFunction)); if (OB_LIKELY(nullptr != temp_ptr)) { temp_ptr = new (temp_ptr)ObFunction(alloc);// success always diff --git a/deps/oblib/src/lib/hash/ob_hashmap.h b/deps/oblib/src/lib/hash/ob_hashmap.h index f7ce51459d..e40949e09d 100644 --- a/deps/oblib/src/lib/hash/ob_hashmap.h +++ b/deps/oblib/src/lib/hash/ob_hashmap.h @@ -124,7 +124,12 @@ public: allocer_.set_attr(node_attr); bucket_allocer_.set_attr(bucket_attr); return ht_.create(cal_next_prime(bucket_num), &allocer_, &bucket_allocer_); - }; + } + int create(int64_t bucket_num, + const ObMemAttr &bucket_attr) + { + return create(bucket_num, bucket_attr, bucket_attr); + } int create(int64_t bucket_num, const lib::ObLabel &bucket_label, const lib::ObLabel &node_label = ObModIds::OB_HASH_NODE, uint64_t tenant_id = OB_SERVER_TENANT_ID, uint64_t ctx_id = ObCtxIds::DEFAULT_CTX_ID) diff --git a/deps/oblib/src/lib/hash/ob_hashset.h b/deps/oblib/src/lib/hash/ob_hashset.h index 87830a6964..e223585fc2 100644 --- a/deps/oblib/src/lib/hash/ob_hashset.h +++ b/deps/oblib/src/lib/hash/ob_hashset.h @@ -96,6 +96,19 @@ public: { return ht_.create(cal_next_prime(bucket_num), &allocer_, &bucket_allocer_); } + int create(int64_t bucket_num, + const ObMemAttr &bucket_attr) + { + return create(bucket_num, bucket_attr, bucket_attr); + } + int create(int64_t bucket_num, + const ObMemAttr &bucket_attr, + const ObMemAttr &node_attr) + { + allocer_.set_attr(node_attr); + bucket_allocer_.set_attr(bucket_attr); + return ht_.create(cal_next_prime(bucket_num), &allocer_, &bucket_allocer_); + } int create(int64_t bucket_num, _allocer *allocer, _bucket_allocer *bucket_allocer) { return ht_.create(cal_next_prime(bucket_num), allocer, bucket_allocer); diff --git a/deps/oblib/src/lib/hash/ob_linear_hash_map.h b/deps/oblib/src/lib/hash/ob_linear_hash_map.h index 17212aa6fc..6aab528ed1 100644 --- a/deps/oblib/src/lib/hash/ob_linear_hash_map.h +++ b/deps/oblib/src/lib/hash/ob_linear_hash_map.h @@ -626,8 +626,9 @@ ObLinearHashMap::HashMapMemMgrCore::HashMapMemMgrCore() : map_array_lock_(common::ObLatchIds::HASH_MAP_LOCK) { attr_.label_ = ObModIds::OB_LINEAR_HASH_MAP; + SET_USE_500(attr_); // Init node alloc. - int ret = node_alloc_.init(static_cast(sizeof(Node)), attr_.label_, attr_.tenant_id_); + int ret = node_alloc_.init(static_cast(sizeof(Node)), attr_); if (OB_FAIL(ret)) { LIB_LOG(WARN, "failed to init node alloc", K(ret)); } @@ -642,13 +643,13 @@ ObLinearHashMap::HashMapMemMgrCore::HashMapMemMgrCore() } // Init dir alloc. ret = dir_alloc_.init(total_limit, 2 * page_size, page_size); - dir_alloc_.set_label(attr_.label_); + dir_alloc_.set_attr(attr_); if (OB_FAIL(ret)) { LIB_LOG(WARN, "failed to init dir alloc", K(ret)); } // Init counter alloc. ret = cnter_alloc_.init(total_limit, 2 * page_size, page_size); - cnter_alloc_.set_label(attr_.label_); + cnter_alloc_.set_attr(attr_); if (OB_FAIL(ret)) { LIB_LOG(WARN, "failed to init cnter alloc", K(ret)); } diff --git a/deps/oblib/src/lib/hash/ob_link_hashmap.h b/deps/oblib/src/lib/hash/ob_link_hashmap.h index 0bf2dda822..0ad91b13e7 100644 --- a/deps/oblib/src/lib/hash/ob_link_hashmap.h +++ b/deps/oblib/src/lib/hash/ob_link_hashmap.h @@ -156,13 +156,17 @@ public: } int init(const lib::ObLabel &label = ObModIds::OB_CONCURRENT_HASH_MAP, const uint64_t tenant_id = OB_SERVER_TENANT_ID) + { + return init(lib::ObMemAttr(tenant_id, label)); + } + int init(const lib::ObMemAttr &attr) { int ret = OB_SUCCESS; - if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) { + if (OB_UNLIKELY(!is_valid_tenant_id(attr.tenant_id_))) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(WARN, "invalid argument", K(ret), K(label), K(tenant_id)); - } else if (OB_FAIL(array_alloc_.init(label, tenant_id))) { - COMMON_LOG(ERROR, "array_alloc_ init error", K(ret), K(label), K(tenant_id)); + COMMON_LOG(WARN, "invalid argument", K(ret), K(attr)); + } else if (OB_FAIL(array_alloc_.init(attr))) { + COMMON_LOG(ERROR, "array_alloc_ init error", K(ret), K(attr)); } else { magic_code_ = MAGIC_CODE; } diff --git a/deps/oblib/src/lib/hash/ob_link_hashmap_deps.h b/deps/oblib/src/lib/hash/ob_link_hashmap_deps.h index a57750c8d4..e5bd0ad54b 100644 --- a/deps/oblib/src/lib/hash/ob_link_hashmap_deps.h +++ b/deps/oblib/src/lib/hash/ob_link_hashmap_deps.h @@ -24,17 +24,16 @@ namespace common class DCArrayAlloc: public IAlloc { public: - DCArrayAlloc(): label_(ObModIds::OB_CONCURRENT_HASH_MAP), tenant_id_(OB_SERVER_TENANT_ID) {} + DCArrayAlloc(): attr_(OB_SERVER_TENANT_ID, ObModIds::OB_CONCURRENT_HASH_MAP) {} virtual ~DCArrayAlloc() {} - int init(const lib::ObLabel &label, const uint64_t tenant_id) + int init(const lib::ObMemAttr &attr) { int ret = OB_SUCCESS; - if (!is_valid_tenant_id(tenant_id)) { + if (!is_valid_tenant_id(attr.tenant_id_)) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(WARN, "invalid argument", K(ret), K(label), K(tenant_id)); + COMMON_LOG(WARN, "invalid argument", K(ret), K(attr)); } else { - label_ = label; - tenant_id_ = tenant_id; + attr_ = attr; } return ret; } @@ -45,8 +44,7 @@ public: if (sz <= 0) { COMMON_LOG_RET(WARN, common::OB_INVALID_ARGUMENT, "invalid argument", K(sz)); } else { - ObMemAttr attr(tenant_id_, label_); - ptr = ob_malloc(sz, attr); + ptr = ob_malloc(sz, attr_); } return ptr; } @@ -61,8 +59,7 @@ public: private: DISALLOW_COPY_AND_ASSIGN(DCArrayAlloc); private: - lib::ObLabel label_; - uint64_t tenant_id_; + lib::ObMemAttr attr_; }; struct RefNode diff --git a/deps/oblib/src/lib/hash/ob_pointer_hashmap.h b/deps/oblib/src/lib/hash/ob_pointer_hashmap.h index 26287380f4..aa1163b641 100644 --- a/deps/oblib/src/lib/hash/ob_pointer_hashmap.h +++ b/deps/oblib/src/lib/hash/ob_pointer_hashmap.h @@ -447,7 +447,12 @@ public: typedef typename SubMap::Iterator iterator; explicit ObPointerHashMap(const lib::ObLabel &label = ObModIds::OB_HASH_NODE) - : sub_map_count_(0), sub_map_mem_size_(default_size), allocator_(label) + : ObPointerHashMap(lib::ObMemAttr(OB_SERVER_TENANT_ID, label)) + { + } + + explicit ObPointerHashMap(const lib::ObMemAttr &attr) + : sub_map_count_(0), sub_map_mem_size_(default_size), allocator_(attr) { memset(sub_maps_, 0, sizeof(sub_maps_)); } diff --git a/deps/oblib/src/lib/lock/ob_bucket_lock.cpp b/deps/oblib/src/lib/lock/ob_bucket_lock.cpp index 06be0dcfaf..8e350a644d 100644 --- a/deps/oblib/src/lib/lock/ob_bucket_lock.cpp +++ b/deps/oblib/src/lib/lock/ob_bucket_lock.cpp @@ -37,6 +37,16 @@ int ObBucketLock::init( const uint32_t latch_id, const lib::ObLabel &label, const uint64_t tenant_id) +{ + attr_.label_ = label; + attr_.tenant_id_ = tenant_id; + return init(bucket_cnt, latch_id, attr_); +} + +int ObBucketLock::init( + const uint64_t bucket_cnt, + const uint32_t latch_id, + const ObMemAttr &attr) { int ret = OB_SUCCESS; if (OB_UNLIKELY(is_inited_)) { @@ -44,17 +54,15 @@ int ObBucketLock::init( COMMON_LOG(WARN, "The ObBucketLock has been inited, ", K(ret)); } else if (OB_UNLIKELY(0 == bucket_cnt) || OB_UNLIKELY(latch_id >= ObLatchIds::LATCH_END) - || OB_UNLIKELY(OB_INVALID_ID == tenant_id)) { + || OB_UNLIKELY(OB_INVALID_ID == attr.tenant_id_)) { ret = OB_INVALID_ARGUMENT; - COMMON_LOG(WARN, "Invalid argument, ", K(bucket_cnt), K(latch_id), K(label), K(tenant_id), K(ret)); + COMMON_LOG(WARN, "Invalid argument, ", K(bucket_cnt), K(latch_id), K(ret)); } else { + attr_ = attr; bucket_cnt_ = bucket_cnt; latch_cnt_ = bucket_cnt_ / 8 + 1; - ObMemAttr mem_attr; void *buf = NULL; - mem_attr.tenant_id_ = tenant_id; - mem_attr.label_ = label; - if (OB_UNLIKELY(NULL == (buf = ob_malloc(latch_cnt_ * sizeof(ObLatch), mem_attr)))) { + if (OB_UNLIKELY(NULL == (buf = ob_malloc(latch_cnt_ * sizeof(ObLatch), attr_)))) { ret = OB_ALLOCATE_MEMORY_FAILED; COMMON_LOG(ERROR, "Fail to allocate memory, ", K_(latch_cnt), K(ret)); } else { diff --git a/deps/oblib/src/lib/lock/ob_bucket_lock.h b/deps/oblib/src/lib/lock/ob_bucket_lock.h index 2701e7d95c..aaace4fc96 100644 --- a/deps/oblib/src/lib/lock/ob_bucket_lock.h +++ b/deps/oblib/src/lib/lock/ob_bucket_lock.h @@ -32,6 +32,10 @@ public: const uint32_t latch_id = ObLatchIds::DEFAULT_BUCKET_LOCK, const lib::ObLabel &label = ObModIds::BUCKET_LOCK, const uint64_t tenant_id = OB_SERVER_TENANT_ID); + int init( + const uint64_t bucket_cnt, + const uint32_t latch_id, + const lib::ObMemAttr &attr); void destroy(); int try_rdlock(const uint64_t bucket_idx); int try_wrlock(const uint64_t bucket_idx); @@ -57,6 +61,7 @@ private: OB_INLINE uint64_t bucket_to_latch_idx(const uint64_t bucket_idx) const; int try_lock_all(const bool is_write_lock); private: + lib::ObMemAttr attr_; uint64_t bucket_cnt_; uint64_t latch_cnt_; ObLatch *latches_; diff --git a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.cpp b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.cpp index 3b89f6f479..8636013b98 100644 --- a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.cpp +++ b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.cpp @@ -132,7 +132,9 @@ ObChunkInfo *ObObjFreeList::chunk_create(ObThreadCache *thread_cache) void *next = NULL; ObChunkInfo *chunk_info = NULL; - if (NULL == (chunk_addr = ob_malloc_align(alignment_, chunk_byte_size_, label_))) { + ObMemAttr attr(OB_SERVER_TENANT_ID, label_); + SET_USE_500(attr); + if (NULL == (chunk_addr = ob_malloc_align(alignment_, chunk_byte_size_, attr))) { OB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "failed to allocate chunk", K_(chunk_byte_size)); } else { chunk_info = new (reinterpret_cast(chunk_addr) + type_size_ * obj_count_per_chunk_) ObChunkInfo(); @@ -433,7 +435,9 @@ void *ObObjFreeList::global_alloc() do { if (obj_free_list_.empty()) { - if (NULL == (chunk_addr = ob_malloc_align(alignment_, chunk_byte_size_, label_))) { + ObMemAttr attr(OB_SERVER_TENANT_ID, label_); + SET_USE_500(attr); + if (NULL == (chunk_addr = ob_malloc_align(alignment_, chunk_byte_size_, attr))) { OB_LOG_RET(ERROR, OB_ALLOCATE_MEMORY_FAILED, "failed to allocate chunk", K_(chunk_byte_size)); break_loop = true; } else { diff --git a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h index 80997e3602..85d3750b29 100644 --- a/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h +++ b/deps/oblib/src/lib/objectpool/ob_concurrency_objpool.h @@ -403,11 +403,11 @@ public: } return blk_size; } - + static ObFixedClassAllocator *get(const char* label = "ConcurObjPool") { static ObFixedClassAllocator instance(sizeof(T), - ObMemAttr(common::OB_SERVER_TENANT_ID, label), + SET_USE_500(ObMemAttr(common::OB_SERVER_TENANT_ID, label)), choose_blk_size(sizeof(T)), common::get_cpu_count()); return &instance; diff --git a/deps/oblib/src/lib/objectpool/ob_pool.h b/deps/oblib/src/lib/objectpool/ob_pool.h index 011291fbfa..c9b5e6179c 100644 --- a/deps/oblib/src/lib/objectpool/ob_pool.h +++ b/deps/oblib/src/lib/objectpool/ob_pool.h @@ -39,6 +39,7 @@ public: void *alloc(); void free(void *obj); void set_label(const lib::ObLabel &label) { block_allocator_.set_label(label); } + void set_attr(const lib::ObMemAttr &attr) { block_allocator_.set_attr(attr); } uint64_t get_free_count() const; uint64_t get_in_use_count() const; @@ -132,6 +133,7 @@ public: } virtual void free(void *ptr) { block_pool_.free(ptr);}; void set_label(const lib::ObLabel &label) {block_pool_.set_label(label);}; + void set_attr(const lib::ObMemAttr &attr) { block_pool_.set_attr(attr); } int64_t get_total_mem_size() const { return block_pool_.get_total_obj_size(); } int mprotect_small_allocator(int prot) { return block_pool_.mprotect_mem_pool(prot); } void reset() override { block_pool_.reset(); } diff --git a/deps/oblib/src/lib/objectpool/ob_resource_pool.h b/deps/oblib/src/lib/objectpool/ob_resource_pool.h index 4e44c5de5c..e42cca763a 100644 --- a/deps/oblib/src/lib/objectpool/ob_resource_pool.h +++ b/deps/oblib/src/lib/objectpool/ob_resource_pool.h @@ -93,10 +93,8 @@ public: allocator_(allocator), inner_allocated_num_(0), inner_used_num_(0), - free_list_allocator_("PoolFreeList", - OB_MALLOC_NORMAL_BLOCK_SIZE, - mem_attr.tenant_id_, - mem_attr.ctx_id_), + free_list_allocator_(SET_USE_500(ObMemAttr(mem_attr.tenant_id_, "PoolFreeList", mem_attr.ctx_id_)), + OB_MALLOC_NORMAL_BLOCK_SIZE), slice_max_used_num_(0), max_idle_num_(0), last_check_ts_(0), @@ -301,14 +299,14 @@ template ObResourcePool::ObResourcePool() : ObBaseResourcePool(MAX_FREE_LIST_NUM, &allocator_, - lib::ObMemAttr(OB_SERVER_TENANT_ID, RPLabel::LABEL)) + SET_USE_500(lib::ObMemAttr(OB_SERVER_TENANT_ID, RPLabel::LABEL))) { int ret = OB_SUCCESS; const int64_t page_size = MIN(OB_MALLOC_BIG_BLOCK_SIZE, MAX(8 * sizeof(T), OB_MALLOC_MIDDLE_BLOCK_SIZE)); if (OB_FAIL(allocator_.init(lib::ObMallocAllocator::get_instance(), page_size, - lib::ObMemAttr(OB_SERVER_TENANT_ID, RPLabel::LABEL)))) { + ObBaseResourcePool::mem_attr_))) { _COMMON_LOG(INFO, "init fifo failed, ret=%d", ret); } diff --git a/deps/oblib/src/lib/objectpool/ob_server_object_pool.h b/deps/oblib/src/lib/objectpool/ob_server_object_pool.h index 8bbd9c6c4c..0c98b28eb4 100644 --- a/deps/oblib/src/lib/objectpool/ob_server_object_pool.h +++ b/deps/oblib/src/lib/objectpool/ob_server_object_pool.h @@ -221,6 +221,7 @@ public: } if (NULL == ctx) { ObMemAttr attr(tenant_id_, ObModIds::OB_SERVER_OBJECT_POOL); + SET_USE_500(attr); char *p = static_cast(ob_malloc(item_size_, attr)); if (NULL == p) { COMMON_LOG_RET(ERROR, common::OB_ALLOCATE_MEMORY_FAILED, "allocate memory failed", K(typeid(T).name()), K(item_size_)); @@ -298,9 +299,10 @@ public: int64_t s = (sizeof(T) + sizeof(Meta)); // Each cached object header has a Meta field to store necessary information and linked list pointers item_size_ = upper_align(s, CACHE_ALIGN_SIZE); // Align according to the cache line to ensure that there will be no false sharing between objects ObMemAttr attr(tenant_id_, ObModIds::OB_SERVER_OBJECT_POOL); + SET_USE_500(attr); void *ptr = NULL; if (OB_ISNULL(ptr = ob_malloc(sizeof(ObPoolArenaHead) * arena_num_, - ObMemAttr(tenant_id_, "PoolArenaArray")))) { + SET_USE_500(ObMemAttr(tenant_id_, "PoolArenaArray"))))) { ret = OB_ALLOCATE_MEMORY_FAILED; COMMON_LOG(ERROR, "allocate memory failed", K(ret), K(typeid(T).name())); } else if ((buf_ = ob_malloc(arena_num_ * cnt_per_arena_ * item_size_, attr)) == NULL) { diff --git a/deps/oblib/src/lib/oblog/ob_log.cpp b/deps/oblib/src/lib/oblog/ob_log.cpp index b9299fd599..7835fe723c 100644 --- a/deps/oblib/src/lib/oblog/ob_log.cpp +++ b/deps/oblib/src/lib/oblog/ob_log.cpp @@ -1380,13 +1380,13 @@ int ObLogger::init(const ObBaseLogWriterCfg &log_cfg, error_allocator_ = new (allocator_ + 1) ObFIFOAllocator(); if (OB_FAIL(allocator_->init(OB_MALLOC_BIG_BLOCK_SIZE, *log_mem_limiter_, - lib::ObMemAttr(OB_SERVER_TENANT_ID, "Logger", - common::ObCtxIds::LOGGER_CTX_ID)))) { + SET_USE_500(lib::ObMemAttr(OB_SERVER_TENANT_ID, "Logger", + common::ObCtxIds::LOGGER_CTX_ID))))) { LOG_STDERR("init fifo error. ret=%d\n", ret); } else if (OB_FAIL(error_allocator_->init(lib::ObMallocAllocator::get_instance(), OB_MALLOC_BIG_BLOCK_SIZE, - lib::ObMemAttr(OB_SERVER_TENANT_ID, "ErrorLogger", - common::ObCtxIds::LOGGER_CTX_ID), + SET_USE_500(lib::ObMemAttr(OB_SERVER_TENANT_ID, "ErrorLogger", + common::ObCtxIds::LOGGER_CTX_ID)), ERROR_LOG_INIT_MEM, ERROR_LOG_INIT_MEM << 1, limit))) { diff --git a/deps/oblib/src/lib/queue/ob_dedup_queue.h b/deps/oblib/src/lib/queue/ob_dedup_queue.h index 254aeaeaca..1e7f781e53 100644 --- a/deps/oblib/src/lib/queue/ob_dedup_queue.h +++ b/deps/oblib/src/lib/queue/ob_dedup_queue.h @@ -175,6 +175,7 @@ public: int add_task(const IObDedupTask &task); int64_t task_count() const { return task_queue_.get_total(); } void set_label(const lib::ObLabel &label) { allocator_.set_label(label); } + void set_attr(const lib::ObMemAttr &attr) { allocator_.set_attr(attr); } int set_thread_dead_threshold(const int64_t thread_dead_threshold); public: void run1() override; diff --git a/deps/oblib/src/lib/resource/ob_resource_mgr.cpp b/deps/oblib/src/lib/resource/ob_resource_mgr.cpp index b7e0497e5e..710e8b881d 100644 --- a/deps/oblib/src/lib/resource/ob_resource_mgr.cpp +++ b/deps/oblib/src/lib/resource/ob_resource_mgr.cpp @@ -621,6 +621,7 @@ int ObResourceMgr::create_tenant_resource_mgr_unsafe(const uint64_t tenant_id, ptr = buf; } else { ObMemAttr attr(OB_SERVER_TENANT_ID, "TntResourceMgr"); + SET_USE_500(attr); if (OB_ISNULL(ptr = ob_malloc(sizeof(ObTenantResourceMgr), attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); diff --git a/deps/oblib/src/lib/restore/ob_object_device.cpp b/deps/oblib/src/lib/restore/ob_object_device.cpp index 0f89b1cc73..0daf3dd185 100644 --- a/deps/oblib/src/lib/restore/ob_object_device.cpp +++ b/deps/oblib/src/lib/restore/ob_object_device.cpp @@ -21,6 +21,10 @@ const char *OB_STORAGE_ACCESS_TYPES_STR[] = {"reader", "overwriter", "appender", ObObjectDevice::ObObjectDevice() : oss_account_(), base_info_(NULL), is_started_(false), lock_(common::ObLatchIds::OBJECT_DEVICE_LOCK) { + auto attr = SET_USE_500("ObjectDevice"); + reader_ctx_pool_.set_attr(attr); + appender_ctx_pool_.set_attr(attr); + overwriter_ctx_pool_.set_attr(attr); } int ObObjectDevice::init(const ObIODOpts &opts) @@ -51,7 +55,7 @@ ObObjectDevice::~ObObjectDevice() } /*the app logical use call ObBackupIoAdapter::get_and_init_device*/ -/*decription: base_info just related to storage_info, +/*decription: base_info just related to storage_info, base_info is used by the reader/appender*/ int ObObjectDevice::start(const ObIODOpts &opts) { @@ -105,7 +109,7 @@ void get_opt_value(ObIODOpts *opts, const char* key, const char*& value) for (int i = 0; i < opts->opt_cnt_; i++) { if (0 == STRCMP(opts->opts_[i].key_, key)) { value = opts->opts_[i].value_.value_str; - break; + break; } } } @@ -131,7 +135,7 @@ int ObObjectDevice::get_access_type(ObIODOpts *opts, ObStorageAccessType& access ObOptValue opt_value; const char* access_type = NULL; get_opt_value(opts, "AccessType", access_type); - + if (NULL == access_type) { OB_LOG(WARN, "can not find access type!"); } else if (0 == STRCMP(access_type , OB_STORAGE_ACCESS_TYPES_STR[OB_STORAGE_ACCESS_READER])) { @@ -166,7 +170,7 @@ int ObObjectDevice::open_for_reader(const char *pathname, void*& ctx) return ret; } -/*ObStorageOssMultiPartWriter is not used int the current version, if we use, later, the open func of +/*ObStorageOssMultiPartWriter is not used int the current version, if we use, later, the open func of overwriter maybe need to add para(just like the open func of appender)*/ int ObObjectDevice::open_for_overwriter(const char *pathname, void*& ctx) { @@ -181,7 +185,7 @@ int ObObjectDevice::open_for_overwriter(const char *pathname, void*& ctx) } else { ctx = (void*)overwriter; } - } + } return ret; } @@ -218,8 +222,8 @@ int ObObjectDevice::open_for_appender(const char *pathname, ObIODOpts *opts, voi } else { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "Invalid open mode!", KCSTRING(open_mode), K(ret)); - } - + } + if (NULL == append_strategy || 0 == STRCMP(append_strategy, "OB_APPEND_USE_OVERRITE")) { //just keep the default value } else if (0 == STRCMP(append_strategy, "OB_APPEND_USE_SLICE_PUT")) { @@ -247,7 +251,7 @@ int ObObjectDevice::open_for_appender(const char *pathname, ObIODOpts *opts, voi } else { ctx = appender; } - } + } return ret; } @@ -282,7 +286,7 @@ int ObObjectDevice::release_res(void* ctx, const ObIOFd &fd, ObStorageAccessType } else { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "invalid access_type!", K(access_type), K(ret)); - } + } if (OB_SUCCESS != (ret_tmp = fd_mng_.release_fd(fd))) { ret = (OB_SUCCESS == ret) ? ret_tmp : ret; @@ -295,8 +299,8 @@ int ObObjectDevice::release_res(void* ctx, const ObIOFd &fd, ObStorageAccessType /* * mode is not used in object device */ -int ObObjectDevice::open(const char *pathname, const int flags, const mode_t mode, - ObIOFd &fd, ObIODOpts *opts) +int ObObjectDevice::open(const char *pathname, const int flags, const mode_t mode, + ObIOFd &fd, ObIODOpts *opts) { UNUSED(flags); UNUSED(mode); @@ -310,8 +314,8 @@ int ObObjectDevice::open(const char *pathname, const int flags, const mode_t mod } else if (OB_ISNULL(pathname)) { ret = OB_INVALID_ARGUMENT; OB_LOG(WARN, "pathname is null!", K(ret)); - } - + } + //handle open logical if (OB_SUCC(ret)) { if(OB_ISNULL(opts)) { @@ -322,7 +326,7 @@ int ObObjectDevice::open(const char *pathname, const int flags, const mode_t mod } else { if (OB_STORAGE_ACCESS_READER == access_type) { ret = open_for_reader(pathname, ctx); - } else if (OB_STORAGE_ACCESS_APPENDER == access_type || + } else if (OB_STORAGE_ACCESS_APPENDER == access_type || OB_STORAGE_ACCESS_RANDOMWRITER == access_type) { ret = open_for_appender(pathname, opts, ctx); } else if (OB_STORAGE_ACCESS_OVERWRITER == access_type) { @@ -340,9 +344,9 @@ int ObObjectDevice::open(const char *pathname, const int flags, const mode_t mod if (OB_SUCC(ret)) { if (OB_FAIL(fd_mng_.get_fd(ctx, device_type_, access_type, fd))) { OB_LOG(WARN, "fail to alloc fd!", K(ret), K(fd), KCSTRING(pathname), K(access_type)); - } + } } - + //handle resource free when exception happen if (OB_FAIL(ret) && !OB_ISNULL(ctx)) { int tmp_ret = OB_SUCCESS; @@ -365,7 +369,7 @@ int ObObjectDevice::close(const ObIOFd &fd) fd_mng_.get_fd_flag(fd, flag); if (!fd_mng_.validate_fd(fd, true)) { - ret = OB_NOT_INIT; + ret = OB_NOT_INIT; OB_LOG(WARN, "fail to close fd. since fd is invalid!", K(ret) ,K(fd.first_id_), K(fd.second_id_)); } else if (OB_FAIL(fd_mng_.fd_to_ctx(fd, ctx))) { OB_LOG(WARN, "fail to get ctx accroding fd!", K(ret)); @@ -385,19 +389,19 @@ int ObObjectDevice::mkdir(const char *pathname, mode_t mode) int ObObjectDevice::rmdir(const char *pathname) { common::ObString uri(pathname); - return util_.del_dir(uri); + return util_.del_dir(uri); } int ObObjectDevice::unlink(const char *pathname) { common::ObString uri(pathname); - return util_.del_file(uri); + return util_.del_file(uri); } int ObObjectDevice::exist(const char *pathname, bool &is_exist) { common::ObString uri(pathname); - return util_.is_exist(uri, is_exist); + return util_.is_exist(uri, is_exist); } /*notice: for backup, this interface only return size*/ @@ -425,7 +429,7 @@ int ObObjectDevice::scan_dir(const char *dir_name, common::ObBaseDirEntryOperato } else { ret = util_.list_files(uri, op); } - + if (OB_FAIL(ret)) { OB_LOG(WARN, "fail to do list/dir scan!", K(ret), K(is_dir_scan), KCSTRING(dir_name)); } @@ -439,7 +443,7 @@ int ObObjectDevice::is_tagging(const char *pathname, bool &is_tagging) } int ObObjectDevice::pread(const ObIOFd &fd, const int64_t offset, const int64_t size, - void *buf, int64_t &read_size, ObIODPreadChecker *checker) + void *buf, int64_t &read_size, ObIODPreadChecker *checker) { UNUSED(checker); int ret = OB_SUCCESS; @@ -463,7 +467,7 @@ int ObObjectDevice::pread(const ObIOFd &fd, const int64_t offset, const int64_t } else if (OB_FAIL(reader->pread((char*)buf, size, offset, read_size))) { OB_LOG(WARN, "fail to pread!", K(ret)); } - } + } return ret; } @@ -475,7 +479,7 @@ int ObObjectDevice::write(const ObIOFd &fd, const void *buf, const int64_t size, int ret = OB_SUCCESS; int flag = -1; void* ctx = NULL; - + fd_mng_.get_fd_flag(fd, flag); if (!fd_mng_.validate_fd(fd, true)) { ret = OB_NOT_INIT; @@ -502,7 +506,7 @@ int ObObjectDevice::write(const ObIOFd &fd, const void *buf, const int64_t size, } else { write_size = 0; } - return ret; + return ret; } /*object storage does not support random write, so offset is no use @@ -515,7 +519,7 @@ int ObObjectDevice::pwrite(const ObIOFd &fd, const int64_t offset, const int64_t int ret = OB_SUCCESS; int flag = -1; void* ctx = NULL; - + UNUSED(offset); fd_mng_.get_fd_flag(fd, flag); @@ -644,7 +648,7 @@ int ObObjectDevice::mark_blocks(ObIBlockIterator &block_iter) { UNUSED(block_iter); OB_LOG_RET(WARN, OB_NOT_SUPPORTED, "mark_blocks is not support in object device !", K(device_type_)); - return OB_NOT_SUPPORTED; + return OB_NOT_SUPPORTED; } int ObObjectDevice::alloc_block(const ObIODOpts *opts, ObIOFd &block_id) @@ -745,7 +749,7 @@ int ObObjectDevice::io_cancel(ObIOContext *io_context, ObIOCB *iocb) UNUSED(io_context); UNUSED(iocb); OB_LOG_RET(WARN, OB_NOT_SUPPORTED, "io_cancel is not support in object device !", K(device_type_)); - return OB_NOT_SUPPORTED; + return OB_NOT_SUPPORTED; } int ObObjectDevice::io_getevents(ObIOContext *io_context, int64_t min_nr, ObIOEvents *events, struct timespec *timeout) @@ -806,7 +810,7 @@ int ObObjectDevice::check_space_full(const int64_t required_size) const { UNUSED(required_size); OB_LOG_RET(WARN, OB_NOT_SUPPORTED, "check_space_full is not support in object device !", K(device_type_)); - return OB_NOT_SUPPORTED; + return OB_NOT_SUPPORTED; } int ObObjectDevice::fdatasync(const ObIOFd &fd) diff --git a/deps/oblib/src/lib/stat/ob_di_tls.h b/deps/oblib/src/lib/stat/ob_di_tls.h index c19737f84f..7c446ce04b 100644 --- a/deps/oblib/src/lib/stat/ob_di_tls.h +++ b/deps/oblib/src/lib/stat/ob_di_tls.h @@ -86,11 +86,12 @@ T* ObDITls::get_instance() static const char* label = get_label(); di_tls.instance_ = (T*)PLACE_HOLDER; // add tenant - di_tls.instance_ = OB_NEW(T, label); + ObMemAttr attr(OB_SERVER_TENANT_ID, label); + SET_USE_500(attr); + di_tls.instance_ = OB_NEW(T, attr); } return di_tls.instance_; } - template class ObDITls { @@ -155,8 +156,10 @@ T* ObDITls::get_instance() if (!di_tls.is_valid()) { static const char* label = get_label(); di_tls.instance_ = (T*)PLACE_HOLDER; + ObMemAttr attr(OB_SERVER_TENANT_ID, label); + SET_USE_500(attr); // add tenant - if (OB_NOT_NULL(di_tls.instance_ = (T*)ob_malloc(sizeof(T) * N, label))) { + if (OB_NOT_NULL(di_tls.instance_ = (T*)ob_malloc(sizeof(T) * N, attr))) { for (auto i = 0; i < N; ++i) { new (di_tls.instance_ + i) T; } diff --git a/deps/oblib/src/lib/string/ob_string_holder.h b/deps/oblib/src/lib/string/ob_string_holder.h index 8591689c4b..b05ad1ec74 100644 --- a/deps/oblib/src/lib/string/ob_string_holder.h +++ b/deps/oblib/src/lib/string/ob_string_holder.h @@ -21,32 +21,13 @@ namespace oceanbase { namespace common { -namespace value_sematic_string -{ -class DefaultAllocator : public ObIAllocator -{ -public: - virtual void* alloc(const int64_t size) override - { return ob_malloc(size, "VSStr"); } - - virtual void* alloc(const int64_t size, const ObMemAttr &attr) override - { return ob_malloc(size, attr); } - - virtual void free(void *ptr) override - { ob_free(ptr); } - - static DefaultAllocator &get_instance() { - static DefaultAllocator allocator; - return allocator; - } -}; -} class ObStringHolder { static constexpr int64_t TINY_STR_SIZE = 32;// no need count '\0' public: - ObStringHolder() : buffer_(nullptr), len_(0) {} + ObStringHolder(const lib::ObMemAttr &attr=lib::ObMemAttr(OB_SERVER_TENANT_ID, "VSStr")) + : buffer_(nullptr), len_(0), attr_(attr) {} ~ObStringHolder() { reset(); } void reset() { if (buffer_ == local_buffer_for_tiny_str_) {// tiny str @@ -55,7 +36,7 @@ public: } else if (OB_ISNULL(buffer_)) {// empty str len_ = 0; } else {// big str - value_sematic_string::DefaultAllocator::get_instance().free(buffer_); + ob_free(buffer_); buffer_ = nullptr; len_ = 0; } @@ -85,7 +66,7 @@ public: } else {// big str int64_t len = str.length(); char *temp_buffer = nullptr; - if (OB_ISNULL(temp_buffer = (char *)value_sematic_string::DefaultAllocator::get_instance().alloc(len))) { + if (OB_ISNULL(temp_buffer = (char *)ob_malloc(len, attr_))) { ret = OB_ALLOCATE_MEMORY_FAILED; } else { reset(); @@ -138,8 +119,9 @@ private: char *buffer_; int64_t len_; char local_buffer_for_tiny_str_[TINY_STR_SIZE]; + lib::ObMemAttr attr_; }; } } -#endif \ No newline at end of file +#endif diff --git a/deps/oblib/src/lib/thread/ob_async_task_queue.cpp b/deps/oblib/src/lib/thread/ob_async_task_queue.cpp index d7ee4ee16a..33e2905410 100644 --- a/deps/oblib/src/lib/thread/ob_async_task_queue.cpp +++ b/deps/oblib/src/lib/thread/ob_async_task_queue.cpp @@ -53,6 +53,7 @@ int ObAsyncTaskQueue::init(const int64_t thread_cnt, const int64_t queue_size, c } else if (OB_FAIL(create(thread_cnt, thread_name))) { LOG_WARN("create async task thread failed", K(ret), K(thread_cnt)); } else { + allocator_.set_attr(SET_USE_500("AsyncTaskQueue")); is_inited_ = true; } return ret; diff --git a/deps/oblib/src/lib/thread/thread_mgr.cpp b/deps/oblib/src/lib/thread/thread_mgr.cpp index a157a01459..c32f6ce041 100644 --- a/deps/oblib/src/lib/thread/thread_mgr.cpp +++ b/deps/oblib/src/lib/thread/thread_mgr.cpp @@ -46,7 +46,7 @@ void lib_init_create_func() { #define TG_DEF(id, name, desc, scope, type, args...) \ create_funcs_[TGDefIDs::id] = []() { \ - auto ret = OB_NEW(TGCLSMap::CLS, "tg", args); \ + auto ret = OB_NEW(TGCLSMap::CLS, SET_USE_500("tg"), args); \ ret->attr_ = {#name, desc, TGScope::scope, TGType::type}; \ return ret; \ }; diff --git a/deps/oblib/src/lib/timezone/ob_timezone_info.cpp b/deps/oblib/src/lib/timezone/ob_timezone_info.cpp index 9c6eced101..f66c570f6a 100644 --- a/deps/oblib/src/lib/timezone/ob_timezone_info.cpp +++ b/deps/oblib/src/lib/timezone/ob_timezone_info.cpp @@ -39388,8 +39388,8 @@ int ObTimeZoneInfoPos::compare_upgrade(const ObTimeZoneInfoPos &other, bool &is_ { int ret = OB_SUCCESS; is_equal = false; - const common::ObSArray &other_type = other.get_tz_tran_types(); - const common::ObSArray &tz_tran_types = get_tz_tran_types(); + const common::ObSArray &other_type = other.get_tz_tran_types(); + const common::ObSArray &tz_tran_types = get_tz_tran_types(); if (OB_UNLIKELY(tz_id_ != other.get_tz_id()) || OB_UNLIKELY(0 != other.get_tz_name().compare(tz_name_)) @@ -39455,7 +39455,7 @@ int ObTimeZoneInfoPos::get_timezone_offset(int64_t value, int32_t &offset_sec, common::ObString &tz_abbr_str, int32_t &tran_type_id) const { int ret = OB_SUCCESS; - const common::ObSArray &tz_tran_types = get_tz_tran_types(); + const common::ObSArray &tz_tran_types = get_tz_tran_types(); int64_t type_cnt = tz_tran_types.count(); int64_t type_idx = 0; if (OB_UNLIKELY(false == is_valid())) { @@ -39508,7 +39508,7 @@ int ObTimeZoneInfoPos::get_timezone_offset(const int32_t tran_type_id, common::ObString &tz_abbr_str, int32_t &offset_sec) const { int ret = OB_SUCCESS; - const common::ObSArray &tz_tran_types = get_tz_tran_types(); + const common::ObSArray &tz_tran_types = get_tz_tran_types(); int64_t type_idx = 0; if (OB_UNLIKELY(false == is_valid())) { ret = OB_ERR_UNEXPECTED; @@ -39534,7 +39534,7 @@ int ObTimeZoneInfoPos::get_timezone_sub_offset(int64_t value, const ObString &tz int32_t &offset_sec, int32_t &tz_id, int32_t &tran_type_id) const { int ret = OB_SUCCESS; - const common::ObSArray &tz_revt_types = get_tz_revt_types(); + const common::ObSArray &tz_revt_types = get_tz_revt_types(); tz_id = static_cast(tz_id_); int64_t type_idx = 0; const bool is_oracle_mode = lib::is_oracle_mode(); @@ -39595,10 +39595,10 @@ int ObTimeZoneInfoPos::calc_revt_types() ret = OB_ERR_UNEXPECTED; LOG_WARN("tz info is invalid", K(ret)); } else { - common::ObSArray &tz_revt_types = tz_revt_types_[get_curr_idx() % 2]; + common::ObSArray &tz_revt_types = tz_revt_types_[get_curr_idx() % 2]; tz_revt_types.reset(); ObTZRevertTypeInfo revt_type_info; - const common::ObSArray &tz_tran_types = get_tz_tran_types(); + const common::ObSArray &tz_tran_types = get_tz_tran_types(); //add first revert type, type info is from default type revt_type_info.type_class_ = ObTZRevertTypeInfo::NORMAL; @@ -39670,8 +39670,8 @@ OB_DEF_SERIALIZE(ObTimeZoneInfoPos) { int ret = OB_SUCCESS; ObString tz_name_str(static_cast(strlen(tz_name_)), tz_name_); - const common::ObSArray &tz_tran_types = get_tz_tran_types(); - const common::ObSArray &tz_revt_types = get_tz_revt_types(); + const common::ObSArray &tz_tran_types = get_tz_tran_types(); + const common::ObSArray &tz_revt_types = get_tz_revt_types(); LST_DO_CODE(OB_UNIS_ENCODE, tz_id_, default_type_, tz_tran_types, tz_revt_types, tz_name_str); return ret; } @@ -39681,8 +39681,8 @@ OB_DEF_DESERIALIZE(ObTimeZoneInfoPos) int ret = OB_SUCCESS; ObString tz_name_str; curr_idx_ = 0; - common::ObSArray &tz_tran_types = tz_tran_types_[0]; - common::ObSArray &tz_revt_types = tz_revt_types_[0]; + common::ObSArray &tz_tran_types = tz_tran_types_[0]; + common::ObSArray &tz_revt_types = tz_revt_types_[0]; LST_DO_CODE(OB_UNIS_DECODE, tz_id_, default_type_, tz_tran_types, tz_revt_types, tz_name_str); if(OB_FAIL(ret)) { @@ -39756,15 +39756,15 @@ void ObTZNameIDAlloc::free_node(ObTZNameHashNode *node) } } -int ObTZInfoMap::init(const lib::ObLabel &label) +int ObTZInfoMap::init(const lib::ObMemAttr &attr) { int ret = OB_SUCCESS; if (OB_UNLIKELY(inited_)) { ret = OB_INIT_TWICE; LOG_WARN("init twice", K(ret)); - } else if (OB_FAIL(id_map_.init(label))) { + } else if (OB_FAIL(id_map_.init(attr))) { LOG_WARN("fail to init id map", K(ret)); - } else if (OB_FAIL(name_map_.init(label))) { + } else if (OB_FAIL(name_map_.init(attr))) { LOG_WARN("fail to init name map", K(ret)); } else { inited_ = true; diff --git a/deps/oblib/src/lib/timezone/ob_timezone_info.h b/deps/oblib/src/lib/timezone/ob_timezone_info.h index 34d8599e4c..6f9de642c7 100644 --- a/deps/oblib/src/lib/timezone/ob_timezone_info.h +++ b/deps/oblib/src/lib/timezone/ob_timezone_info.h @@ -532,12 +532,12 @@ public: inline int32_t get_curr_idx() const { return curr_idx_; } inline int32_t get_next_idx() const { return curr_idx_ + 1; } inline void inc_curr_idx() { ++curr_idx_; } - const common::ObSArray &get_tz_tran_types() const { return tz_tran_types_[get_curr_idx() % 2]; } - const common::ObSArray &get_tz_revt_types() const { return tz_revt_types_[get_curr_idx() % 2]; } - const common::ObSArray &get_next_tz_tran_types() const { return tz_tran_types_[get_next_idx() % 2]; } - const common::ObSArray &get_next_tz_revt_types() const { return tz_revt_types_[get_next_idx() % 2]; } - common::ObSArray &get_next_tz_tran_types() { return tz_tran_types_[get_next_idx() % 2]; } - common::ObSArray &get_next_tz_revt_types() { return tz_revt_types_[get_next_idx() % 2]; } + const common::ObSArray &get_tz_tran_types() const { return tz_tran_types_[get_curr_idx() % 2]; } + const common::ObSArray &get_tz_revt_types() const { return tz_revt_types_[get_curr_idx() % 2]; } + const common::ObSArray &get_next_tz_tran_types() const { return tz_tran_types_[get_next_idx() % 2]; } + const common::ObSArray &get_next_tz_revt_types() const { return tz_revt_types_[get_next_idx() % 2]; } + common::ObSArray &get_next_tz_tran_types() { return tz_tran_types_[get_next_idx() % 2]; } + common::ObSArray &get_next_tz_revt_types() { return tz_revt_types_[get_next_idx() % 2]; } int calc_revt_types(); virtual int timezone_to_str(char *buf, const int64_t len, int64_t &pos) const; VIRTUAL_TO_STRING_KV("tz_name", common::ObString(common::OB_MAX_TZ_NAME_LEN, tz_name_), @@ -562,9 +562,9 @@ private: there are no transitions at all.*/ ObTZTransitionTypeInfo default_type_; //used for utc time -> local time - common::ObSArray tz_tran_types_[2]; + common::ObSArray tz_tran_types_[2]; //used for local time -> utc time - common::ObSArray tz_revt_types_[2]; + common::ObSArray tz_revt_types_[2]; uint32_t curr_idx_; char tz_name_[common::OB_MAX_TZ_NAME_LEN]; }; @@ -630,7 +630,7 @@ class ObTZInfoMap public: ObTZInfoMap() : inited_(false), id_map_(), name_map_() {} ~ObTZInfoMap() {} - int init(const lib::ObLabel &label); + int init(const lib::ObMemAttr &attr); int reset(); void destroy(); int print_tz_info_map(); diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_session_handler.cpp b/deps/oblib/src/rpc/obrpc/ob_rpc_session_handler.cpp index f7494a2924..1c8462a0d2 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_session_handler.cpp +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_session_handler.cpp @@ -26,8 +26,9 @@ using namespace oceanbase::obrpc; ObRpcSessionHandler::ObRpcSessionHandler() { sessid_ = 0; - next_wait_map_.create(MAX_COND_COUNT, ObModIds::OB_HASH_BUCKET_NEXT_WAIT_MAP, - ObModIds::OB_HASH_NODE_NEXT_WAIT_MAP); + ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_HASH_NODE_NEXT_WAIT_MAP); + SET_USE_500(attr); + next_wait_map_.create(MAX_COND_COUNT, attr, attr); max_waiting_thread_count_ = MAX_WAIT_THREAD_COUNT; waiting_thread_count_ = 0; diff --git a/deps/oblib/unittest/lib/allocator/test_page_arena.cpp b/deps/oblib/unittest/lib/allocator/test_page_arena.cpp index 06ddeb421d..7c58b54be2 100644 --- a/deps/oblib/unittest/lib/allocator/test_page_arena.cpp +++ b/deps/oblib/unittest/lib/allocator/test_page_arena.cpp @@ -37,7 +37,7 @@ struct MyPageAllocator: public ObIAllocator void freed(const int64_t sz) { UNUSED(sz); } void set_label(const oceanbase::lib::ObLabel &label) { UNUSED(label); } void set_tenant_id(uint64_t tenant_id) { UNUSED(tenant_id); } - oceanbase::lib::ObLabel get_label() const { return 0; } + oceanbase::lib::ObLabel get_label() const { return "test"; } static int64_t alloc_count_; static int64_t free_count_; diff --git a/src/logservice/archiveservice/dynamic_buffer.cpp b/src/logservice/archiveservice/dynamic_buffer.cpp index 4706063dbf..eb48ae0462 100644 --- a/src/logservice/archiveservice/dynamic_buffer.cpp +++ b/src/logservice/archiveservice/dynamic_buffer.cpp @@ -24,13 +24,7 @@ namespace oceanbase namespace archive { DynamicBuffer::DynamicBuffer(const int64_t MAX_SIZE) : - buf_size_(0), - buf_(NULL), - ref_(0), - buf_limit_(MAX_SIZE), - buf_gen_timestamp_(OB_INVALID_TIMESTAMP), - buf_size_usage_(), - label_("DynamicBuffer") + DynamicBuffer("DynamicBuffer", MAX_SIZE) {} DynamicBuffer::DynamicBuffer(const char *label, const int64_t MAX_SIZE) : @@ -41,7 +35,9 @@ DynamicBuffer::DynamicBuffer(const char *label, const int64_t MAX_SIZE) : buf_gen_timestamp_(OB_INVALID_TIMESTAMP), buf_size_usage_(), label_(label) -{} +{ + buf_size_usage_.set_attr(SET_USE_500(label)); +} DynamicBuffer::~DynamicBuffer() { diff --git a/src/logservice/archiveservice/large_buffer_pool.cpp b/src/logservice/archiveservice/large_buffer_pool.cpp index 27ff3400cb..fa774773a7 100644 --- a/src/logservice/archiveservice/large_buffer_pool.cpp +++ b/src/logservice/archiveservice/large_buffer_pool.cpp @@ -27,7 +27,9 @@ LargeBufferPool::LargeBufferPool() : label_(), array_(), rwlock_() -{} +{ + array_.set_attr(SET_USE_500("LargeBufferPool")); +} LargeBufferPool::~LargeBufferPool() { diff --git a/src/logservice/libobcdc/src/ob_log_tenant.cpp b/src/logservice/libobcdc/src/ob_log_tenant.cpp index 45e671f00f..5237e91a6f 100644 --- a/src/logservice/libobcdc/src/ob_log_tenant.cpp +++ b/src/logservice/libobcdc/src/ob_log_tenant.cpp @@ -894,7 +894,8 @@ int ObLogTenant::init_tz_info_(const uint64_t tenant_id) } if (OB_FAIL(ret)) { - } else if (OB_FAIL(tz_info_map_->init(ObModIds::OB_HASH_BUCKET_TIME_ZONE_INFO_MAP))) { + } else if (OB_FAIL(tz_info_map_->init(ObMemAttr(OB_SERVER_TENANT_ID, + ObModIds::OB_HASH_BUCKET_TIME_ZONE_INFO_MAP)))) { LOG_ERROR("fail to init tz_info_map_", K(tenant_id), KR(ret)); } else if (TCTX.timezone_info_getter_->init_tz_info_wrap( tenant_id, diff --git a/src/logservice/palf/election/utils/election_event_recorder.cpp b/src/logservice/palf/election/utils/election_event_recorder.cpp index 08d680f2d2..8b0d9877ae 100644 --- a/src/logservice/palf/election/utils/election_event_recorder.cpp +++ b/src/logservice/palf/election/utils/election_event_recorder.cpp @@ -57,7 +57,9 @@ int EventRecorder::report_event_(ElectionEventType type, const common::ObString ObAddr self_addr = self_addr_; ObUniqueGuard uniq_holder; #define PRINT_WRAPPER KR(ret), K(*this), K(type), K(info) - if (CLICK_FAIL(ob_make_unique(uniq_holder))) { + lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "EventReHolder"); + SET_USE_500(attr); + if (CLICK_FAIL(ob_make_unique(uniq_holder, attr))) { LOG_EVENT(WARN, "fail to make unique guard"); } else if (CLICK_FAIL(uniq_holder->assign(info))) { LOG_EVENT(WARN, "fail to create unique ownership of string"); diff --git a/src/observer/ob_inner_sql_connection_pool.cpp b/src/observer/ob_inner_sql_connection_pool.cpp index 1131aa3314..3a84fac953 100644 --- a/src/observer/ob_inner_sql_connection_pool.cpp +++ b/src/observer/ob_inner_sql_connection_pool.cpp @@ -30,7 +30,7 @@ namespace observer ObInnerSQLConnectionPool::ObInnerSQLConnectionPool() : inited_(false), stop_(false), total_conn_cnt_(0), free_conn_list_(), used_conn_list_(), - allocator_(ObModIds::OB_INNER_SQL_CONN_POOL), + allocator_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_INNER_SQL_CONN_POOL))), schema_service_(NULL), ob_sql_(NULL), vt_iter_creator_(NULL), diff --git a/src/observer/ob_resource_inner_sql_connection_pool.cpp b/src/observer/ob_resource_inner_sql_connection_pool.cpp index a86c1972d8..0537453830 100644 --- a/src/observer/ob_resource_inner_sql_connection_pool.cpp +++ b/src/observer/ob_resource_inner_sql_connection_pool.cpp @@ -42,11 +42,13 @@ int ObResourceInnerSQLConnectionPool::init(ObMultiVersionSchemaService *schema_s int ret = OB_SUCCESS; ObLatchWGuard guard(lock_, ObLatchIds::INNER_CONN_POOL_LOCK); + ObMemAttr attr(OB_SERVER_TENANT_ID, "IdConnMap"); + SET_USE_500(attr); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("ObResourceInnerSQLConnectionPool has already been inited", K(ret)); } else if (OB_FAIL(id_conn_map_.create(ObInnerSQLConnectionPool::WARNNING_CONNECTION_CNT, - lib::ObLabel("IdConnMap")))) { + attr, attr))) { LOG_WARN("fail to create id_conn_map_", K(ret)); } else if (OB_FAIL(inner_sql_conn_pool_.init(schema_service, ob_sql, diff --git a/src/observer/ob_tenant_duty_task.cpp b/src/observer/ob_tenant_duty_task.cpp index d613a393b5..afa221f80a 100644 --- a/src/observer/ob_tenant_duty_task.cpp +++ b/src/observer/ob_tenant_duty_task.cpp @@ -147,7 +147,9 @@ int ObTenantDutyTask::update_tenant_ctx_memory_throttle(uint64_t tenant_id) limit = INT64_MAX; // empty str means no limit, and not care ctx_id. } for (int i = 0; i < ObCtxIds::MAX_CTX_ID; i++) { - if (ObCtxIds::WORK_AREA == i || ObCtxIds::META_OBJ_CTX_ID == i) { + if (ObCtxIds::WORK_AREA == i || + ObCtxIds::META_OBJ_CTX_ID == i || + ObCtxIds::DO_NOT_USE_ME == i) { // use sql_work_area continue; } diff --git a/src/observer/ob_uniq_task_queue.h b/src/observer/ob_uniq_task_queue.h index e0651a9593..f30ebe7c07 100644 --- a/src/observer/ob_uniq_task_queue.h +++ b/src/observer/ob_uniq_task_queue.h @@ -197,6 +197,8 @@ int ObUniqTaskQueue::init_only(Process *updater, const int64_t th const int64_t queue_size, const char *thread_name) { int ret = common::OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, common::ObModIds::OB_PARTITION_TABLE_TASK); + SET_USE_500(attr); const int64_t group_count = 128; if (inited_) { ret = common::OB_INIT_TWICE; @@ -206,12 +208,12 @@ int ObUniqTaskQueue::init_only(Process *updater, const int64_t th SERVER_LOG(WARN, "invalid argument", K(thread_num), K(queue_size), K(updater)); } else if (OB_FAIL(cond_.init(common::ObWaitEventIds::PARTITION_TABLE_UPDATER_COND_WAIT))) { SERVER_LOG(WARN, "fai to init condition, ", K(ret)); - } else if (OB_FAIL(task_map_.create(queue_size, common::ObModIds::OB_PARTITION_TABLE_TASK))) { + } else if (OB_FAIL(task_map_.create(queue_size, attr, attr))) { SERVER_LOG(WARN, "create hash map failed", K(ret), K(queue_size)); } else if (OB_FAIL(group_map_.create(group_count, - common::ObModIds::OB_PARTITION_TABLE_TASK))) { + attr, attr))) { SERVER_LOG(WARN, "create hash map failed", K(ret), K(group_count)); - } else if (OB_FAIL(processing_task_map_.create(queue_size, common::ObModIds::OB_PARTITION_TABLE_TASK))) { + } else if (OB_FAIL(processing_task_map_.create(queue_size, attr, attr))) { SERVER_LOG(WARN, "create hash map failed", K(ret)); } else { this->set_thread_count(static_cast(thread_num)); diff --git a/src/observer/omt/ob_tenant_timezone.cpp b/src/observer/omt/ob_tenant_timezone.cpp index f7bd9c0c82..f65485927d 100644 --- a/src/observer/omt/ob_tenant_timezone.cpp +++ b/src/observer/omt/ob_tenant_timezone.cpp @@ -46,14 +46,14 @@ int ObTenantTimezone::init(ObTenantTimezoneMgr *tz_mgr) int ret = OB_SUCCESS; tenant_tz_mgr_ = tz_mgr; is_inited_ = true; - tz_info_map_ = OB_NEW(ObTZInfoMap, "TZInfoMap"); - tz_info_mgr_ = OB_NEW(ObTimeZoneInfoManager, "TZInfoMgr", OBSERVER.get_common_rpc_proxy(), + tz_info_map_ = OB_NEW(ObTZInfoMap, SET_USE_500("TZInfoMap")); + tz_info_mgr_ = OB_NEW(ObTimeZoneInfoManager, SET_USE_500("TZInfoMgr"), OBSERVER.get_common_rpc_proxy(), OBSERVER.get_mysql_proxy(), OBSERVER.get_root_service(), *tz_info_map_, tenant_id_); if (OB_ISNULL(tz_info_map_) || OB_ISNULL(tz_info_mgr_)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("fail to allocate mem for tz_info", K(ret), K(tz_info_map_), K(tz_info_mgr_)); - } else if (OB_FAIL(tz_info_map_->init("TZInfoMap"))) { + } else if (OB_FAIL(tz_info_map_->init(SET_USE_500("TZInfoMap")))) { LOG_WARN("fail to init tz_info_map_", K(ret)); } else if (OB_FAIL(tz_info_mgr_->init())) { LOG_WARN("fail to init tz_info_mgr_", K(ret)); diff --git a/src/observer/omt/ob_tenant_timezone_mgr.cpp b/src/observer/omt/ob_tenant_timezone_mgr.cpp index 6a6ae6103a..24d4e4958a 100644 --- a/src/observer/omt/ob_tenant_timezone_mgr.cpp +++ b/src/observer/omt/ob_tenant_timezone_mgr.cpp @@ -384,7 +384,7 @@ int ObTenantTimezoneMgr::get_tenant_timezone_default(const uint64_t tenant_id, static ObTZInfoMap tz_map; UNUSED(tenant_id); if (OB_UNLIKELY(! tz_map.is_inited()) && - OB_FAIL(tz_map.init("TzMapStatic"))) { + OB_FAIL(tz_map.init(SET_USE_500("TzMapStatic")))) { LOG_WARN("init time zone info map failed", K(ret)); } else { timezone_wrap.set_tz_map(&tz_map); diff --git a/src/share/allocator/ob_memstore_allocator_mgr.cpp b/src/share/allocator/ob_memstore_allocator_mgr.cpp index 73f9e8800b..293cdd4b6a 100644 --- a/src/share/allocator/ob_memstore_allocator_mgr.cpp +++ b/src/share/allocator/ob_memstore_allocator_mgr.cpp @@ -60,6 +60,7 @@ int ObMemstoreAllocatorMgr::get_tenant_memstore_allocator(const uint64_t tenant_ ObMemAttr attr; attr.tenant_id_ = OB_SERVER_TENANT_ID; attr.label_ = ObModIds::OB_MEMSTORE_ALLOCATOR; + SET_USE_500(attr); void *buf = ob_malloc(sizeof(TAllocator), attr); if (NULL != buf) { TAllocator *allocator = new (buf) TAllocator(); diff --git a/src/share/allocator/ob_tenant_mutil_allocator_mgr.cpp b/src/share/allocator/ob_tenant_mutil_allocator_mgr.cpp index e0fc67a537..dcb19432eb 100644 --- a/src/share/allocator/ob_tenant_mutil_allocator_mgr.cpp +++ b/src/share/allocator/ob_tenant_mutil_allocator_mgr.cpp @@ -113,6 +113,7 @@ int ObTenantMutilAllocatorMgr::construct_allocator_(const uint64_t tenant_id, OB_LOG(WARN, "invalid arguments", K(ret), K(tenant_id)); } else { ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_TENANT_MUTIL_ALLOCATOR); + SET_USE_500(attr); void *buf = ob_malloc(sizeof(TMA), attr); if (NULL == buf) { ret = OB_ALLOCATE_MEMORY_FAILED; diff --git a/src/share/cache/ob_kvcache_hazard_version.cpp b/src/share/cache/ob_kvcache_hazard_version.cpp index cd06f52f32..975f51116f 100644 --- a/src/share/cache/ob_kvcache_hazard_version.cpp +++ b/src/share/cache/ob_kvcache_hazard_version.cpp @@ -17,7 +17,7 @@ namespace oceanbase{ namespace common{ -/* +/* * -----------------------------------------------------------KVCacheHazardNode----------------------------------------------------------- */ KVCacheHazardNode::KVCacheHazardNode() @@ -38,7 +38,7 @@ void KVCacheHazardNode::set_next(KVCacheHazardNode * const next) } } -/* +/* * -----------------------------------------------------------KVCacheHazardThreadStore----------------------------------------------------------- */ KVCacheHazardThreadStore::KVCacheHazardThreadStore() @@ -139,7 +139,7 @@ void KVCacheHazardThreadStore::retire(const uint64_t version, const uint64_t ten } void KVCacheHazardThreadStore::add_nodes(KVCacheHazardNode &list) -{ +{ // Remember to udapte waiting_nodes_count_ outside KVCacheHazardNode *tail = &list; @@ -156,17 +156,17 @@ void KVCacheHazardThreadStore::add_nodes(KVCacheHazardNode &list) } } -/* +/* * -----------------------------------------------------------GlobalHazardVersion----------------------------------------------------------- */ GlobalHazardVersion::GlobalHazardVersion() - : version_(0), + : version_(0), thread_waiting_node_threshold_(0), thread_store_lock_(common::ObLatchIds::THREAD_STORE_LOCK), thread_stores_(nullptr), thread_store_allocator_(), - ts_key_(OB_INVALID_PTHREAD_KEY), + ts_key_(OB_INVALID_PTHREAD_KEY), inited_(false) { } @@ -176,17 +176,20 @@ GlobalHazardVersion::~GlobalHazardVersion() destroy(); } -int GlobalHazardVersion::init(const int64_t thread_waiting_node_threshold) -{ +int GlobalHazardVersion::init(const int64_t thread_waiting_node_threshold) +{ int ret = OB_SUCCESS; if (OB_UNLIKELY(inited_)) { ret = OB_INIT_TWICE; COMMON_LOG(WARN, "This HazardVersion has been inited", K(ret), K(inited_)); - } else if (OB_FAIL(thread_store_allocator_.init(OB_MALLOC_MIDDLE_BLOCK_SIZE, "KVCACHE_HAZARD", OB_SERVER_TENANT_ID, + } else if (OB_FAIL(thread_store_allocator_.init(OB_MALLOC_MIDDLE_BLOCK_SIZE, "KVCACHE_HAZARD", OB_SERVER_TENANT_ID, INT64_MAX))) { COMMON_LOG(WARN, "Fail to init thread store allocator", K(ret)); } else { + lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "KVCACHE_HAZARD"); + SET_USE_500(attr); + thread_store_allocator_.set_attr(attr); int syserr = pthread_key_create(&ts_key_, deregister_thread); if (OB_UNLIKELY(0 != syserr)) { ret = OB_ERR_UNEXPECTED; @@ -311,7 +314,7 @@ int GlobalHazardVersion::retire(const uint64_t tenant_id) int GlobalHazardVersion::get_thread_store(KVCacheHazardThreadStore *&ts) { int ret = OB_SUCCESS; - + ts = static_cast(pthread_getspecific(ts_key_)); if (OB_UNLIKELY(nullptr == ts)) { int64_t thread_id = GETTID(); @@ -337,7 +340,7 @@ int GlobalHazardVersion::get_thread_store(KVCacheHazardThreadStore *&ts) ts = free_store; break; } - } + } free_store = free_store->get_next(); } @@ -368,7 +371,7 @@ int GlobalHazardVersion::get_thread_store(KVCacheHazardThreadStore *&ts) } } } - } + } return ret; } @@ -463,7 +466,7 @@ void GlobalHazardVersion::deregister_thread(void *d_ts) static_cast(d_ts)->set_exit(); } -/* +/* * -----------------------------------------------------------GlobalHazardVersionGuard----------------------------------------------------------- */ diff --git a/src/share/cache/ob_kvcache_inst_map.cpp b/src/share/cache/ob_kvcache_inst_map.cpp index 004700416d..da3023d555 100644 --- a/src/share/cache/ob_kvcache_inst_map.cpp +++ b/src/share/cache/ob_kvcache_inst_map.cpp @@ -308,11 +308,13 @@ int ObKVCacheInstMap::get_cache_inst( //double check, success to get inst, add ref to return outside add_inst_ref(inst); } else if (OB_HASH_NOT_EXIST == ret) { + lib::ObMemAttr attr(inst_key.tenant_id_, "CACHE_MAP_NODE"); + SET_USE_500(attr); if (OB_FAIL(inst_pool_.pop(inst))) { COMMON_LOG(WARN, "Fail to alloc cache inst, ", K(ret)); } else if (OB_FAIL(get_mb_list(inst_key.tenant_id_, inst->mb_list_handle_))) { COMMON_LOG(WARN, "get mb list failed", K(ret), "tenant_id", inst_key.tenant_id_); - } else if (OB_FAIL(inst->node_allocator_.init(OB_MALLOC_BIG_BLOCK_SIZE, "CACHE_MAP_NODE", inst_key.tenant_id_, 1))) { + } else if (OB_FAIL(inst->node_allocator_.init(OB_MALLOC_BIG_BLOCK_SIZE, attr, 1))) { COMMON_LOG(WARN, "Fail to init node allocator, ", K(ret)); } else if (OB_FAIL(inst_map_.set_refactored(inst_key, inst))) { COMMON_LOG(WARN, "Fail to set inst to inst map, ", K(ret)); @@ -503,7 +505,7 @@ int ObKVCacheInstMap::get_cache_info(const uint64_t tenant_id, ObIArray 50 * 1000) {// limit in 5w active nodes ret = OB_ERR_UNEXPECTED; DETECT_LOG(WARN, "too many detector", K(alived_count), KR(ret)); } else if (nullptr == (p_detector = - (ObIDeadLockDetector *)ob_malloc(sizeof(ObLCLNode), MEMORY_LABEL))) { + (ObIDeadLockDetector *)ob_malloc(sizeof(ObLCLNode), attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; DETECT_LOG(WARN, "DetectorFactory alloc new detector failed", KR(ret)); } else { @@ -166,13 +168,15 @@ int ObDeadLockDetectorMgr::init() ret = OB_ERR_UNEXPECTED; DETECT_LOG(ERROR, "proxy_ or rpc_ is not null", PRINT_WRAPPER); } else { + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); if (nullptr == (proxy_ = - (obrpc::ObDetectorRpcProxy *)ob_malloc(sizeof(obrpc::ObDetectorRpcProxy), MEMORY_LABEL))) { + (obrpc::ObDetectorRpcProxy *)ob_malloc(sizeof(obrpc::ObDetectorRpcProxy), attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; DETECT_LOG(WARN, "alloc proxy_ memory failed", KR(ret)); } else if (nullptr == (rpc_ = (ObDeadLockDetectorRpc *)ob_malloc(sizeof(ObDeadLockDetectorRpc), - MEMORY_LABEL))) { + attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; DETECT_LOG(WARN, "alloc rpc_ memory failed", KR(ret)); } else { @@ -187,7 +191,7 @@ int ObDeadLockDetectorMgr::init() DETECT_LOG(WARN, "req_transport init failed", PRINT_WRAPPER); } else if (OB_FAIL(rpc_->init(proxy_, GCTX.self_addr()))) { DETECT_LOG(WARN, "rpc_ init faile", PRINT_WRAPPER); - } else if (OB_FAIL(detector_map_.init())) { + } else if (OB_FAIL(detector_map_.init(attr))) { DETECT_LOG(WARN, "detector_map_ init failed", PRINT_WRAPPER); } else if (OB_FAIL(sender_thread_.init())) { DETECT_LOG(WARN, "ObLCLBatchSenderThread init failed", PRINT_WRAPPER); @@ -384,6 +388,8 @@ int ObDeadLockDetectorMgr::process_notify_parent_message( ret = common::OB_ENTRY_EXIST; detector_map_.revert(p_detector); } else { + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); ObDeadLockDetectorMgr *p_deadlock_detector_mgr = MTL(ObDeadLockDetectorMgr *); if (OB_ISNULL(p_deadlock_detector_mgr)) { DETECT_LOG(ERROR, "can not get ObDeadLockDetectorMgr", KP(p_deadlock_detector_mgr), K(MTL_ID())); @@ -391,11 +397,11 @@ int ObDeadLockDetectorMgr::process_notify_parent_message( [](const common::ObIArray &, const int64_t) -> int { DETECT_LOG_RET(ERROR, common::OB_ERR_UNEXPECTED, "should not kill inner node"); return common::OB_ERR_UNEXPECTED; }, - [binary_key](ObDetectorUserReportInfo& report_info) -> int { + [binary_key,attr](ObDetectorUserReportInfo& report_info) -> int { ObSharedGuard ptr; ptr.assign((char*)"detector", [](char*){}); report_info.set_module_name(ptr); - char *buffer = (char*)ob_malloc(sizeof(char) * 128, MEMORY_LABEL); + char *buffer = (char*)ob_malloc(sizeof(char) * 128, attr); if (OB_NOT_NULL(buffer)) { binary_key.to_string(buffer, 128); ptr.assign(buffer, [](char* p){ ob_free(p); }); diff --git a/src/share/io/ob_io_manager.cpp b/src/share/io/ob_io_manager.cpp index ec0f94cf2b..6a68db6f28 100644 --- a/src/share/io/ob_io_manager.cpp +++ b/src/share/io/ob_io_manager.cpp @@ -69,6 +69,9 @@ int ObIOManager::init(const int64_t memory_limit, } else if (OB_FAIL(fault_detector_.init())) { LOG_WARN("init io fault detector failed", K(ret)); } else { + ObMemAttr attr(OB_SERVER_TENANT_ID, "IO_MGR"); + SET_USE_500(attr); + allocator_.set_attr(attr); io_config_.set_default_value(); is_inited_ = true; } diff --git a/src/share/io/ob_io_struct.cpp b/src/share/io/ob_io_struct.cpp index 8faedc86aa..f77b359f68 100644 --- a/src/share/io/ob_io_struct.cpp +++ b/src/share/io/ob_io_struct.cpp @@ -2989,13 +2989,14 @@ ObIOTracer::~ObIOTracer() int ObIOTracer::init(const uint64_t tenant_id) { int ret = OB_SUCCESS; + auto attr = SET_USE_500("io_trace_map"); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("init twice", K(ret)); } else if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(tenant_id)); - } else if (OB_FAIL(trace_map_.create(1009, "io_trace_map"))) { + } else if (OB_FAIL(trace_map_.create(1009, attr))) { LOG_WARN("create trace map failed", K(ret)); } else { tenant_id_ = tenant_id; diff --git a/src/share/ob_autoincrement_service.cpp b/src/share/ob_autoincrement_service.cpp index 0dde0527ec..a301d62e91 100644 --- a/src/share/ob_autoincrement_service.cpp +++ b/src/share/ob_autoincrement_service.cpp @@ -263,15 +263,17 @@ int ObAutoincrementService::init(ObAddr &addr, srv_proxy_ = srv_proxy; schema_service_ = schema_service; + ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_AUTOINCREMENT); + SET_USE_500(attr); if (OB_FAIL(distributed_autoinc_service_.init(mysql_proxy))) { LOG_WARN("fail init distributed_autoinc_service_ service", K(ret)); } else if (OB_FAIL(global_autoinc_service_.init(my_addr_, req_transport))) { LOG_WARN("fail init auto inc global service", K(ret)); - } else if (OB_FAIL(node_allocator_.init(sizeof(TableNode), ObModIds::OB_AUTOINCREMENT))) { + } else if (OB_FAIL(node_allocator_.init(sizeof(TableNode), attr))) { LOG_WARN("failed to init table node allocator", K(ret)); - } else if (OB_FAIL(handle_allocator_.init(sizeof(CacheHandle), ObModIds::OB_AUTOINCREMENT))) { + } else if (OB_FAIL(handle_allocator_.init(sizeof(CacheHandle), attr))) { LOG_WARN("failed to init cache handle allocator", K(ret)); - } else if (OB_FAIL(node_map_.init())) { + } else if (OB_FAIL(node_map_.init(attr))) { LOG_WARN("failed to init table node map", K(ret)); } else { for (int64_t i = 0; i < INIT_NODE_MUTEX_NUM; ++i) { diff --git a/src/share/ob_event_history_table_operator.cpp b/src/share/ob_event_history_table_operator.cpp index 947f48d36e..93ddae2d18 100644 --- a/src/share/ob_event_history_table_operator.cpp +++ b/src/share/ob_event_history_table_operator.cpp @@ -194,7 +194,7 @@ int ObEventHistoryTableOperator::init(common::ObMySQLProxy &proxy) OB_FAIL(timer_.init_and_start(thread_count, 5_s, "EventTimer", queue_size_square_of_2))) { LOG_WARN("int global event report timer failed", KR(ret)); } else { - event_queue_.set_label(ObModIds::OB_RS_EVENT_QUEUE); + event_queue_.set_attr(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_RS_EVENT_QUEUE))); proxy_ = &proxy; inited_ = true; stopped_ = false; diff --git a/src/share/ob_occam_thread_pool.h b/src/share/ob_occam_thread_pool.h index 57539c14a3..fca91024c6 100644 --- a/src/share/ob_occam_thread_pool.h +++ b/src/share/ob_occam_thread_pool.h @@ -49,7 +49,7 @@ struct DefaultAllocator : public ObIAllocator { #ifdef UNIITTEST_DEBUG total_alive_num++; #endif - return ob_malloc(size, "OccamThreadPool"); + return ob_malloc(size, SET_USE_500("OccamThreadPool")); } void* alloc(const int64_t size, const ObMemAttr &attr) override { UNUSED(attr); diff --git a/src/share/ob_tablet_autoincrement_service.cpp b/src/share/ob_tablet_autoincrement_service.cpp index 4744fc647c..7c8d5c51fe 100644 --- a/src/share/ob_tablet_autoincrement_service.cpp +++ b/src/share/ob_tablet_autoincrement_service.cpp @@ -274,9 +274,11 @@ ObTabletAutoincrementService &ObTabletAutoincrementService::get_instance() int ObTabletAutoincrementService::init() { int ret = OB_SUCCESS; + lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "AutoincMgr"); + SET_USE_500(attr); if (OB_FAIL(node_allocator_.init(sizeof(ObTabletAutoincMgr), ObModIds::OB_AUTOINCREMENT))) { LOG_WARN("failed to init table node allocator", K(ret)); - } else if (OB_FAIL(tablet_autoinc_mgr_map_.init())) { + } else if (OB_FAIL(tablet_autoinc_mgr_map_.init(attr))) { LOG_WARN("failed to init table node map", K(ret)); } else { for (int64_t i = 0; i < INIT_NODE_MUTEX_NUM; ++i) { diff --git a/src/share/ob_tenant_mgr.cpp b/src/share/ob_tenant_mgr.cpp index d5097f5135..bab4d054a7 100644 --- a/src/share/ob_tenant_mgr.cpp +++ b/src/share/ob_tenant_mgr.cpp @@ -55,20 +55,6 @@ namespace common { using namespace oceanbase::obrpc; -void get_tenant_ids(uint64_t *ids, int cap, int &cnt) -{ - auto *instance = ObMallocAllocator::get_instance(); - cnt = 0; - for (uint64_t tenant_id = 1; tenant_id <= instance->get_max_used_tenant_id() && cnt < cap; ++tenant_id) { - if (nullptr != instance->get_tenant_ctx_allocator(tenant_id, - ObCtxIds::DEFAULT_CTX_ID) || - nullptr != instance->get_tenant_ctx_allocator_unrecycled(tenant_id, - ObCtxIds::DEFAULT_CTX_ID)) { - ids[cnt++] = tenant_id; - } - } -} - ObVirtualTenantManager::ObVirtualTenantManager() : tenant_map_(NULL), tenant_pool_(), diff --git a/src/share/ob_thread_mgr.cpp b/src/share/ob_thread_mgr.cpp index aa242f0bc2..c3778ab4e9 100644 --- a/src/share/ob_thread_mgr.cpp +++ b/src/share/ob_thread_mgr.cpp @@ -34,7 +34,7 @@ void ob_init_create_func() { #define TG_DEF(id, name, desc, scope, type, args...) \ lib::create_funcs_[lib::TGDefIDs::id] = []() { \ - auto ret = OB_NEW(TGCLSMap::CLS, "tg", args); \ + auto ret = OB_NEW(TGCLSMap::CLS, SET_USE_500("tg"), args); \ ret->attr_ = {#name, desc, TGScope::scope, TGType::type}; \ return ret; \ }; diff --git a/src/share/ob_time_zone_info_manager.cpp b/src/share/ob_time_zone_info_manager.cpp index ba46c6b459..853644c8e6 100644 --- a/src/share/ob_time_zone_info_manager.cpp +++ b/src/share/ob_time_zone_info_manager.cpp @@ -64,7 +64,7 @@ const char *ObTimeZoneInfoManager::FETCH_TENANT_TZ_INFO_SQL = ") tz_info WHERE tz_info.tran_row_number = 1 " "ORDER BY tz_info.time_zone_id, tz_info.transition_time "; -const char *ObTimeZoneInfoManager::FETCH_LATEST_TZ_VERSION_SQL = +const char *ObTimeZoneInfoManager::FETCH_LATEST_TZ_VERSION_SQL = "SELECT value from oceanbase.__all_sys_stat where name = 'current_timezone_version'"; int ObTimeZoneInfoManager::init() @@ -253,8 +253,8 @@ int ObTimeZoneInfoManager::set_tz_info_map(ObTimeZoneInfoPos *&stored_tz_info, //do nothing } else { LOG_INFO("need to upgrade transition time", KPC(stored_tz_info), K(new_tz_info)); - common::ObSArray &next_tz_tran_types = stored_tz_info->get_next_tz_tran_types(); - common::ObSArray &next_tz_revt_types = stored_tz_info->get_next_tz_revt_types(); + common::ObSArray &next_tz_tran_types = stored_tz_info->get_next_tz_tran_types(); + common::ObSArray &next_tz_revt_types = stored_tz_info->get_next_tz_revt_types(); if (OB_FAIL(next_tz_tran_types.assign(new_tz_info.get_tz_tran_types()))) { LOG_WARN("fail to assign next_tz_tran_types", K(new_tz_info.get_tz_tran_types()), K(ret)); } else if (OB_FAIL(next_tz_revt_types.assign(new_tz_info.get_tz_revt_types()))) { @@ -445,7 +445,7 @@ int ObTimeZoneInfoManager::fill_tz_info_map(ObRequestTZInfoResult &tz_result) for(int64_t i = 0 ; OB_SUCC(ret) && i < tz_result.tz_array_.count(); ++i) { if (NULL != stored_tz_info) { tz_info_map_.id_map_.revert(stored_tz_info); - stored_tz_info = NULL; + stored_tz_info = NULL; } ObTimeZoneInfoPos &new_tz_info = tz_result.tz_array_.at(i); if (OB_FAIL(tz_info_map_.id_map_.get(new_tz_info.get_tz_id(), stored_tz_info))) { diff --git a/src/share/rc/ob_tenant_base.cpp b/src/share/rc/ob_tenant_base.cpp index ccf56815ef..43860523e7 100644 --- a/src/share/rc/ob_tenant_base.cpp +++ b/src/share/rc/ob_tenant_base.cpp @@ -20,6 +20,14 @@ namespace oceanbase { +namespace lib +{ +int64_t mtl_id() +{ + return MTL_CTX() != nullptr && MTL_ID() != 0 ? MTL_ID() : OB_SERVER_TENANT_ID; +} +} + namespace share { using namespace oceanbase::common; diff --git a/src/share/rpc/ob_batch_rpc.cpp b/src/share/rpc/ob_batch_rpc.cpp index 206f5fbcce..69a707c4bf 100644 --- a/src/share/rpc/ob_batch_rpc.cpp +++ b/src/share/rpc/ob_batch_rpc.cpp @@ -52,7 +52,7 @@ int build_batch_packet(const ObAddr &sender, const uint32_t batch_type, const ui if (req.get_estimate_size() > (limit * 4 / 5) || is_retry) { // 多分配1024字节用于填充其他字段 limit = req.get_req_size() + header_end_pos + 1024; - if (OB_ISNULL(pkt = (ObBatchPacket *)ob_malloc(limit, "RPC_BATCH_BUF"))) { + if (OB_ISNULL(pkt = (ObBatchPacket *)ob_malloc(limit, SET_USE_500("RPC_BATCH_BUF")))) { ret = OB_ALLOCATE_MEMORY_FAILED; } else { is_dynamic_alloc = true; @@ -177,7 +177,7 @@ int build_batch_packet(const ObAddr &sender, const uint32_t batch_type, const in if (req.get_estimate_size() > (limit * 4 / 5) || is_retry) { // 多分配1024字节用于填充其他字段 limit = req.get_req_size() + header_end_pos + 1024; - if (OB_ISNULL(pkt = (ObBatchPacket *)ob_malloc(limit, "RPC_BATCH_BUF"))) { + if (OB_ISNULL(pkt = (ObBatchPacket *)ob_malloc(limit, SET_USE_500("RPC_BATCH_BUF")))) { ret = OB_ALLOCATE_MEMORY_FAILED; } else { is_dynamic_alloc = true; @@ -347,7 +347,7 @@ void ObBatchRpcBase::do_work() ObRpcBuffer* ObBatchRpcBase::create_buffer(const uint64_t tenant_id, const ObAddr& addr, const int64_t dst_cluster_id) { const int64_t alloc_size = get_batch_buffer_size(batch_type_) * BATCH_BUFFER_COUNT; - RpcBuffer* p = (RpcBuffer*)ob_malloc(alloc_size, ObModIds::OB_RPC_BUFFER); + RpcBuffer* p = (RpcBuffer*)ob_malloc(alloc_size, SET_USE_500(ObModIds::OB_RPC_BUFFER)); const int64_t buf_size = (alloc_size - 1024) / BATCH_BUFFER_COUNT; return (NULL == p)? NULL: new(p)RpcBuffer(tenant_id, addr, dst_cluster_id, batch_type_, buf_size, BATCH_BUFFER_COUNT); } diff --git a/src/share/scheduler/ob_dag_scheduler.cpp b/src/share/scheduler/ob_dag_scheduler.cpp index 997a77cd7a..c1cc8ed303 100644 --- a/src/share/scheduler/ob_dag_scheduler.cpp +++ b/src/share/scheduler/ob_dag_scheduler.cpp @@ -3017,7 +3017,7 @@ int ObTenantDagScheduler::create_worker() { int ret = OB_SUCCESS; // TODO add upper worker cnt limit, each tenant should have a max_worker_cnt - ObTenantDagWorker *worker = OB_NEW(ObTenantDagWorker, ObModIds::OB_SCHEDULER); + ObTenantDagWorker *worker = OB_NEW(ObTenantDagWorker, SET_USE_500(ObModIds::OB_SCHEDULER)); if (OB_ISNULL(worker)) { ret = OB_ALLOCATE_MEMORY_FAILED; COMMON_LOG(WARN, "failed to allocate ObTenantDagWorker", K(ret)); diff --git a/src/share/scheduler/ob_dag_warning_history_mgr.h b/src/share/scheduler/ob_dag_warning_history_mgr.h index 114afa8f3a..f6ccefb37a 100644 --- a/src/share/scheduler/ob_dag_warning_history_mgr.h +++ b/src/share/scheduler/ob_dag_warning_history_mgr.h @@ -226,7 +226,9 @@ int ObNodeArray::init(const char *label, const int64_t max_cnt) COMMON_LOG(WARN, "failed to init bitset", K(ret), K(max_cnt)); } else { void * buf = NULL; - allocator_.set_label(label); + auto attr = SET_USE_500(label); + allocator_.set_attr(attr); + free_node_bitset_.set_attr(attr); if (NULL == (buf = allocator_.alloc(sizeof(T) * max_cnt))) { ret = OB_ALLOCATE_MEMORY_FAILED; COMMON_LOG(WARN, "failed to alloc info node", K(ret)); @@ -317,7 +319,8 @@ int ObInfoManager:: init( const int64_t max_cnt) { int ret = OB_SUCCESS; - if (OB_FAIL(map_.create(bucket_num, label))) { + auto attr = SET_USE_500(label); + if (OB_FAIL(map_.create(bucket_num, attr))) { COMMON_LOG(WARN, "failed to create map", K(ret), K(bucket_num), K(label)); } else if (OB_FAIL(node_array_.init(label, max_cnt))) { COMMON_LOG(WARN, "failed to init node array", K(ret), K(max_cnt), K(label)); diff --git a/src/share/schema/ob_context_mgr.cpp b/src/share/schema/ob_context_mgr.cpp index 9143c301e8..15bb1a253d 100644 --- a/src/share/schema/ob_context_mgr.cpp +++ b/src/share/schema/ob_context_mgr.cpp @@ -83,19 +83,19 @@ ObContextHashWrapper ObGetContextKey ObContextMgr::ObContextMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - context_infos_(0, NULL, "SchemaContext"), - context_map_("SchemaContext") + context_infos_(0, NULL, SET_USE_500("SchemaContext")), + context_map_(SET_USE_500("SchemaContext")) { } ObContextMgr::ObContextMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - context_infos_(0, NULL, "SchemaContext"), - context_map_("SchemaContext") + context_infos_(0, NULL, SET_USE_500("SchemaContext")), + context_map_(SET_USE_500("SchemaContext")) { } @@ -322,7 +322,7 @@ int ObContextMgr::del_context(const ObContextKey &context) K(context_infos_.count()), K(context_map_.item_count())); int tmp_ret = OB_SUCCESS; - if (OB_SUCCESS != (tmp_ret + if (OB_SUCCESS != (tmp_ret = ObContextMgr::rebuild_context_hashmap(context_infos_, context_map_))) { LOG_WARN("rebuild context hashmap failed", K(tmp_ret)); } diff --git a/src/share/schema/ob_dblink_mgr.cpp b/src/share/schema/ob_dblink_mgr.cpp index add5fdba72..f9ff00bb00 100644 --- a/src/share/schema/ob_dblink_mgr.cpp +++ b/src/share/schema/ob_dblink_mgr.cpp @@ -28,20 +28,20 @@ using namespace common; using namespace common::hash; ObDbLinkMgr::ObDbLinkMgr() - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - dblink_schemas_(0, NULL, "DBLINK_MGR"), - dblink_id_map_("DBLINK_MGR"), - dblink_name_map_("DBLINK_MGR"), + dblink_schemas_(0, NULL, SET_USE_500("DBLINK_MGR")), + dblink_id_map_(SET_USE_500("DBLINK_MGR")), + dblink_name_map_(SET_USE_500("DBLINK_MGR")), is_inited_(false) {} ObDbLinkMgr::ObDbLinkMgr(ObIAllocator &allocator) - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - dblink_schemas_(0, NULL, "DBLINK_MGR"), - dblink_id_map_("DBLINK_MGR"), - dblink_name_map_("DBLINK_MGR"), + dblink_schemas_(0, NULL, SET_USE_500("DBLINK_MGR")), + dblink_id_map_(SET_USE_500("DBLINK_MGR")), + dblink_name_map_(SET_USE_500("DBLINK_MGR")), is_inited_(false) {} diff --git a/src/share/schema/ob_directory_mgr.cpp b/src/share/schema/ob_directory_mgr.cpp index ef7cfcd57a..d0b1fedf10 100644 --- a/src/share/schema/ob_directory_mgr.cpp +++ b/src/share/schema/ob_directory_mgr.cpp @@ -28,21 +28,21 @@ const char *ObDirectoryMgr::DIRECTORY_MGR = "DIRECTORY_MGR"; ObDirectoryMgr::ObDirectoryMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - directory_infos_(0, NULL, DIRECTORY_MGR), - directory_name_map_(DIRECTORY_MGR), - directory_id_map_(DIRECTORY_MGR) + directory_infos_(0, NULL, SET_USE_500(DIRECTORY_MGR)), + directory_name_map_(SET_USE_500(DIRECTORY_MGR)), + directory_id_map_(SET_USE_500(DIRECTORY_MGR)) { } ObDirectoryMgr::ObDirectoryMgr(common::ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - directory_infos_(0, NULL, DIRECTORY_MGR), - directory_name_map_(DIRECTORY_MGR), - directory_id_map_(DIRECTORY_MGR) + directory_infos_(0, NULL, SET_USE_500(DIRECTORY_MGR)), + directory_name_map_(SET_USE_500(DIRECTORY_MGR)), + directory_id_map_(SET_USE_500(DIRECTORY_MGR)) { } diff --git a/src/share/schema/ob_keystore_mgr.cpp b/src/share/schema/ob_keystore_mgr.cpp index 297eb455c7..c52ddd9759 100644 --- a/src/share/schema/ob_keystore_mgr.cpp +++ b/src/share/schema/ob_keystore_mgr.cpp @@ -28,18 +28,18 @@ using namespace common::hash; ObKeystoreMgr::ObKeystoreMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - keystore_infos_(0, NULL, ObModIds::OB_SCHEMA_KEYSTORE), - keystore_map_(ObModIds::OB_SCHEMA_KEYSTORE) + keystore_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_KEYSTORE)), + keystore_map_(SET_USE_500(ObModIds::OB_SCHEMA_KEYSTORE)) { } ObKeystoreMgr::ObKeystoreMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - keystore_infos_(0, NULL, ObModIds::OB_SCHEMA_KEYSTORE), - keystore_map_(ObModIds::OB_SCHEMA_KEYSTORE) + keystore_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_KEYSTORE)), + keystore_map_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_SCHEMA_KEYSTORE))) { } ObKeystoreMgr::~ObKeystoreMgr() @@ -366,4 +366,3 @@ int ObKeystoreMgr::get_schema_statistics(ObSchemaStatisticsInfo &schema_info) co } //end of namespace schema } //end of namespace share } //end of namespace oceanbase - diff --git a/src/share/schema/ob_label_se_policy_mgr.cpp b/src/share/schema/ob_label_se_policy_mgr.cpp index 5c73d37dc4..3c82468d02 100644 --- a/src/share/schema/ob_label_se_policy_mgr.cpp +++ b/src/share/schema/ob_label_se_policy_mgr.cpp @@ -29,24 +29,24 @@ using namespace hash; ObLabelSePolicyMgr::ObLabelSePolicyMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - policy_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - column_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)), + policy_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)), + column_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)) { } ObLabelSePolicyMgr::ObLabelSePolicyMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - policy_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - column_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_POLICY) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)), + policy_name_map_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_SCHEMA_LABEL_SE_POLICY))), + column_name_map_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_SCHEMA_LABEL_SE_POLICY))), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_POLICY)) { } @@ -466,26 +466,26 @@ int ObLabelSePolicyMgr::get_schema_statistics(ObSchemaStatisticsInfo &schema_inf ObLabelSeCompMgr::ObLabelSeCompMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - short_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - long_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - num_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + short_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + long_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + num_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)) { } ObLabelSeCompMgr::ObLabelSeCompMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - short_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - long_name_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT), - num_map_(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + short_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + long_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)), + num_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_COMPONENT)) { } @@ -1049,24 +1049,24 @@ int ObLabelSeCompMgr::get_schema_statistics(ObSchemaStatisticsInfo &schema_info) ObLabelSeLabelMgr::ObLabelSeLabelMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - label_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - tag_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + label_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + tag_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)) { } ObLabelSeLabelMgr::ObLabelSeLabelMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - label_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL), - tag_map_(ObModIds::OB_SCHEMA_LABEL_SE_LABEL) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + label_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)), + tag_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_LABEL)) { } @@ -1559,22 +1559,22 @@ int ObLabelSeLabelMgr::get_schema_statistics(ObSchemaStatisticsInfo &schema_info ObLabelSeUserLevelMgr::ObLabelSeUserLevelMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL), - user_level_map_(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)), + user_level_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)) { } ObLabelSeUserLevelMgr::ObLabelSeUserLevelMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - schema_infos_(0, NULL, ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL), - user_level_map_(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL), - id_map_(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL) + schema_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)), + user_level_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)), + id_map_(SET_USE_500(ObModIds::OB_SCHEMA_LABEL_SE_USER_LEVEL)) { } diff --git a/src/share/schema/ob_mock_fk_parent_table_mgr.cpp b/src/share/schema/ob_mock_fk_parent_table_mgr.cpp index f49178b000..ec79dfbfab 100644 --- a/src/share/schema/ob_mock_fk_parent_table_mgr.cpp +++ b/src/share/schema/ob_mock_fk_parent_table_mgr.cpp @@ -87,19 +87,19 @@ ObMockFKParentTableHashWrapper ObGetMockFKParentTableKey< ObMockFKParentTableMgr::ObMockFKParentTableMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - mock_fk_parent_table_infos_(0, NULL, "MockFkParentTab"), - mock_fk_parent_table_map_("MockFkParentTab") + mock_fk_parent_table_infos_(0, NULL, SET_USE_500("MockFkParentTab")), + mock_fk_parent_table_map_(SET_USE_500("MockFkParentTab")) { } ObMockFKParentTableMgr::ObMockFKParentTableMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - mock_fk_parent_table_infos_(0, NULL, "MockFkParentTab"), - mock_fk_parent_table_map_("MockFkParentTab") + mock_fk_parent_table_infos_(0, NULL, SET_USE_500("MockFkParentTab")), + mock_fk_parent_table_map_(SET_USE_500("MockFkParentTab")) { } diff --git a/src/share/schema/ob_multi_version_schema_service.cpp b/src/share/schema/ob_multi_version_schema_service.cpp index 429e86378c..48923273ff 100644 --- a/src/share/schema/ob_multi_version_schema_service.cpp +++ b/src/share/schema/ob_multi_version_schema_service.cpp @@ -79,6 +79,7 @@ const char *ObMultiVersionSchemaService::print_refresh_schema_mode(const Refresh ObSchemaConstructTask::ObSchemaConstructTask() { + schema_tasks_.set_attr(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, "SchemaTasks"))); (void)pthread_mutex_init(&schema_mutex_, NULL); (void)pthread_cond_init(&schema_cond_, NULL); } @@ -3679,8 +3680,8 @@ int ObMultiVersionSchemaService::get_new_schema_version(uint64_t tenant_id, int6 } int ObMultiVersionSchemaService::get_tenant_mem_info( - const uint64_t &tenant_id, - common::ObIArray &tenant_mem_infos) + const uint64_t &tenant_id, + common::ObIArray &tenant_mem_infos) { int ret = OB_SUCCESS; ObSchemaMemMgr *mem_mgr = NULL; @@ -3697,19 +3698,19 @@ int ObMultiVersionSchemaService::get_tenant_mem_info( ret = OB_ERR_UNEXPECTED; LOG_WARN("mem_mgr is NULL", KR(ret), K(tenant_id)); } else if (OB_FAIL(mem_mgr->get_all_alloc_info(tenant_mem_infos))) { - LOG_WARN("fail to get mem_mgr alloc info", KR(ret), K(tenant_id)); + LOG_WARN("fail to get mem_mgr alloc info", KR(ret), K(tenant_id)); } return ret; } int ObMultiVersionSchemaService::get_tenant_slot_info( - common::ObIAllocator &allocator, - const uint64_t &tenant_id, + common::ObIAllocator &allocator, + const uint64_t &tenant_id, common::ObIArray &tenant_slot_infos) { int ret = OB_SUCCESS; ObSchemaStore * schema_store = NULL; - + if (OB_INVALID_TENANT_ID == tenant_id) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid tenant_id", KR(ret), K(tenant_id)); @@ -3735,7 +3736,7 @@ int ObMultiVersionSchemaService::get_schema_store_tenants(common::ObIArrayget_pool()) @@ -185,7 +186,7 @@ int ObServerSchemaService::init(ObMySQLProxy *sql_proxy, } else if (FALSE_IT(schema_service_->set_common_config(config))) { // will not reach here } else if (OB_FAIL(version_his_map_.create(VERSION_HIS_MAP_BUCKET_NUM, - ObModIds::OB_SCHEMA_ID_VERSIONS, ObModIds::OB_SCHEMA_ID_VERSIONS))) { + attr))) { LOG_WARN("create version his map failed", KR(ret)); } else { sql_proxy_ = sql_proxy; diff --git a/src/share/schema/ob_synonym_mgr.cpp b/src/share/schema/ob_synonym_mgr.cpp index 200013c117..de6854675f 100644 --- a/src/share/schema/ob_synonym_mgr.cpp +++ b/src/share/schema/ob_synonym_mgr.cpp @@ -118,21 +118,21 @@ int64_t ObSimpleSynonymSchema::get_convert_size() const ObSynonymMgr::ObSynonymMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - synonym_infos_(0, NULL, ObModIds::OB_SCHEMA_SYNONYM), - synonym_id_map_(ObModIds::OB_SCHEMA_SYNONYM), - synonym_name_map_(ObModIds::OB_SCHEMA_SYNONYM) + synonym_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)), + synonym_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)), + synonym_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)) { } ObSynonymMgr::ObSynonymMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - synonym_infos_(0, NULL, ObModIds::OB_SCHEMA_SYNONYM), - synonym_id_map_(ObModIds::OB_SCHEMA_SYNONYM), - synonym_name_map_(ObModIds::OB_SCHEMA_SYNONYM) + synonym_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)), + synonym_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)), + synonym_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_SYNONYM)) { } diff --git a/src/share/schema/ob_sys_variable_mgr.cpp b/src/share/schema/ob_sys_variable_mgr.cpp index 62e7d48196..7de9b4c2b4 100644 --- a/src/share/schema/ob_sys_variable_mgr.cpp +++ b/src/share/schema/ob_sys_variable_mgr.cpp @@ -94,19 +94,19 @@ ObSimpleSysVariableSchema &ObSimpleSysVariableSchema::operator =(const ObSimpleS ObSysVariableMgr::ObSysVariableMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - sys_variable_infos_(0, NULL, ObModIds::OB_SCHEMA_SYS_VARIABLE), - sys_variable_map_(ObModIds::OB_SCHEMA_SYS_VARIABLE) + sys_variable_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_SYS_VARIABLE)), + sys_variable_map_(SET_USE_500(ObModIds::OB_SCHEMA_SYS_VARIABLE)) { } ObSysVariableMgr::ObSysVariableMgr(common::ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - sys_variable_infos_(0, NULL, ObModIds::OB_SCHEMA_SYS_VARIABLE), - sys_variable_map_(ObModIds::OB_SCHEMA_SYS_VARIABLE) + sys_variable_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_SYS_VARIABLE)), + sys_variable_map_(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_SCHEMA_SYS_VARIABLE))) { } diff --git a/src/share/schema/ob_tablespace_mgr.cpp b/src/share/schema/ob_tablespace_mgr.cpp index bbf6fd9238..9f77a8f76d 100644 --- a/src/share/schema/ob_tablespace_mgr.cpp +++ b/src/share/schema/ob_tablespace_mgr.cpp @@ -222,19 +222,19 @@ struct Deep_Copy_EarlyStopCondition /////////////////////////////////////////////////////////////////// ObTablespaceMgr::ObTablespaceMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - tablespace_infos_(0, NULL, ObModIds::OB_SCHEMA_TABLESPACE), - tablespace_map_(ObModIds::OB_SCHEMA_TABLESPACE) + tablespace_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_TABLESPACE)), + tablespace_map_(SET_USE_500(ObModIds::OB_SCHEMA_TABLESPACE)) { } ObTablespaceMgr::ObTablespaceMgr(ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - tablespace_infos_(0, NULL, ObModIds::OB_SCHEMA_TABLESPACE), - tablespace_map_(ObModIds::OB_SCHEMA_TABLESPACE) + tablespace_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_TABLESPACE)), + tablespace_map_(SET_USE_500(ObModIds::OB_SCHEMA_TABLESPACE)) { } diff --git a/src/share/schema/ob_trigger_mgr.cpp b/src/share/schema/ob_trigger_mgr.cpp index 0925b57299..21172a7702 100644 --- a/src/share/schema/ob_trigger_mgr.cpp +++ b/src/share/schema/ob_trigger_mgr.cpp @@ -87,21 +87,21 @@ uint64_t ObSimpleTriggerSchema::get_exec_tenant_id() const } ObTriggerMgr::ObTriggerMgr() - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - trigger_infos_(0, NULL, ObModIds::OB_SCHEMA_TRIGGER_INFO_VECTOR), - trigger_id_map_(ObModIds::OB_SCHEMA_TRIGGER_ID_MAP), - trigger_name_map_(ObModIds::OB_SCHEMA_TRIGGER_NAME_MAP), + trigger_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_INFO_VECTOR)), + trigger_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_ID_MAP)), + trigger_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_NAME_MAP)), is_inited_(false) { } ObTriggerMgr::ObTriggerMgr(ObIAllocator &allocator) - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - trigger_infos_(0, NULL, ObModIds::OB_SCHEMA_TRIGGER_INFO_VECTOR), - trigger_id_map_(ObModIds::OB_SCHEMA_TRIGGER_ID_MAP), - trigger_name_map_(ObModIds::OB_SCHEMA_TRIGGER_NAME_MAP), + trigger_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_INFO_VECTOR)), + trigger_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_ID_MAP)), + trigger_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_TRIGGER_NAME_MAP)), is_inited_(false) { } diff --git a/src/share/schema/ob_udf_mgr.cpp b/src/share/schema/ob_udf_mgr.cpp index 1bf74638a0..c1c9bec3c8 100644 --- a/src/share/schema/ob_udf_mgr.cpp +++ b/src/share/schema/ob_udf_mgr.cpp @@ -116,19 +116,19 @@ ObSimpleUDFSchema &ObSimpleUDFSchema::operator =(const ObSimpleUDFSchema &other) ObUDFMgr::ObUDFMgr() : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - udf_infos_(0, NULL, ObModIds::OB_SCHEMA_UDF), - udf_map_(ObModIds::OB_SCHEMA_UDF) + udf_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_UDF)), + udf_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDF)) { } ObUDFMgr::ObUDFMgr(common::ObIAllocator &allocator) : is_inited_(false), - local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - udf_infos_(0, NULL, ObModIds::OB_SCHEMA_UDF), - udf_map_(ObModIds::OB_SCHEMA_UDF) + udf_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_UDF)), + udf_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDF)) { } diff --git a/src/share/schema/ob_udt_mgr.cpp b/src/share/schema/ob_udt_mgr.cpp index 0b28e6a4e1..bbacd7e619 100644 --- a/src/share/schema/ob_udt_mgr.cpp +++ b/src/share/schema/ob_udt_mgr.cpp @@ -97,21 +97,21 @@ int64_t ObSimpleUDTSchema::get_convert_size() const } ObUDTMgr::ObUDTMgr() - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(local_allocator_), - udt_infos_(0, NULL, ObModIds::OB_SCHEMA_UDT_INFO_VECTOR), - type_id_map_(ObModIds::OB_SCHEMA_UDT_ID_MAP), - type_name_map_(ObModIds::OB_SCHEMA_UDT_NAME_MAP), + udt_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_UDT_INFO_VECTOR)), + type_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDT_ID_MAP)), + type_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDT_NAME_MAP)), is_inited_(false) { } ObUDTMgr::ObUDTMgr(ObIAllocator &allocator) - : local_allocator_(ObModIds::OB_SCHEMA_GETTER_GUARD), + : local_allocator_(SET_USE_500(ObModIds::OB_SCHEMA_GETTER_GUARD)), allocator_(allocator), - udt_infos_(0, NULL, ObModIds::OB_SCHEMA_UDT_INFO_VECTOR), - type_id_map_(ObModIds::OB_SCHEMA_UDT_ID_MAP), - type_name_map_(ObModIds::OB_SCHEMA_UDT_NAME_MAP), + udt_infos_(0, NULL, SET_USE_500(ObModIds::OB_SCHEMA_UDT_INFO_VECTOR)), + type_id_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDT_ID_MAP)), + type_name_map_(SET_USE_500(ObModIds::OB_SCHEMA_UDT_NAME_MAP)), is_inited_(false) { } diff --git a/src/share/stat/ob_opt_stat_monitor_manager.cpp b/src/share/stat/ob_opt_stat_monitor_manager.cpp index 40a88d7ebb..bfa7abe542 100644 --- a/src/share/stat/ob_opt_stat_monitor_manager.cpp +++ b/src/share/stat/ob_opt_stat_monitor_manager.cpp @@ -119,15 +119,17 @@ void ObOptStatMonitorCheckTask::runTimerTask() int ObOptStatMonitorManager::init(ObMySQLProxy *mysql_proxy) { int ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, "DmlStatsHashMap"); + SET_USE_500(attr); if (inited_) { ret = OB_INIT_TWICE; LOG_WARN("column usage manager has already been initialized.", K(ret)); } else if (OB_ISNULL(mysql_proxy)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get null mysql proxy", K(ret)); - } else if (OB_FAIL(column_usage_maps_.create(100, "ColUsagHashMap"))) { + } else if (OB_FAIL(column_usage_maps_.create(100, SET_USE_500("ColUsagHashMap")))) { LOG_WARN("failed to create column usage maps", K(ret)); - } else if (OB_FAIL(dml_stat_maps_.create(100, "DmlStatsHashMap"))) { + } else if (OB_FAIL(dml_stat_maps_.create(100, attr))) { LOG_WARN("failed to create dml stats maps", K(ret)); } else if (OB_FAIL(flush_all_task_.init(lib::TGDefIDs::ServerGTimer))) { LOG_WARN("failed to init column usage task", K(ret)); @@ -265,18 +267,20 @@ int ObOptStatMonitorManager::update_local_cache(uint64_t tenant_id, { int ret = OB_SUCCESS; ReadMapAtomicOp atomic_op(&args); + ObMemAttr attr(OB_SERVER_TENANT_ID, "ColUsagHashMap"); + SET_USE_500(attr); if (GCTX.is_standby_cluster()) { // standby cluster can't write __all_column_usage, so do not need to update local update } else if (OB_FAIL(column_usage_maps_.read_atomic(tenant_id, atomic_op))) { if (OB_HASH_NOT_EXIST == ret) {//not exists such tenant id map, need alloc new map ColumnUsageMap *col_map = NULL; ColumnUsageMap *tmp_col_map = NULL; - void *buff = ob_malloc(sizeof(ColumnUsageMap), "ColUsagHashMap"); + void *buff = ob_malloc(sizeof(ColumnUsageMap), attr); if (OB_ISNULL(buff)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); } else if (OB_FALSE_IT(col_map = new(buff)ColumnUsageMap())) { - } else if (OB_FAIL(col_map->create(10000, "ColUsagHashMap", "ColUsagHashMap", OB_SERVER_TENANT_ID))) { + } else if (OB_FAIL(col_map->create(10000, attr))) { LOG_WARN("failed to create column usage map", K(ret)); } else if (OB_FAIL(column_usage_maps_.set_refactored(tenant_id, col_map))) { // set refacter failed, may created by other thread @@ -309,6 +313,8 @@ int ObOptStatMonitorManager::update_local_cache(uint64_t tenant_id, ObOptDmlStat { int ret = OB_SUCCESS; ReadMapAtomicOp atomic_op(dml_stat); + ObMemAttr attr(OB_SERVER_TENANT_ID, "DmlStatsHashMap"); + SET_USE_500(attr); if (GCTX.is_standby_cluster()) { // standby cluster can't write __all_monitor_modified, so do not need to update local update } else if (OB_FAIL(dml_stat_maps_.read_atomic(tenant_id, atomic_op))) { @@ -316,12 +322,12 @@ int ObOptStatMonitorManager::update_local_cache(uint64_t tenant_id, ObOptDmlStat ret = OB_SUCCESS; DmlStatMap *dml_stat_map = NULL; DmlStatMap *tmp_dml_stat_map = NULL; - void *buff = ob_malloc(sizeof(DmlStatMap), "DmlStatsHashMap"); + void *buff = ob_malloc(sizeof(DmlStatMap), attr); if (OB_ISNULL(buff)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); } else if (OB_FALSE_IT(dml_stat_map = new(buff)DmlStatMap())) { - } else if (OB_FAIL(dml_stat_map->create(10000, "DmlStatsHashMap", "DmlStatsHashMap", OB_SERVER_TENANT_ID))) { + } else if (OB_FAIL(dml_stat_map->create(10000, attr))) { LOG_WARN("failed to create column usage map", K(ret)); } else if (OB_FAIL(dml_stat_maps_.set_refactored(tenant_id, dml_stat_map))) { // set refacter failed, may created by other thread @@ -734,6 +740,8 @@ int ObOptStatMonitorManager::SwapMapAtomicOp::operator() (common::hash::HashMapP { int ret = OB_SUCCESS; column_usage_map_ = NULL; + ObMemAttr attr(OB_SERVER_TENANT_ID, "DmlStatsHashMap"); + SET_USE_500(attr); if (OB_ISNULL(entry.second)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); @@ -741,14 +749,14 @@ int ObOptStatMonitorManager::SwapMapAtomicOp::operator() (common::hash::HashMapP // do nothing } else { ColumnUsageMap *col_map = NULL; - void *buff = ob_malloc(sizeof(ColumnUsageMap), "ColUsagHashMap"); + void *buff = ob_malloc(sizeof(ColumnUsageMap), attr); if (OB_ISNULL(buff)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); } else if (NULL == (col_map = new(buff)ColumnUsageMap())) { ret = OB_NOT_INIT; LOG_WARN("fail to constructor column usage map", K(ret)); - } else if (OB_FAIL(col_map->create(10000, "ColUsagHashMap", "ColUsagHashMap", OB_SERVER_TENANT_ID))) { + } else if (OB_FAIL(col_map->create(10000, attr))) { LOG_WARN("failed to create column usage map", K(ret)); } else { column_usage_map_ = entry.second; @@ -770,6 +778,8 @@ int ObOptStatMonitorManager::SwapMapAtomicOp::operator() (common::hash::HashMapP { int ret = OB_SUCCESS; dml_stat_map_ = NULL; + ObMemAttr attr(OB_SERVER_TENANT_ID, "DmlStatMap"); + SET_USE_500(attr); if (OB_ISNULL(entry.second)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret)); @@ -777,14 +787,14 @@ int ObOptStatMonitorManager::SwapMapAtomicOp::operator() (common::hash::HashMapP // do nothing } else { DmlStatMap *dml_stat_map = NULL; - void *buff = ob_malloc(sizeof(DmlStatMap), "DmlStatMap"); + void *buff = ob_malloc(sizeof(DmlStatMap), attr); if (OB_ISNULL(buff)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("alloc memory failed", K(ret)); } else if (NULL == (dml_stat_map = new(buff)DmlStatMap())) { ret = OB_NOT_INIT; LOG_WARN("fail to constructor DmlStatMap", K(ret)); - } else if (OB_FAIL(dml_stat_map->create(10000, "DmlStatMap", "DmlStatMap", OB_SERVER_TENANT_ID))) { + } else if (OB_FAIL(dml_stat_map->create(10000, attr))) { LOG_WARN("failed to create column usage map", K(ret)); } else { dml_stat_map_ = entry.second; diff --git a/src/sql/dtl/ob_dtl_interm_result_manager.cpp b/src/sql/dtl/ob_dtl_interm_result_manager.cpp index 483d712e36..047d6361ee 100644 --- a/src/sql/dtl/ob_dtl_interm_result_manager.cpp +++ b/src/sql/dtl/ob_dtl_interm_result_manager.cpp @@ -187,11 +187,11 @@ ObDTLIntermResultManager &ObDTLIntermResultManager::getInstance() int ObDTLIntermResultManager::init() { int ret = OB_SUCCESS; + auto attr = SET_USE_500("HashBuckDTLINT"); if (IS_INIT) { ret = OB_INIT_TWICE; } else if (OB_FAIL(map_.create(BUCKET_NUM, - "HashBuckDTLINT", - "HashNodeDTLINT"))) { + attr, attr))) { LOG_WARN("create hash table failed", K(ret)); } else if (OB_FAIL(TG_SCHEDULE(lib::TGDefIDs::ServerGTimer, gc_, ObDTLIntermResultGC::REFRESH_INTERVAL, true))) { diff --git a/src/sql/engine/cmd/ob_load_data_utils.cpp b/src/sql/engine/cmd/ob_load_data_utils.cpp index 8150c580b6..cd0cfb2ef4 100644 --- a/src/sql/engine/cmd/ob_load_data_utils.cpp +++ b/src/sql/engine/cmd/ob_load_data_utils.cpp @@ -447,11 +447,13 @@ int ObGetAllJobStatusOp::get_next_job_status(ObLoadDataStat *&job_status) int ObGlobalLoadDataStatMap::init() { int ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, ObModIds::OB_SQL_LOAD_DATA); + SET_USE_500(attr); if (IS_INIT) { ret = OB_INIT_TWICE; } else if (OB_FAIL(map_.create(bucket_num, - ObModIds::OB_SQL_LOAD_DATA, - ObModIds::OB_SQL_LOAD_DATA))) { + attr, + attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("create hash table failed", K(ret)); } else { @@ -526,5 +528,3 @@ OB_SERIALIZE_MEMBER(ObLoadDataGID, id); } } - - diff --git a/src/sql/engine/px/ob_px_target_mgr.cpp b/src/sql/engine/px/ob_px_target_mgr.cpp index afaa5b39b9..a52d29e864 100644 --- a/src/sql/engine/px/ob_px_target_mgr.cpp +++ b/src/sql/engine/px/ob_px_target_mgr.cpp @@ -28,19 +28,20 @@ ObPxTargetMgr &ObPxTargetMgr::get_instance() return px_res_mgr; } -int ObPxTargetMgr::init(const common::ObAddr &server, +int ObPxTargetMgr::init(const common::ObAddr &server, ObIAliveServerTracer &server_tracer) { int ret = OB_SUCCESS; + auto attr = SET_USE_500("PxResMgr"); if (is_inited_) { ret = OB_INIT_TWICE; LOG_WARN("ObPxTargetMgr inited twice", K(ret)); } else if (!server.is_valid()) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), K(server)); - } else if (px_info_map_.init("PxResMgr")) { + } else if (OB_FAIL(px_info_map_.init(attr))) { LOG_WARN("px_info_map_ init failed", K(ret)); - } else if (alive_server_set_.create(PX_MAX_ALIVE_SERVER_NUM)) { + } else if (OB_FAIL(alive_server_set_.create(PX_MAX_ALIVE_SERVER_NUM, attr))) { LOG_WARN("create alive_server_set_ failed", K(ret)); } else { server_ = server; @@ -128,7 +129,7 @@ void ObPxTargetMgr::run1() lib::set_thread_name("PxTargetMgr", get_thread_idx()); while (!has_set_stop()) { - // sleep 100 * 1000 us + // sleep 100 * 1000 us ob_usleep(PX_REFRESH_TARGET_INTERVEL_US); refresh_times++; @@ -137,7 +138,7 @@ void ObPxTargetMgr::run1() // check alive is a very slow and not necessary oper if (refresh_times % 100 == 0) { - for (hash::ObHashSet::const_iterator it = alive_server_set_.begin(); + for (hash::ObHashSet::const_iterator it = alive_server_set_.begin(); OB_SUCC(ret) && it != alive_server_set_.end(); it++) { bool alive = true; int64_t trace_time; @@ -177,7 +178,7 @@ int ObPxTargetMgr::add_tenant(const uint64_t tenant_id) if (OB_ISNULL(ptr = ob_malloc(sizeof(ObPxResInfo), memattr))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate memory failed", K(ret), K(tenant_id)); - } else { + } else { if (OB_ISNULL(px_res_info = new (ptr) ObPxResInfo())) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("px resouce info construct failed", K(ret), KP(ptr)); @@ -222,7 +223,7 @@ int ObPxTargetMgr::delete_tenant(const uint64_t tenant_id) }*/ } } - + if (OB_SUCCESS == ret) { LOG_INFO("delete tenant success", K(tenant_id)); } else { @@ -377,7 +378,7 @@ int ObPxTargetMgr::get_all_tenant(common::ObSEArray &tenant_array) int ret = OB_SUCCESS; tenant_array.reset(); ObPxInfoMap::Iterator iter(px_info_map_); - for (ObPxResInfo *value = NULL; + for (ObPxResInfo *value = NULL; OB_SUCC(ret) && OB_NOT_NULL(value = iter.next(value)); iter.revert(value)) { ObPxTenantInfo tenant_info = value->hash_node_->hash_link_.key_; if (OB_FAIL(tenant_array.push_back(tenant_info.get_value()))) { diff --git a/src/sql/executor/ob_maintain_dependency_info_task.cpp b/src/sql/executor/ob_maintain_dependency_info_task.cpp index 1946190bbd..bd39981910 100644 --- a/src/sql/executor/ob_maintain_dependency_info_task.cpp +++ b/src/sql/executor/ob_maintain_dependency_info_task.cpp @@ -194,9 +194,10 @@ int ObMaintainObjDepInfoTask::assign_view_schema(const ObTableSchema &view_schem int ObMaintainDepInfoTaskQueue::init(const int64_t thread_cnt, const int64_t queue_size) { int ret = OB_SUCCESS; + auto attr = SET_USE_500("DepInfoTaskQ"); if (OB_FAIL(ObAsyncTaskQueue::init(thread_cnt, queue_size, "MaintainDepInfoTaskQueue"))) { LOG_WARN("failed to init base queue", K(ret)); - } else if (OB_FAIL(view_info_set_.create(INIT_BKT_SIZE))) { + } else if (OB_FAIL(view_info_set_.create(INIT_BKT_SIZE, attr, attr))) { LOG_WARN("failed to init view set", K(ret)); } return ret; diff --git a/src/sql/session/ob_sql_session_mgr.h b/src/sql/session/ob_sql_session_mgr.h index 3cad895b4d..5589f3687d 100644 --- a/src/sql/session/ob_sql_session_mgr.h +++ b/src/sql/session/ob_sql_session_mgr.h @@ -193,7 +193,8 @@ private: { public: ValueAlloc() - : session_pool_map_(allocator_), + : allocator_(SET_USE_500("SessMap")), + session_pool_map_(allocator_), alloc_total_count_(0), alloc_from_pool_count_(0), free_total_count_(0), diff --git a/src/sql/session/ob_user_resource_mgr.cpp b/src/sql/session/ob_user_resource_mgr.cpp index 59b2162779..f79e6c0a60 100644 --- a/src/sql/session/ob_user_resource_mgr.cpp +++ b/src/sql/session/ob_user_resource_mgr.cpp @@ -31,7 +31,9 @@ static const char *MEMORY_LABEL = "UserResourceMgr"; ObConnectResource* ObConnectResAlloc::alloc_value() { - return OB_NEW(ObConnectResource, MEMORY_LABEL); + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); + return OB_NEW(ObConnectResource, attr); } void ObConnectResAlloc::free_value(ObConnectResource* tz_info) @@ -43,7 +45,9 @@ void ObConnectResAlloc::free_value(ObConnectResource* tz_info) ObConnectResHashNode* ObConnectResAlloc::alloc_node(ObConnectResource* value) { UNUSED(value); - return OB_NEW(ObConnectResHashNode, MEMORY_LABEL); + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); + return OB_NEW(ObConnectResHashNode, attr); } void ObConnectResAlloc::free_node(ObConnectResHashNode* node) @@ -97,7 +101,9 @@ int ObConnectResourceMgr::apply_for_tenant_conn_resource(const uint64_t tenant_i if (OB_ENTRY_NOT_EXIST == ret) { ret = OB_SUCCESS; // not exist, alloc and insert - if (OB_ISNULL(tenant_res = OB_NEW(ObConnectResource, MEMORY_LABEL))) { + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); + if (OB_ISNULL(tenant_res = OB_NEW(ObConnectResource, attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate tenant resource failed", K(ret)); } else { @@ -205,8 +211,10 @@ int ObConnectResourceMgr::get_or_insert_user_resource(const uint64_t tenant_id, if (OB_FAIL(user_res_map_.get(user_key, user_res))) { if (OB_ENTRY_NOT_EXIST == ret) { ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, MEMORY_LABEL); + SET_USE_500(attr); // not exist, alloc and insert - if (OB_ISNULL(user_res = OB_NEW(ObConnectResource, MEMORY_LABEL))) { + if (OB_ISNULL(user_res = OB_NEW(ObConnectResource, attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("allocate user resource failed", K(ret)); } else { diff --git a/src/storage/blocksstable/encoding/ob_encoding_allocator.h b/src/storage/blocksstable/encoding/ob_encoding_allocator.h index 707822128b..9a3a162ab7 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_allocator.h +++ b/src/storage/blocksstable/encoding/ob_encoding_allocator.h @@ -104,7 +104,10 @@ public: allocator_(nullptr) { int ret = OB_SUCCESS; - if (nullptr == (allocator_ = OB_NEW(ObDecoderAllocator, "encoding_alloc", + lib::ObMemAttr attr; + attr.label_ = "encoding_alloc"; + SET_USE_500(attr); + if (nullptr == (allocator_ = OB_NEW(ObDecoderAllocator, attr, decoder_sizes, "encoding_alloc"))) { ret = common::OB_ALLOCATE_MEMORY_FAILED; STORAGE_LOG(WARN, "allocate ObDecoderAllocator failed", K(ret)); diff --git a/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp b/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp index 2621e543b9..b3e0822f31 100644 --- a/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp +++ b/src/storage/blocksstable/encoding/ob_encoding_allocator.ipp @@ -14,7 +14,7 @@ template ObEncodingPool::ObEncodingPool(const int64_t item_size, const char *label) : free_items_(), free_cnt_(0), pool_(item_size, common::OB_MALLOC_NORMAL_BLOCK_SIZE, - common::ObMalloc(label)) + common::ObMalloc(SET_USE_500(label))) { } diff --git a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp index e8a661bf60..858bab1db8 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_decoder.cpp @@ -126,7 +126,7 @@ ObColumnDecoderCtx ObMicroBlockDecoder::none_exist_column_decoder_ctx_; class ObTLDecoderCtxArray { public: - ObTLDecoderCtxArray(): ctxs_array_(), allocator_("TLDecoderCtx") {} + ObTLDecoderCtxArray(): ctxs_array_(), allocator_(SET_USE_500("TLDecoderCtx")) {} virtual ~ObTLDecoderCtxArray() { @@ -877,8 +877,8 @@ ObMicroBlockDecoder::ObMicroBlockDecoder() allocator_(nullptr), ctx_array_(nullptr), ctxs_(nullptr), - decoder_allocator_(ObModIds::OB_DECODER_CTX), - buf_allocator_("OB_MICB_DECODER") + decoder_allocator_(SET_USE_500(ObModIds::OB_DECODER_CTX)), + buf_allocator_(SET_USE_500("OB_MICB_DECODER")) { need_release_decoders_.set_allocator(&buf_allocator_); } diff --git a/src/storage/blocksstable/ob_index_block_row_scanner.cpp b/src/storage/blocksstable/ob_index_block_row_scanner.cpp index 4b0ba86f4e..07d7da1c74 100644 --- a/src/storage/blocksstable/ob_index_block_row_scanner.cpp +++ b/src/storage/blocksstable/ob_index_block_row_scanner.cpp @@ -43,7 +43,7 @@ int ObIndexBlockDataHeader::get_index_data(const int64_t row_idx, const char *&i } ObIndexBlockDataTransformer::ObIndexBlockDataTransformer() - : allocator_(), micro_reader_helper_() {} + : allocator_(SET_USE_500(lib::ObMemAttr(OB_SERVER_TENANT_ID, "IdxBlkDataTrans"))), micro_reader_helper_() {} ObIndexBlockDataTransformer::~ObIndexBlockDataTransformer() { diff --git a/src/storage/blocksstable/ob_micro_block_cache.cpp b/src/storage/blocksstable/ob_micro_block_cache.cpp index 3d747c3082..188949590c 100644 --- a/src/storage/blocksstable/ob_micro_block_cache.cpp +++ b/src/storage/blocksstable/ob_micro_block_cache.cpp @@ -1038,7 +1038,7 @@ int ObDataMicroBlockCache::init(const char *cache_name, const int64_t priority) } else if (OB_FAIL(allocator_.init(mem_limit, OB_MALLOC_MIDDLE_BLOCK_SIZE, OB_MALLOC_MIDDLE_BLOCK_SIZE))) { STORAGE_LOG(WARN, "Fail to init io allocator, ", K(ret)); } else { - allocator_.set_label(ObModIds::OB_SSTABLE_MICRO_BLOCK_ALLOCATOR); + allocator_.set_attr(SET_USE_500(ObMemAttr(OB_SERVER_TENANT_ID, ObModIds::OB_SSTABLE_MICRO_BLOCK_ALLOCATOR))); } return ret; } diff --git a/src/storage/blocksstable/ob_micro_block_reader_helper.h b/src/storage/blocksstable/ob_micro_block_reader_helper.h index 9b058a92cd..d3137680d8 100644 --- a/src/storage/blocksstable/ob_micro_block_reader_helper.h +++ b/src/storage/blocksstable/ob_micro_block_reader_helper.h @@ -119,4 +119,4 @@ int ObMicroBlockReaderHelper::init_reader(T *&cache_reader_ptr, ObIMicroBlockRea } // end namespace blocksstable } // end namespace oceanbase - #endif //OCEANBASE_BLOCKSSTABLE_OB_MICRO_BLOCK_READER_HELPER_H_ \ No newline at end of file + #endif //OCEANBASE_BLOCKSSTABLE_OB_MICRO_BLOCK_READER_HELPER_H_ diff --git a/src/storage/blocksstable/ob_tmp_file_store.cpp b/src/storage/blocksstable/ob_tmp_file_store.cpp index 3e63a9172e..b907f01ddd 100644 --- a/src/storage/blocksstable/ob_tmp_file_store.cpp +++ b/src/storage/blocksstable/ob_tmp_file_store.cpp @@ -614,10 +614,11 @@ ObTmpTenantMacroBlockManager::~ObTmpTenantMacroBlockManager() int ObTmpTenantMacroBlockManager::init(common::ObIAllocator &allocator) { int ret = OB_SUCCESS; + auto attr = SET_USE_500(ObModIds::OB_TMP_BLOCK_MAP); if (IS_INIT) { ret = OB_INIT_TWICE; STORAGE_LOG(WARN, "ObTmpMacroBlockManager has been inited", K(ret)); - } else if (OB_FAIL(blocks_.create(MBLK_HASH_BUCKET_NUM, ObModIds::OB_TMP_BLOCK_MAP))) { + } else if (OB_FAIL(blocks_.create(MBLK_HASH_BUCKET_NUM, attr, attr))) { STORAGE_LOG(WARN, "Fail to create tmp macro block map, ", K(ret)); } else { allocator_ = &allocator; @@ -814,6 +815,8 @@ int64_t ObTmpTenantFileStore::dec_ref() int ObTmpTenantFileStore::init(const uint64_t tenant_id) { + auto allocator_attr = SET_USE_500(ObModIds::OB_TMP_BLOCK_MANAGER); + auto io_allocator_attr = SET_USE_500(ObModIds::OB_TMP_PAGE_CACHE); int ret = OB_SUCCESS; if (IS_INIT) { ret = OB_INIT_TWICE; @@ -822,6 +825,8 @@ int ObTmpTenantFileStore::init(const uint64_t tenant_id) STORAGE_LOG(WARN, "fail to init allocator", K(ret)); } else if (OB_FAIL(io_allocator_.init(OB_MALLOC_BIG_BLOCK_SIZE, ObModIds::OB_TMP_PAGE_CACHE, tenant_id, IO_LIMIT))) { STORAGE_LOG(WARN, "Fail to init io allocator, ", K(ret)); + } else if (FALSE_IT(allocator_.set_attr(allocator_attr))) { + } else if (FALSE_IT(io_allocator_.set_attr(io_allocator_attr))) { } else if (OB_ISNULL(page_cache_ = &ObTmpPageCache::get_instance())) { ret = OB_ERR_UNEXPECTED; STORAGE_LOG(WARN, "fail to get the page cache", K(ret)); @@ -1399,6 +1404,7 @@ ObTmpFileStore::~ObTmpFileStore() int ObTmpFileStore::init() { int ret = OB_SUCCESS; + auto attr = SET_USE_500(ObModIds::OB_TMP_FILE_STORE_MAP); if (IS_INIT) { ret = OB_INIT_TWICE; STORAGE_LOG(WARN, "ObTmpFileStore has not been inited", K(ret)); @@ -1411,10 +1417,10 @@ int ObTmpFileStore::init() TMP_FILE_BLOCK_CACHE_PRIORITY))) { STORAGE_LOG(WARN, "Fail to init tmp tenant block cache, ", K(ret)); } else if (OB_FAIL(tenant_file_stores_.create(STORE_HASH_BUCKET_NUM, - ObModIds::OB_TMP_FILE_STORE_MAP))) { + attr, attr))) { STORAGE_LOG(WARN, "Fail to create tmp tenant file store map, ", K(ret)); } else { - allocator_.set_label(ObModIds::OB_TMP_FILE_STORE_MAP); + allocator_.set_attr(attr); is_inited_ = true; } if (!is_inited_) { diff --git a/src/storage/compaction/ob_compaction_diagnose.cpp b/src/storage/compaction/ob_compaction_diagnose.cpp index 88ab26f09c..d69edcb825 100644 --- a/src/storage/compaction/ob_compaction_diagnose.cpp +++ b/src/storage/compaction/ob_compaction_diagnose.cpp @@ -74,7 +74,7 @@ int64_t ObScheduleSuspectInfo::gen_hash(int64_t tenant_id, int64_t dag_hash) ObScheduleSuspectInfoMgr::ObScheduleSuspectInfoMgr() : is_inited_(false), - allocator_("scheSuspectInfo", OB_SERVER_TENANT_ID), + allocator_(SET_USE_500("scheSuspectInfo")), lock_(common::ObLatchIds::INFO_MGR_LOCK) { } @@ -82,7 +82,7 @@ ObScheduleSuspectInfoMgr::ObScheduleSuspectInfoMgr() int ObScheduleSuspectInfoMgr::init() { int ret = OB_SUCCESS; - if (OB_FAIL(info_map_.create(SUSPECT_INFO_BUCKET_NUM, "scheSuspectInfo"))) { + if (OB_FAIL(info_map_.create(SUSPECT_INFO_BUCKET_NUM, SET_USE_500("scheSuspectInfo")))) { COMMON_LOG(WARN, "failed to create dap map", K(ret)); } else { is_inited_ = true; diff --git a/src/storage/compaction/ob_storage_locality_cache.cpp b/src/storage/compaction/ob_storage_locality_cache.cpp index ea28a929e7..3490048618 100644 --- a/src/storage/compaction/ob_storage_locality_cache.cpp +++ b/src/storage/compaction/ob_storage_locality_cache.cpp @@ -61,7 +61,7 @@ ObStorageLocalityCache::ObStorageLocalityCache() sql_proxy_(nullptr), alloc_buf_(nullptr), allocator_("StoLocCache"), - ls_locality_array_(OB_MALLOC_NORMAL_BLOCK_SIZE, allocator_) + ls_locality_array_(OB_MALLOC_NORMAL_BLOCK_SIZE, ModulePageAllocator(allocator_)) {} ObStorageLocalityCache::~ObStorageLocalityCache() diff --git a/src/storage/compaction/ob_storage_locality_cache.h b/src/storage/compaction/ob_storage_locality_cache.h index 27015083b0..b73526541f 100644 --- a/src/storage/compaction/ob_storage_locality_cache.h +++ b/src/storage/compaction/ob_storage_locality_cache.h @@ -102,7 +102,7 @@ private: ObMySQLProxy *sql_proxy_; void *alloc_buf_; common::DefaultPageAllocator allocator_; - common::ObArray ls_locality_array_; + common::ObArray ls_locality_array_; }; } // namespace compaction diff --git a/src/storage/ddl/ob_ddl_heart_beat_task.cpp b/src/storage/ddl/ob_ddl_heart_beat_task.cpp index 139ae8f5fc..7e16691c91 100644 --- a/src/storage/ddl/ob_ddl_heart_beat_task.cpp +++ b/src/storage/ddl/ob_ddl_heart_beat_task.cpp @@ -67,10 +67,12 @@ ObDDLHeartBeatTaskContainer::~ObDDLHeartBeatTaskContainer() int ObDDLHeartBeatTaskContainer::init() { int ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, "register_tasks"); + SET_USE_500(attr); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("ObDDLHeartBeatTaskContainer inited twice", K(ret)); - } else if (OB_FAIL(register_tasks_.create(BUCKET_LOCK_BUCKET_CNT, "register_tasks", "register_tasks"))) { + } else if (OB_FAIL(register_tasks_.create(BUCKET_LOCK_BUCKET_CNT, attr, attr))) { LOG_WARN("failed to create register_tasks map", K(ret)); } else if (OB_FAIL(bucket_lock_.init(BUCKET_LOCK_BUCKET_CNT))) { LOG_WARN("failed to init bucket lock", K(ret)); @@ -166,4 +168,4 @@ int ObDDLHeartBeatTaskContainer::send_task_status_to_rs() } } // end of namespace storage -} // end of namespace oceanbase \ No newline at end of file +} // end of namespace oceanbase diff --git a/src/storage/ddl/ob_ddl_redo_log_replayer.cpp b/src/storage/ddl/ob_ddl_redo_log_replayer.cpp index e7219689e5..8778f58cdf 100644 --- a/src/storage/ddl/ob_ddl_redo_log_replayer.cpp +++ b/src/storage/ddl/ob_ddl_redo_log_replayer.cpp @@ -38,12 +38,14 @@ ObDDLRedoLogReplayer::~ObDDLRedoLogReplayer() int ObDDLRedoLogReplayer::init(ObLS *ls) { int ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, "RedoLogBuckLock"); + SET_USE_500(attr); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("ObDDLRedoLogReplayer has been inited twice", K(ret)); } else if (OB_FAIL(allocator_.init(TOTAL_LIMIT, HOLD_LIMIT, OB_MALLOC_NORMAL_BLOCK_SIZE))) { LOG_WARN("fail to init allocator", K(ret)); - } else if (OB_FAIL(bucket_lock_.init(DEFAULT_HASH_BUCKET_COUNT))) { + } else if (OB_FAIL(bucket_lock_.init(DEFAULT_HASH_BUCKET_COUNT, ObLatchIds::DEFAULT_BUCKET_LOCK, attr))) { LOG_WARN("fail to init bucket lock", K(ret)); } else { ls_ = ls; diff --git a/src/storage/ddl/ob_ddl_redo_log_writer.cpp b/src/storage/ddl/ob_ddl_redo_log_writer.cpp index 1d63eed495..ddb93e270c 100644 --- a/src/storage/ddl/ob_ddl_redo_log_writer.cpp +++ b/src/storage/ddl/ob_ddl_redo_log_writer.cpp @@ -261,7 +261,8 @@ void ObDDLCtrlSpeedHandle::ObDDLCtrlSpeedItemHandle::reset() } ObDDLCtrlSpeedHandle::ObDDLCtrlSpeedHandle() - : is_inited_(false), speed_handle_map_(), allocator_("DDLClogCtrl"), bucket_lock_(), refreshTimerTask_() + : is_inited_(false), speed_handle_map_(), allocator_(SET_USE_500("DDLClogCtrl")), + bucket_lock_(), refreshTimerTask_() { } @@ -283,6 +284,8 @@ ObDDLCtrlSpeedHandle &ObDDLCtrlSpeedHandle::get_instance() int ObDDLCtrlSpeedHandle::init() { int ret = OB_SUCCESS; + lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "DDLSpeedCtrl"); + SET_USE_500(attr); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("inited twice", K(ret)); @@ -291,7 +294,7 @@ int ObDDLCtrlSpeedHandle::init() LOG_WARN("unexpected error, speed handle map is created", K(ret)); } else if (OB_FAIL(bucket_lock_.init(MAP_BUCKET_NUM))) { LOG_WARN("init bucket lock failed", K(ret)); - } else if (OB_FAIL(speed_handle_map_.create(MAP_BUCKET_NUM, "DDLSpeedCtrl"))) { + } else if (OB_FAIL(speed_handle_map_.create(MAP_BUCKET_NUM, attr, attr))) { LOG_WARN("fail to create speed handle map", K(ret)); } else { is_inited_ = true; diff --git a/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp b/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp index 541d5b6490..4f96c699f6 100644 --- a/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp +++ b/src/storage/ddl/ob_direct_insert_sstable_ctx.cpp @@ -1299,19 +1299,22 @@ int ObSSTableInsertManager::init() int ret = OB_SUCCESS; const int64_t bucket_num = 1000L * 100L; // 10w const int64_t memory_limit = 1024L * 1024L * 1024L * 10L; // 10GB + lib::ObMemAttr attr(OB_SERVER_TENANT_ID, "DInsSstMgr"); + SET_USE_500(attr); if (OB_UNLIKELY(is_inited_)) { ret = OB_INIT_TWICE; LOG_WARN("init twice", K(ret)); } else if (OB_FAIL(allocator_.init(OB_MALLOC_MIDDLE_BLOCK_SIZE, - lib::ObLabel("DInsSstMgr"), - OB_SERVER_TENANT_ID, - memory_limit))) { + attr.label_, + OB_SERVER_TENANT_ID, + memory_limit))) { LOG_WARN("init alloctor failed", K(ret)); } else if (OB_FAIL(bucket_lock_.init(bucket_num))) { LOG_WARN("init bucket lock failed", K(ret), K(bucket_num)); - } else if (OB_FAIL(table_ctx_map_.create(bucket_num, lib::ObLabel("DInsSstMgr")))) { + } else if (OB_FAIL(table_ctx_map_.create(bucket_num, attr, attr))) { LOG_WARN("create context map failed", K(ret)); } else { + allocator_.set_attr(attr); context_id_generator_ = ObTimeUtility::current_time(); is_inited_ = true; } diff --git a/src/storage/lob/ob_lob_manager.cpp b/src/storage/lob/ob_lob_manager.cpp index 3dd915d46e..f2abed3999 100644 --- a/src/storage/lob/ob_lob_manager.cpp +++ b/src/storage/lob/ob_lob_manager.cpp @@ -28,7 +28,8 @@ namespace storage int ObLobManager::mtl_new(ObLobManager *&m) { int ret = OB_SUCCESS; const uint64_t tenant_id = MTL_ID(); - m = OB_NEW(ObLobManager, oceanbase::ObModIds::OMT_TENANT, tenant_id); + auto attr = SET_USE_500("LobManager"); + m = OB_NEW(ObLobManager, attr, tenant_id); if (OB_ISNULL(m)) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to alloc memory", K(ret), K(tenant_id)); @@ -972,7 +973,7 @@ int ObLobManager::check_need_out_row( // in_row : 0 | need_out_row : 0 --> invalid // in_row : 0 | need_out_row : 1 --> do nothing, keep out_row // in_row : 1 | need_out_row : 0 --> do nothing, keep in_row - // in_row : 1 | need_out_row : 1 --> in_row to out_row + // in_row : 1 | need_out_row : 1 --> in_row to out_row if (!param.lob_common_->in_row_ && !need_out_row) { if (!param.lob_common_->is_init_) { ret = OB_ERR_UNEXPECTED; diff --git a/src/storage/memtable/ob_memtable.cpp b/src/storage/memtable/ob_memtable.cpp index 40b937409a..c6dd65794c 100644 --- a/src/storage/memtable/ob_memtable.cpp +++ b/src/storage/memtable/ob_memtable.cpp @@ -2386,7 +2386,9 @@ bool ObMemtable::has_multi_source_data_unit(const MultiSourceDataUnitType type) ObMemtableStat::ObMemtableStat() : lock_(common::ObLatchIds::MEMTABLE_STAT_LOCK), memtables_() -{} +{ + memtables_.set_attr(SET_USE_500("MemTables")); +} ObMemtableStat::~ObMemtableStat() {} diff --git a/src/storage/ob_resource_map.h b/src/storage/ob_resource_map.h index 467b32fde3..cb9165f640 100644 --- a/src/storage/ob_resource_map.h +++ b/src/storage/ob_resource_map.h @@ -212,6 +212,7 @@ int ObResourceMap::init( const int64_t page_size) { int ret = common::OB_SUCCESS; + auto attr = SET_USE_500(ObMemAttr(tenant_id, label)); const int64_t bkt_num = common::hash::cal_next_prime(bucket_num); if (OB_UNLIKELY(is_inited_)) { ret = common::OB_INIT_TWICE; @@ -223,7 +224,7 @@ int ObResourceMap::init( K(page_size), K(tenant_id)); } else if (OB_FAIL(bucket_lock_.init(bkt_num))) { STORAGE_LOG(WARN, "fail to init bucket lock", K(ret), K(bkt_num)); - } else if (OB_FAIL(map_.create(bkt_num, label, label, tenant_id))) { + } else if (OB_FAIL(map_.create(bkt_num, attr, attr))) { STORAGE_LOG(WARN, "fail to create map", K(ret)); } else if (OB_UNLIKELY(bkt_num != map_.bucket_count())) { ret = OB_ERR_UNEXPECTED; @@ -232,7 +233,7 @@ int ObResourceMap::init( } else if (OB_FAIL(allocator_.init(total_limit, hold_limit, page_size))) { STORAGE_LOG(WARN, "fail to init allocator", K(ret)); } else { - allocator_.set_label(label); + allocator_.set_attr(attr); is_inited_ = true; STORAGE_LOG(INFO, "init resource map success", K(ret), K(tenant_id), K(bkt_num)); } diff --git a/src/storage/tx/ob_trans_define.h b/src/storage/tx/ob_trans_define.h index 7e8216132e..ecd6a3805a 100644 --- a/src/storage/tx/ob_trans_define.h +++ b/src/storage/tx/ob_trans_define.h @@ -177,8 +177,7 @@ public: if (OB_UNLIKELY(ObTransErrsim::is_memory_errsim())) { ret = NULL; } else { - const common::ObMemAttr attr(tenant_id_, label_, ctx_id_); - ret = inner_alloc_(sz, attr); + ret = inner_alloc_(sz, attr_); } return ret; } @@ -425,8 +424,8 @@ public: enum TransType : int32_t { - UNKNOWN_TRANS = -1, - SP_TRANS = 0, + UNKNOWN_TRANS = -1, + SP_TRANS = 0, DIST_TRANS = 2 }; diff --git a/src/storage/tx/ob_ts_mgr.cpp b/src/storage/tx/ob_ts_mgr.cpp index 5be11857cc..201c26c13c 100644 --- a/src/storage/tx/ob_ts_mgr.cpp +++ b/src/storage/tx/ob_ts_mgr.cpp @@ -931,6 +931,7 @@ int ObTsMgr::add_tenant_(const uint64_t tenant_id) void *ptr = NULL; ObTimeGuard timeguard("add ts tenant"); ObMemAttr memattr(OB_SERVER_TENANT_ID, ObModIds::OB_GTS_TASK_QUEUE); + SET_USE_500(memattr); ObTsTenantInfo tenant_info(tenant_id); ObTsSourceInfo *ts_source_info = NULL; diff --git a/src/storage/tx/ob_tx_ls_log_writer.cpp b/src/storage/tx/ob_tx_ls_log_writer.cpp index b7451957f1..436e9e4f36 100644 --- a/src/storage/tx/ob_tx_ls_log_writer.cpp +++ b/src/storage/tx/ob_tx_ls_log_writer.cpp @@ -148,11 +148,13 @@ int ObTxLSLogCb::alloc_log_buf_() { int ret = OB_SUCCESS; + ObMemAttr attr(OB_SERVER_TENANT_ID, "TxLSLogBuf"); + SET_USE_500(attr); if (0 == ObTxLSLogLimit::LOG_BUF_SIZE || nullptr != log_buf_) { ret = OB_INVALID_ARGUMENT; TRANS_LOG(WARN, "[TxLsLogWriter] invalid arguments", KR(ret), K(ObTxLSLogLimit::LOG_BUF_SIZE), KP(log_buf_)); } else if (nullptr - == (log_buf_ = (char *)ob_malloc(ObTxLSLogLimit::LOG_BUF_SIZE, "TxLSLogBuf"))) { + == (log_buf_ = (char *)ob_malloc(ObTxLSLogLimit::LOG_BUF_SIZE, attr))) { ret = OB_ALLOCATE_MEMORY_FAILED; TRANS_LOG(WARN, "[TxLsLogWriter] allocate memory failed", KR(ret), K(ObTxLSLogLimit::LOG_BUF_SIZE)); } diff --git a/src/storage/tx_storage/ob_tenant_memory_printer.cpp b/src/storage/tx_storage/ob_tenant_memory_printer.cpp index 96931abcd4..97ff6dd222 100644 --- a/src/storage/tx_storage/ob_tenant_memory_printer.cpp +++ b/src/storage/tx_storage/ob_tenant_memory_printer.cpp @@ -90,6 +90,7 @@ int ObTenantMemoryPrinter::print_tenant_usage() LOG_WARN("print mtl tenant usage failed", K(tmp_ret), K(tenant_id)); } } + uint64_t tenant_ids[128] = {0}; int tenant_cnt = 0; static uint64_t all_tenant_ids[OB_MAX_SERVER_TENANT_CNT] = {0}; common::get_tenant_ids(all_tenant_ids, OB_MAX_SERVER_TENANT_CNT, tenant_cnt); @@ -107,6 +108,7 @@ int ObTenantMemoryPrinter::print_tenant_usage() if (is_deleted_tenant) { mallocator->print_tenant_memory_usage(id); mallocator->print_tenant_ctx_memory_usage(id); + mallocator->print_malloc_sample(id); } } }