fix null mod_name

This commit is contained in:
obdev 2023-04-13 06:46:35 +00:00 committed by ob-robot
parent fdc59d1d46
commit 36e28a5f79
89 changed files with 175 additions and 183 deletions

View File

@ -30,7 +30,6 @@ void *ObTenantCtxAllocator::alloc(const int64_t size, const ObMemAttr &attr)
{
abort_unless(attr.tenant_id_ == tenant_id_);
abort_unless(attr.ctx_id_ == ctx_id_);
BACKTRACE_RET(WARN, OB_INVALID_ARGUMENT, !attr.label_.is_valid(), "[OB_MOD_DO_NOT_USE_ME ALLOC]size:%ld", size);
void *ptr = common_alloc(size, attr, *this, obj_mgr_);
return ptr;
}
@ -44,7 +43,6 @@ int64_t ObTenantCtxAllocator::get_obj_hold(void *ptr)
void* ObTenantCtxAllocator::realloc(const void *ptr, const int64_t size, const ObMemAttr &attr)
{
BACKTRACE_RET(WARN, OB_INVALID_ARGUMENT, !attr.label_.is_valid(), "[OB_MOD_DO_NOT_USE_ME REALLOC]size:%ld", size);
void *nptr = common_realloc(ptr, size, attr, *this, obj_mgr_);
return nptr;
}
@ -401,6 +399,9 @@ void* ObTenantCtxAllocator::common_alloc(const int64_t size, const ObMemAttr &at
{
SANITY_DISABLE_CHECK_RANGE(); // prevent sanity_check_range
void *ret = nullptr;
if (!attr.label_.is_valid()) {
LIB_LOG_RET(ERROR, OB_INVALID_ARGUMENT, "OB_MOD_DO_NOT_USE_ME ALLOC", K(size));
}
bool sample_allowed = ObMallocSampleLimiter::malloc_sample_allowed(size, attr);
const int64_t alloc_size = sample_allowed ? (size + AOBJECT_BACKTRACE_SIZE) : size;
AObject *obj = allocator.alloc_object(alloc_size, attr);
@ -443,6 +444,9 @@ void* ObTenantCtxAllocator::common_realloc(const void *ptr, const int64_t size,
{
SANITY_DISABLE_CHECK_RANGE(); // prevent sanity_check_range
void *nptr = NULL;
if (!attr.label_.is_valid()) {
LIB_LOG_RET(ERROR, OB_INVALID_ARGUMENT, "OB_MOD_DO_NOT_USE_ME REALLOC", K(size));
}
AObject *obj = NULL;
if (NULL != ptr) {
obj = reinterpret_cast<AObject*>((char*)ptr - AOBJECT_HEADER_SIZE);

View File

@ -21,7 +21,6 @@ namespace oceanbase
namespace common
{
using lib::ObMemAttr;
extern ObMemAttr default_memattr;
class ObIAllocator
{
public:
@ -80,7 +79,8 @@ public:
{
return NULL == alloc_ ? NULL : alloc_->alloc(sz, attr);
}
virtual void *alloc(const int64_t sz) { return alloc(sz, default_memattr); }
virtual void *alloc(const int64_t sz)
{ return NULL == alloc_ ? NULL : alloc_->alloc(sz); }
virtual void* realloc(const void *ptr, const int64_t size, const ObMemAttr &attr)
{ return NULL == alloc_ ? NULL : alloc_->realloc(ptr, size, attr); }

View File

@ -30,7 +30,6 @@ void *ObAllocator::alloc(const int64_t size, const ObMemAttr &attr)
ret = init();
}
if (OB_SUCC(ret)) {
BACKTRACE_RET(WARN, OB_INVALID_ARGUMENT, !attr.label_.is_valid(), "[OB_MOD_DO_NOT_USE_ME ALLOC]size:%ld", size);
ObMemAttr inner_attr = attr_;
if (attr.label_.is_valid()) {
inner_attr.label_ = attr.label_;

View File

@ -44,7 +44,7 @@ class ObAllocator : public ObIAllocator
friend class lib::__MemoryContext__;
friend class ObParallelAllocator;
public:
ObAllocator(__MemoryContext__ *mem_context, const ObMemAttr &attr = default_memattr,
ObAllocator(__MemoryContext__ *mem_context, const ObMemAttr &attr,
const bool use_pm=false,
const uint32_t ablock_size=lib::INTACT_NORMAL_AOBJECT_SIZE);
virtual ~ObAllocator() {}
@ -176,7 +176,7 @@ class ObParallelAllocator : public ObIAllocator
public:
ObParallelAllocator(ObAllocator &root_allocator,
__MemoryContext__ *mem_context,
const ObMemAttr &attr=default_memattr,
const ObMemAttr &attr,
const int parallel=4,
const uint32_t ablock_size=lib::INTACT_NORMAL_AOBJECT_SIZE);
virtual ~ObParallelAllocator();

View File

@ -90,7 +90,7 @@ public:
int init(ObIAllocator *allocator,
const int64_t page_size,
const ObMemAttr &attr=default_memattr,
const ObMemAttr &attr,
const int64_t init_size=0,
const int64_t idle_size=256L << 10,
const int64_t max_size=INT64_MAX);

View File

@ -19,7 +19,6 @@
#include <execinfo.h>
#endif
oceanbase::common::ObMemAttr oceanbase::common::default_memattr;
int oceanbase::common::ObMemBuf::ensure_space(const int64_t size, const lib::ObLabel &label)
{

View File

@ -29,8 +29,7 @@ inline void ob_print_mod_memory_usage(bool print_to_std = false,
UNUSEDx(print_to_std, print_glibc_malloc_stats);
}
extern ObMemAttr default_memattr;
inline void *ob_malloc(const int64_t nbyte, const ObMemAttr &attr = default_memattr)
inline void *ob_malloc(const int64_t nbyte, const ObMemAttr &attr)
{
void *ptr = NULL;
auto allocator = lib::ObMallocAllocator::get_instance();
@ -70,7 +69,7 @@ inline void *ob_realloc(void *ptr, const int64_t nbyte, const ObMemAttr &attr)
void *ob_malloc_align(
const int64_t alignment, const int64_t nbyte,
const ObMemAttr &attr = default_memattr);
const ObMemAttr &attr);
void ob_free_align(void *ptr);
// Deprecated interface

View File

@ -25,7 +25,6 @@ namespace oceanbase
{
namespace common
{
using oceanbase::common::default_memattr;
using lib::BlockSet;
using lib::AChunk;
using lib::ABlock;
@ -71,7 +70,7 @@ public:
int64_t get_hold() const;
int64_t get_tid() const { return tid_; }
// IBlockMgr interface
virtual ABlock *alloc_block(uint64_t size, const ObMemAttr &attr=default_memattr) override;
virtual ABlock *alloc_block(uint64_t size, const ObMemAttr &attr) override;
virtual void free_block(ABlock *block) override;
virtual int64_t sync_wash(int64_t wash_size) override
{

View File

@ -23,10 +23,10 @@ namespace common
class ObSafeArena : public ObIAllocator
{
public:
ObSafeArena(const lib::ObLabel &label, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE, ObMemAttr attr = default_memattr)
: arena_alloc_(label, page_size, attr.tenant_id_),
lock_(ObLatchIds::OB_AREAN_ALLOCATOR_LOCK),
attr_(attr)
ObSafeArena(const lib::ObLabel &label, const int64_t page_size = OB_MALLOC_NORMAL_BLOCK_SIZE,
int64_t tenant_id = OB_SERVER_TENANT_ID)
: arena_alloc_(label, page_size, tenant_id),
lock_(ObLatchIds::OB_AREAN_ALLOCATOR_LOCK)
{}
virtual ~ObSafeArena() {}
@ -34,7 +34,8 @@ public:
public:
virtual void *alloc(const int64_t sz) override
{
return alloc(sz, attr_);
ObSpinLockGuard guard(lock_);
return arena_alloc_.alloc(sz);
}
virtual void* alloc(const int64_t sz, const ObMemAttr &attr) override
@ -81,7 +82,6 @@ public:
private:
ObArenaAllocator arena_alloc_;
ObSpinLock lock_;
ObMemAttr attr_;
private:
DISALLOW_COPY_AND_ASSIGN(ObSafeArena);

View File

@ -91,7 +91,7 @@ struct ModulePageAllocator: public ObIAllocator
tenant_id_(tenant_id),
ctx_id_(ctx_id) {}
explicit ModulePageAllocator(ObIAllocator &allocator,
const lib::ObLabel &label = lib::ObLabel())
const lib::ObLabel &label = ObModIds::OB_MODULE_PAGE_ALLOCATOR)
: allocator_(&allocator),
label_(label),
tenant_id_(OB_SERVER_TENANT_ID),
@ -1095,7 +1095,8 @@ public:
public:
void *alloc(const int64_t sz) override
{
return alloc(sz, default_memattr);
ObSpinLockGuard guard(lock_);
return arena_.alloc(sz);
}
void *alloc(const int64_t sz, const ObMemAttr &attr) override
{

View File

@ -783,7 +783,8 @@ private:
DISALLOW_COPY_AND_ASSIGN(ObHashTable);
public:
ObHashTable() : allocer_(NULL),
ObHashTable() : default_bucket_allocer_(ObModIds::OB_HASH_BUCKET),
allocer_(NULL),
bucket_allocer_(&default_bucket_allocer_),
bucket_num_(0),
size_(0)

View File

@ -69,7 +69,6 @@ namespace lib
using std::nullptr_t;
using lib::ObMemAttr;
using oceanbase::common::default_memattr;
class Flow;
class __MemoryContext__;
enum class ContextSource
@ -331,14 +330,12 @@ public:
const DynamicInfo &get_dynamic_info() const { return di_; }
const StaticInfo &get_static_info() const { return *reinterpret_cast<StaticInfo*>(static_id_); }
void *allocf(const int64_t size,
const ObMemAttr &attr=default_memattr)
const ObMemAttr &attr)
{
return freeable_alloc_->alloc(size, attr);
}
void *allocp(const int64_t size,
const ObMemAttr &attr=default_memattr)
void *allocp(const int64_t size)
{
UNUSEDx(attr);
void *ptr = nullptr;
ptr = arena_alloc_.alloc(size);
return ptr;
@ -759,15 +756,14 @@ private:
};
inline void *ctxalf(const int64_t size,
const ObMemAttr &attr=default_memattr)
const ObMemAttr &attr)
{
return CURRENT_CONTEXT->allocf(size, attr);
}
inline void *ctxalp(const int64_t size,
const ObMemAttr &attr=default_memattr)
inline void *ctxalp(const int64_t size)
{
return CURRENT_CONTEXT->allocp(size, attr);
return CURRENT_CONTEXT->allocp(size);
}
inline void ctxfree(void *ptr)

View File

@ -211,7 +211,7 @@ int ObTimezoneUtils::parse_timezone_file(const ObString& timezone_file_name)
ALIGN_SIZE(sp.typecnt * sizeof(TRAN_TYPE_INFO)) +
ALIGN_SIZE(sp.charcnt) +
sp.leapcnt * sizeof(LS_INFO);
tzinfo_buf = (char *)ob_malloc(bufSize);
tzinfo_buf = (char *)ob_malloc(bufSize, "TimeZoneUtils");
if(NULL == tzinfo_buf){
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
@ -415,8 +415,8 @@ int ObTimezoneUtils::prepare_tz_info(TIME_ZONE_INFO &tz_info)
}
/* set maximum end_l as finisher */
revts[tz_info.revcnt] = end_l;
if(!(tz_info.revts = (my_time_t*)ob_malloc(sizeof(my_time_t) * (tz_info.revcnt + 1)))
|| !(tz_info.revtis = (REVT_INFO*)ob_malloc(sizeof(REVT_INFO) * tz_info.revcnt))
if(!(tz_info.revts = (my_time_t*)ob_malloc(sizeof(my_time_t) * (tz_info.revcnt + 1), "TimeZoneUtils"))
|| !(tz_info.revtis = (REVT_INFO*)ob_malloc(sizeof(REVT_INFO) * tz_info.revcnt, "TimeZoneUtils"))
){
OB_LOG(ERROR, "ob_malloc for tz_info.revts tz_info.revtis failed");
ret = OB_ALLOCATE_MEMORY_FAILED;

View File

@ -40,7 +40,7 @@ inline int ObProtoEncodeParam::save_large_packet(const char *start, const int64_
} else if (OB_UNLIKELY(NULL != large_pkt_buf_)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("large pkt buf has already exist", KP(start), K(len), K(ret));
} else if (OB_ISNULL(large_pkt_buf_ = (char *)ob_malloc(len))) {
} else if (OB_ISNULL(large_pkt_buf_ = (char *)ob_malloc(len, "ProtoEncodePara"))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("fail to alloc mem", K(len), K(ret));
} else {

View File

@ -173,7 +173,7 @@ TEST_F(TestBlockSet, BigBlockOrigin)
void *p = NULL;
while (cnt--) {
p = ob_malloc(sz);
p = ob_malloc(sz, ObNewModIds::TEST);
check_ptr(p);
ob_free(p);
}

View File

@ -42,7 +42,7 @@ TEST_F(TestObMallocCallbackGuard, AllocAndFree)
int64_t hold = 0;
MallocCallback cb(hold);
ObMallocCallbackGuard guard(cb);
auto *ptr = ob_malloc(2113);
auto *ptr = ob_malloc(2113, ObNewModIds::TEST);
std::cout << "alloc" << std::endl;
ASSERT_EQ(hold, 8192);
ob_free(ptr);
@ -52,7 +52,7 @@ TEST_F(TestObMallocCallbackGuard, AllocAndFree)
int64_t hold2 = 0;
MallocCallback cb(hold2);
ObMallocCallbackGuard guard(cb);
auto *ptr = ob_malloc(2113);
auto *ptr = ob_malloc(2113, ObNewModIds::TEST);
ASSERT_EQ(hold, 8192);
ASSERT_EQ(hold2, 8192);
std::cout << "alloc" << std::endl;
@ -61,7 +61,7 @@ TEST_F(TestObMallocCallbackGuard, AllocAndFree)
ASSERT_EQ(hold2, 0);
std::cout << "free" << std::endl << std::endl;
}
ptr = ob_malloc(2113);
ptr = ob_malloc(2113, ObNewModIds::TEST);
ASSERT_EQ(hold, 8192);
std::cout << "alloc" << std::endl;
ob_free(ptr);

View File

@ -42,7 +42,7 @@ public:
// p = obj->data_;
// }
// return p;
return oceanbase::common::ob_malloc(size);
return oceanbase::common::ob_malloc(size, ObNewModIds::TEST);
}
void Free(void *ptr)
@ -66,22 +66,9 @@ TEST_F(TestObjectMgr, Basic2)
while (cnt--) {
int i = 0;
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
p[i++] = ob_malloc(sz);
for (int j = 0; j < 16; ++j) {
p[i++] = ob_malloc(sz, ObNewModIds::TEST);
}
while (i--) {
ob_free(p[i]);
}

View File

@ -32,6 +32,7 @@ const int64_t init_size = 0;
int64_t glibc_alloc_count = 0;
int64_t glibc_free_count = 0;
const ObMemAttr default_memattr(OB_SERVER_TENANT_ID, ObNewModIds::TEST);
#define MOCK_ALIGN 512
#define MOCK_ALLOC_ALIGN 1
@ -978,7 +979,7 @@ TEST(TestFIFO, init_idle_max)
MockAllocator mock_allocator;
ObFIFOAllocator fa;
// invalid arg
ASSERT_NE(OB_SUCCESS, fa.init(&mock_allocator, 0));
ASSERT_NE(OB_SUCCESS, fa.init(&mock_allocator, 0, default_memattr));
ASSERT_NE(OB_SUCCESS, fa.init(&mock_allocator, page_size, default_memattr, -1));
ASSERT_NE(OB_SUCCESS, fa.init(&mock_allocator, page_size, default_memattr, 0, -1));
ASSERT_NE(OB_SUCCESS, fa.init(&mock_allocator, page_size, default_memattr, 0, 0, -1));

View File

@ -22,12 +22,12 @@ struct MyPageAllocator: public ObIAllocator
{
UNUSED(attr);
alloc_count_++;
return ob_malloc(sz);
return ob_malloc(sz, ObNewModIds::TEST);
}
void *alloc(const int64_t sz)
{
alloc_count_++;
return ob_malloc(sz);
return ob_malloc(sz, ObNewModIds::TEST);
}
void free(void *p)
{

View File

@ -42,7 +42,7 @@ public:
struct ObMallocWrapper: public AllocInterface
{
public:
void* alloc() { return common::ob_malloc(ISIZE); }
void* alloc() { return common::ob_malloc(ISIZE, ObNewModIds::TEST); }
void free(void* p) { common::ob_free(p); }
};

View File

@ -196,7 +196,7 @@ TEST(TestObIteratableHashSet, hash_full)
{
const uint64_t N = 10000;
typedef ObIteratableHashSet<int64_t, N> HashSetType;
HashSetType *hashset = (HashSetType *)ob_malloc(sizeof(HashSetType));
HashSetType *hashset = (HashSetType *)ob_malloc(sizeof(HashSetType), ObNewModIds::TEST);
ASSERT_TRUE(NULL != hashset);
new(hashset) HashSetType();
ASSERT_TRUE(NULL != hashset);

View File

@ -57,7 +57,7 @@ TEST_F(TestObDList, encode_decode)
ASSERT_TRUE(list.add_last(&node2));
int64_t buf_size = get_dlist_serialize_size(list);
char *buf = static_cast<char*>(ob_malloc(buf_size));
char *buf = static_cast<char*>(ob_malloc(buf_size, ObNewModIds::TEST));
int64_t buf_len = buf_size;
int64_t pos = 0;
ASSERT_EQ(OB_SUCCESS, serialize_dlist(list, buf, buf_len, pos));

View File

@ -71,6 +71,7 @@ TEST_F(TestContext, Basic)
int64_t used = g_pm.used_;
ASSERT_EQ(0, used);
void *ptr = nullptr;
ObMemAttr attr(OB_SERVER_TENANT_ID, ObNewModIds::TEST);
WITH_CONTEXT(mem_context) {
ptr = ctxalp(100);
ASSERT_NE(ptr, nullptr);
@ -103,7 +104,7 @@ TEST_F(TestContext, Basic)
for (int i = 0; i < 64; ++i) {
ptr = ctxalp(1024);
ASSERT_NE(ptr, nullptr);
ptr = ctxalf(100);
ptr = ctxalf(100, attr);
ASSERT_NE(ptr, nullptr);
ObArenaAllocator &arena_alloc = CURRENT_CONTEXT->get_arena_allocator();
ptr = arena_alloc.alloc(1024);
@ -125,8 +126,8 @@ TEST_F(TestContext, Basic)
{
// In order to allow the object_set inside current_ctx to allocate free_list in advance
// Don't let the memory occupied by free_list affect subsequent verification
ctxalf(8192 - 1000);
ptr = ctxalf(2000);
ctxalf(8192 - 1000, attr);
ptr = ctxalf(2000, attr);
ASSERT_NE(ptr, nullptr);
ctxfree(ptr);
}

View File

@ -96,7 +96,7 @@ TEST(print_utility, to_cstring)
const int size = 1300;
const int number = 10;
char data[size * number];
char *buffer = (char*)ob_malloc(sizeof(MyTuple) * number);
char *buffer = (char*)ob_malloc(sizeof(MyTuple) * number, ObNewModIds::TEST);
MyTuple *tuples[number];
for (int n = 0; n < number; ++n) {
memset(&data[n * size], 'a' + n, size - 1);

View File

@ -766,7 +766,7 @@ int ObSimpleLogClusterTestEnv::submit_log_impl(PalfHandleImplGuard &leader,
PalfAppendOptions opts;
ObRole role;
while (buf == NULL) {
buf = static_cast<char *>(ob_malloc(buf_len));
buf = static_cast<char *>(ob_malloc(buf_len, ObNewModIds::TEST));
}
bool state;
if (OB_FAIL(generate_data(buf, buf_len, real_log_data_size, data_len))) {

View File

@ -433,7 +433,8 @@ TEST_F(TestObSimpleLogClusterBasicFunc, data_corrupted)
LSN lsn;
EXPECT_EQ(OB_SUCCESS, iterator.next());
EXPECT_EQ(OB_SUCCESS, iterator.get_entry(entry, lsn));
char *buf = static_cast<char*>(ob_malloc_align(LOG_DIO_ALIGN_SIZE, MAX_LOG_BUFFER_SIZE));
char *buf = static_cast<char*>(ob_malloc_align(LOG_DIO_ALIGN_SIZE, MAX_LOG_BUFFER_SIZE,
ObMemAttr(OB_SERVER_TENANT_ID, ObNewModIds::TEST)));
int64_t pos = 0;
LogWriteBuf write_buf;
write_buf.push_back(buf, MAX_LOG_BUFFER_SIZE);

View File

@ -969,7 +969,8 @@ TEST_F(TestIndexTree, test_merge_info_build_row)
// test deep_copy of macro_meta with given allocator
ObArenaAllocator arena_allocator;
ObFIFOAllocator safe_allocator;
OK(safe_allocator.init(&arena_allocator, OB_MALLOC_BIG_BLOCK_SIZE));
OK(safe_allocator.init(&arena_allocator, OB_MALLOC_BIG_BLOCK_SIZE,
ObMemAttr(OB_SERVER_TENANT_ID, ObNewModIds::TEST)));
ObDataMacroBlockMeta *copy_meta = nullptr;
ObDataMacroBlockMeta &large_meta = *merge_info_list->at(0);
int64_t test_col_cnt = 100;

View File

@ -265,7 +265,7 @@ TEST_F(TestLSTabletService, test_serialize_tablet)
int64_t tablet_length = orig_tablet->get_serialize_size();
int64_t pos = 0;
char *buf = static_cast<char *>(ob_malloc(tablet_length));
char *buf = static_cast<char *>(ob_malloc(tablet_length, ObNewModIds::TEST));
ret = orig_tablet->serialize(buf, tablet_length, pos);
ASSERT_EQ(OB_SUCCESS, ret);
@ -294,7 +294,7 @@ TEST_F(TestLSTabletService, test_serialize_linked_list_tablet)
// serialize and deserialize linked list
int64_t tablets_length = tablet_head->get_serialize_size();
int64_t se_pos = 0;
char *buf = static_cast<char *>(ob_malloc(tablets_length));
char *buf = static_cast<char *>(ob_malloc(tablets_length, ObNewModIds::TEST));
ret = tablet_head->serialize(buf, tablets_length, se_pos);
ASSERT_EQ(OB_SUCCESS, ret);
@ -335,7 +335,7 @@ TEST_F(TestLSTabletService, test_deserialize_tablet_with_allocator)
// serialize and deserialize linked list
int64_t tablets_length = tablet_head->get_serialize_size();
int64_t se_pos = 0;
char *buf = static_cast<char *>(ob_malloc(tablets_length));
char *buf = static_cast<char *>(ob_malloc(tablets_length, ObNewModIds::TEST));
ret = tablet_head->serialize(buf, tablets_length, se_pos);
ASSERT_EQ(OB_SUCCESS, ret);

View File

@ -104,7 +104,7 @@ static ObFIFOAllocator &get_global_allocator()
{
static ObFIFOAllocator allocator;
if (OB_UNLIKELY(!allocator.is_inited())) {
IGNORE_RETURN allocator.init(&LuaAllocator::get_instance(), (1 << 13) - 8, default_memattr, 0, 0, INT64_MAX);
IGNORE_RETURN allocator.init(&LuaAllocator::get_instance(), (1 << 13) - 8, lib::ObMemAttr(OB_SERVER_TENANT_ID, "LuaAlloc"), 0, 0, INT64_MAX);
}
return allocator;
}

View File

@ -44,7 +44,7 @@ public:
ObConcurrentSeqQueue();
~ObConcurrentSeqQueue();
public:
int init(const int64_t queue_size, const ObMemAttr &memattr = default_memattr);
int init(const int64_t queue_size, const ObMemAttr &memattr);
/// @retval OB_SUCCESS success
/// @retval OB_TIMEOUT timeout
/// @retval other value fail

View File

@ -289,7 +289,7 @@ int ObLogMetaDataService::read_meta_info_in_archive_log_(
int64_t data_size = 0;
share::SCN start_scn;
if (OB_ISNULL(data_dict_in_log_info_buffer = static_cast<char*>(ob_malloc(buffer_size)))) {
if (OB_ISNULL(data_dict_in_log_info_buffer = static_cast<char*>(ob_malloc(buffer_size, "DataDictMetaInf")))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc buffer for datadict metainfo failed", KR(ret), K(buffer_size));
} else if (OB_FAIL(archive_dest.set(archive_dest_str))) {

View File

@ -448,8 +448,8 @@ ObLogMetaManager::MetaInfo<Type>::MetaInfo() :
base_allocator_(common::ObModIds::OB_LOG_META_INFO),
fifo_allocator_()
{
fifo_allocator_.init(&base_allocator_, common::OB_MALLOC_NORMAL_BLOCK_SIZE);
fifo_allocator_.set_label(common::ObModIds::OB_LOG_META_INFO);
fifo_allocator_.init(&base_allocator_, common::OB_MALLOC_NORMAL_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, common::ObModIds::OB_LOG_META_INFO));
}
template <class Type>

View File

@ -58,7 +58,7 @@ public:
public:
int init(const int64_t thread_num,
const int64_t queue_size,
const ObMemAttr &memattr = default_memattr);
const ObMemAttr &memattr);
void destroy();
public:

View File

@ -256,7 +256,7 @@ int LogIOWorker::BatchLogIOFlushLogTaskMgr::init(int64_t batch_width,
PALF_LOG(ERROR, "batch_io_task_array_ init failed", K(ret));
} else {
for (int i = 0; i < batch_width && OB_SUCC(ret); i++) {
char *ptr = reinterpret_cast<char*>(mtl_malloc(sizeof(BatchLogIOFlushLogTask)));
char *ptr = reinterpret_cast<char*>(mtl_malloc(sizeof(BatchLogIOFlushLogTask), "LogIOTask"));
BatchLogIOFlushLogTask *io_task = NULL;
if (NULL == ptr) {
ret = OB_ALLOCATE_MEMORY_FAILED;

View File

@ -4039,7 +4039,7 @@ int PalfHandleImpl::read_and_append_log_group_entry_before_ts_(
} else if (FALSE_IT(last_log_buf_len = curr_group_entry.get_group_entry_size())
|| FALSE_IT(last_log_start_lsn = curr_log_lsn)) {
} else if (NULL ==
(last_log_buf = static_cast<char*>(ob_malloc(last_log_buf_len)))) {
(last_log_buf = static_cast<char*>(ob_malloc(last_log_buf_len, "PalfHandleImpl")))) {
tmp_ret = OB_ALLOCATE_MEMORY_FAILED;
PALF_LOG(WARN, "alloc memory for last_log_buf in flashback failed", K(ret));
} else if (OB_TMP_FAIL(curr_group_entry.serialize(last_log_buf, last_log_buf_len, pos))) {

View File

@ -131,7 +131,7 @@ int ObLayerPerf::do_clog_layer_perf()
palf::LSN lsn;
share::SCN zero, ts_ns;
LOG_INFO("perf layer append", KP(r_), KP(buf));
if (nullptr == (cb = static_cast<PerfLogCb*>(ob_malloc(sizeof(PerfLogCb))))) {
if (nullptr == (cb = static_cast<PerfLogCb*>(ob_malloc(sizeof(PerfLogCb), "PerfLogCb")))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_ERROR("allo mem", K(ret));
} else if (FALSE_IT(new (cb) PerfLogCb(r_))) {

View File

@ -1409,7 +1409,7 @@ int ObInnerSQLConnection::request_table_lock_(const uint64_t tenant_id,
char *tmp_str = nullptr;
int64_t pos = 0;
ObString sql;
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size())))) {
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size(), "LockTableReq")))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory for sql_str failed", K(ret), K(arg.get_serialize_size()));
} else if (OB_FAIL(arg.serialize(tmp_str, arg.get_serialize_size(), pos))) {
@ -1528,7 +1528,7 @@ int ObInnerSQLConnection::request_table_lock_(const uint64_t tenant_id,
arg.lock_mode_ = lock_mode;
arg.timeout_us_ = timeout_us;
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size())))) {
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size(), "LockTableReq")))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory for sql_str failed", K(ret), K(arg.get_serialize_size()));
} else if (OB_FAIL(arg.serialize(tmp_str, arg.get_serialize_size(), pos))) {
@ -1545,7 +1545,7 @@ int ObInnerSQLConnection::request_table_lock_(const uint64_t tenant_id,
arg.lock_mode_ = lock_mode;
arg.timeout_us_ = timeout_us;
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size())))) {
if (OB_ISNULL(tmp_str = static_cast<char *>(ob_malloc(arg.get_serialize_size(), "LockTableReq")))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory for sql_str failed", K(ret), K(arg.get_serialize_size()));
} else if (OB_FAIL(arg.serialize(tmp_str, arg.get_serialize_size(), pos))) {

View File

@ -51,7 +51,7 @@ public:
virtual void *alloc(const int64_t size, const ObMemAttr &attr) override;
virtual void *alloc(const int64_t size) override
{
return alloc(size, default_memattr);
return alloc(size, ObMemAttr(MTL_ID(), ObModIds::OB_PL_TEMP));
}
virtual void free(void *ptr) override { UNUSED(ptr); }
virtual void reset();

View File

@ -117,11 +117,11 @@ int ObBackupTaskSchedulerQueue::init(
LOG_WARN("invalid argument", K(ret), K(bucket_num), K(rpc_proxy), K(task_scheduler));
} else if (OB_FAIL(task_map_.create(bucket_num, OB_BACKUP_TASK_SCHEDULER))) {
LOG_WARN("fail to init task map", K(ret), K(bucket_num));
} else if (OB_FAIL(task_allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE))) {
} else if (OB_FAIL(task_allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, OB_BACKUP_TASK_SCHEDULER)))) {
LOG_WARN("fail to init task allocator", K(ret));
} else {
max_size_ = max_size;
task_allocator_.set_label(OB_BACKUP_TASK_SCHEDULER);
tenant_stat_map_ = &tenant_stat_map;
server_stat_map_ = &server_stat_map;
server_mgr_ = &server_manager;

View File

@ -184,7 +184,7 @@ public:
skip_change_member_list_(false),
generate_time_(common::ObTimeUtility::current_time()),
priority_(ObDRTaskPriority::MAX_PRI),
comment_(""),
comment_("DRTask"),
schedule_time_(0),
execute_time_(0),
task_id_() {}

View File

@ -117,10 +117,10 @@ int ObDRTaskQueue::init(
} else if (OB_FAIL(task_map_.create(bucket_num, "DRTaskQ"))) {
LOG_WARN("fail to create task map", KR(ret), K(bucket_num));
} else if (OB_FAIL(task_alloc_.init(
ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE))) {
ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, "DRTaskQ")))) {
LOG_WARN("fail to init task allocator", KR(ret));
} else {
task_alloc_.set_label("DRTaskQ");
config_ = &config;
rpc_proxy_ = rpc_proxy;
server_mgr_ = server_mgr;

View File

@ -59,7 +59,7 @@ ObLSReplicaTaskDisplayInfo::ObLSReplicaTaskDisplayInfo()
source_replica_type_(REPLICA_TYPE_FULL),
source_replica_paxos_replica_number_(OB_INVALID_COUNT),
execute_server_(),
comment_("")
comment_("LSReplicaTask")
{
}

View File

@ -35,11 +35,12 @@ public:
{
reset();
}
virtual void *alloc(const int64_t size) override
virtual void *alloc(const int64_t size, const ObMemAttr &attr) override
{
return alloc(size, default_memattr);
UNUSED(attr);
return alloc(size);
}
virtual void* alloc(const int64_t size, const ObMemAttr &attr) override
virtual void* alloc(const int64_t size) override
{
void *p = NULL;
if (size > MAX_RESERVE_SIZE - 1 - pos_) {

View File

@ -85,7 +85,7 @@ ObVirtualTenantManager::ObVirtualTenantManager()
: tenant_map_(NULL),
tenant_pool_(),
allocator_(ObModIds::OB_TENANT_INFO),
memattr_(default_memattr),
memattr_(OB_SERVER_TENANT_ID, ObModIds::OB_TENANT_INFO),
is_inited_(false)
{
}

View File

@ -605,7 +605,7 @@ inline ObTenantSwitchGuard _make_tenant_switch_guard()
for (share::ObTenantSwitchGuard g = share::_make_tenant_switch_guard(); g.loop_num_ == 0; g.loop_num_++) \
if (OB_SUCC(g.switch_to(tenant_id)))
inline void *mtl_malloc(int64_t nbyte, const common::ObMemAttr & attr = default_memattr)
inline void *mtl_malloc(int64_t nbyte, const common::ObMemAttr &attr)
{
common::ObMemAttr inner_attr = attr;
if (OB_SERVER_TENANT_ID == inner_attr.tenant_id_ &&
@ -627,7 +627,7 @@ inline ObTenantSwitchGuard _make_tenant_switch_guard()
return ob_free(ptr);
}
inline void *mtl_malloc_align(int64_t alignment, int64_t nbyte, const common::ObMemAttr & attr = default_memattr)
inline void *mtl_malloc_align(int64_t alignment, int64_t nbyte, const common::ObMemAttr &attr)
{
common::ObMemAttr inner_attr = attr;
if (OB_SERVER_TENANT_ID == inner_attr.tenant_id_ &&

View File

@ -1783,19 +1783,21 @@ public:
virtual void* alloc(const int64_t sz) override
{
return alloc(sz, common::default_memattr);
return NULL == allocator_ ? NULL : allocator_->alloc(sz);
}
virtual void* alloc(const int64_t sz, const common::ObMemAttr &attr) override
{
void *ret = NULL;
if (allocator_) {
ret = allocator_->alloc(sz, attr);
}
return ret;
return NULL == allocator_ ? NULL : allocator_->alloc(sz, attr);
}
virtual void free(void *p) override { allocator_->free(p); }
virtual void free(void *p) override
{
if (allocator_) {
allocator_->free(p);
p = NULL;
}
}
virtual ~ObSchemaAllocator() {};
private:
common::ObIAllocator *allocator_;

View File

@ -165,7 +165,7 @@ int ObDASTaskResultMgr::save_task_result(int64_t task_id,
bool added = false;
if (is_vectorized) {
void *buf = NULL;
if (OB_ISNULL(buf = ob_malloc(sizeof(ObChunkDatumStore::StoredRow *) * max_batch_size))) {
if (OB_ISNULL(buf = ob_malloc(sizeof(ObChunkDatumStore::StoredRow *) * max_batch_size, "DASTaskResMgr"))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc stored row array failed", KR(ret));
} else {
@ -177,7 +177,7 @@ int ObDASTaskResultMgr::save_task_result(int64_t task_id,
} else if (OB_FAIL(datum_store.init(4 * 1024 * 1024, // 4MB
MTL_ID(),
common::ObCtxIds::DEFAULT_CTX_ID,
"ObDASTaskResultMgr",
"DASTaskResMgr",
true))) {
LOG_WARN("init datum store failed", KR(ret));
} else if (OB_FAIL(datum_store.alloc_dir_id())) {
@ -374,7 +374,7 @@ int ObDASTaskResultMgr::iterator_task_result(int64_t task_id,
&& OB_FAIL(datum_store.init(INT64_MAX,
MTL_ID(),
common::ObCtxIds::DEFAULT_CTX_ID,
"ObDASTaskResultMgr",
"DASTaskResMgr",
false))) {
LOG_WARN("init datum store failed", KR(ret));
} else {

View File

@ -204,10 +204,10 @@ int ObDtlBufferInfoManager::ObDtlBufferInfoAllocator::init()
int ret = OB_SUCCESS;
if (OB_FAIL(allocator_.init(
lib::ObMallocAllocator::get_instance(),
OB_MALLOC_NORMAL_BLOCK_SIZE))) {
OB_MALLOC_NORMAL_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, "DTLBufAlloc")))) {
LOG_WARN("failed to init alocator", K(ret));
} else {
allocator_.set_label("DTLBufAlloc");
free_list_.reset();
}
return ret;
@ -360,10 +360,10 @@ int ObDtlLocalFirstBufferCacheManager::init()
int ret = OB_SUCCESS;
if (OB_FAIL(allocator_.init(
lib::ObMallocAllocator::get_instance(),
OB_MALLOC_NORMAL_BLOCK_SIZE))) {
OB_MALLOC_NORMAL_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, ObModIds::OB_SQL_DTL)))) {
LOG_WARN("failed to init allocator", K(ret));
} else {
allocator_.set_label(ObModIds::OB_SQL_DTL);
if (OB_FAIL(hash_table_.init(BUCKET_NUM, CONCURRENT_CNT))) {
LOG_WARN("failed to init hash table", K(ret));
} else if (OB_FAIL(buffer_info_mgr_.init())) {

View File

@ -337,10 +337,10 @@ int ObTenantSqlMemoryManager::mtl_init(ObTenantSqlMemoryManager *&sql_mem_mgr)
LOG_WARN("failed to alloc tenant sql memory manager", K(ret));
} else if (OB_FAIL(sql_mem_mgr->allocator_.init(
lib::ObMallocAllocator::get_instance(),
OB_MALLOC_NORMAL_BLOCK_SIZE))) {
OB_MALLOC_NORMAL_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, "SqlMemMgr")))) {
LOG_WARN("failed to init fifo allocator", K(ret));
} else {
sql_mem_mgr->allocator_.set_label("SqlMemMgr");
int64_t work_area_interval_size = sizeof(ObSqlWorkAreaInterval) * INTERVAL_NUM;
sql_mem_mgr->wa_intervals_ = reinterpret_cast<ObSqlWorkAreaInterval*>(
sql_mem_mgr->allocator_.alloc(work_area_interval_size));

View File

@ -269,7 +269,7 @@ ObBackupFileWriteCtx::ObBackupFileWriteCtx()
max_file_size_(0),
io_fd_(),
dev_handle_(NULL),
data_buffer_(),
data_buffer_("BackupCtx"),
bandwidth_throttle_(NULL)
{}
@ -399,6 +399,7 @@ ObBackupDataCtx::ObBackupDataCtx()
macro_index_buffer_node_(),
meta_index_buffer_node_(),
file_trailer_(),
tmp_buffer_("BackupCtx"),
bandwidth_throttle_(NULL)
{}

View File

@ -159,7 +159,7 @@ ObIBackupMultiLevelIndexBuilder::ObIBackupMultiLevelIndexBuilder()
root_(NULL),
write_ctx_(NULL),
allocator_(),
buffer_writer_()
buffer_writer_("BackupIndMerger")
{}
ObIBackupMultiLevelIndexBuilder::~ObIBackupMultiLevelIndexBuilder()
@ -479,7 +479,7 @@ int ObIBackupMultiLevelIndexBuilder::get_index_tree_height_(int64_t &height) con
int ObIBackupMultiLevelIndexBuilder::flush_trailer_()
{
int ret = OB_SUCCESS;
ObSelfBufferWriter buffer_writer;
ObSelfBufferWriter buffer_writer("BackupInd");
ObBackupMultiLevelIndexTrailer *trailer = NULL;
const int64_t trailer_len = sizeof(ObBackupMultiLevelIndexTrailer);
int64_t tree_height = 0;
@ -532,7 +532,7 @@ ObIBackupIndexMerger::ObIBackupIndexMerger()
: is_inited_(false),
merge_param_(),
offset_(),
buffer_writer_(),
buffer_writer_("BackupIndMerger"),
dev_handle_(NULL),
io_fd_(),
write_ctx_(),

View File

@ -479,7 +479,7 @@ ObITabletMetaBackupReader::~ObITabletMetaBackupReader()
/* ObTabletMetaBackupReader */
ObTabletMetaBackupReader::ObTabletMetaBackupReader() : ObITabletMetaBackupReader(), buffer_writer_()
ObTabletMetaBackupReader::ObTabletMetaBackupReader() : ObITabletMetaBackupReader(), buffer_writer_("BackupReader")
{}
ObTabletMetaBackupReader::~ObTabletMetaBackupReader()
@ -537,7 +537,7 @@ int ObTabletMetaBackupReader::get_meta_data(blocksstable::ObBufferReader &buffer
/* ObSSTableMetaBackupReader */
ObSSTableMetaBackupReader::ObSSTableMetaBackupReader() : ObITabletMetaBackupReader(), sstable_array_(), buffer_writer_()
ObSSTableMetaBackupReader::ObSSTableMetaBackupReader() : ObITabletMetaBackupReader(), sstable_array_(), buffer_writer_("BackupReader")
{}
ObSSTableMetaBackupReader::~ObSSTableMetaBackupReader()
@ -632,7 +632,7 @@ int ObSSTableMetaBackupReader::get_macro_block_id_list_(
/* ObTabletPhysicalIDMetaBackupReader */
ObTabletPhysicalIDMetaBackupReader::ObTabletPhysicalIDMetaBackupReader()
: is_inited_(false), ctx_(NULL), tablet_id_(), buffer_writer_()
: is_inited_(false), ctx_(NULL), tablet_id_(), buffer_writer_("BackupReader")
{}
ObTabletPhysicalIDMetaBackupReader::~ObTabletPhysicalIDMetaBackupReader()

View File

@ -112,7 +112,7 @@ ObBackupIndexBufferNode::ObBackupIndexBufferNode()
next_(NULL),
read_count_(0),
write_count_(0),
buffer_writer_()
buffer_writer_("BackupTmpFile")
{}
ObBackupIndexBufferNode::~ObBackupIndexBufferNode()

View File

@ -92,7 +92,7 @@ int ObMicroBlockEncoder::try_encoder(ObIColumnEncoder *&encoder, const int64_t c
}
ObMicroBlockEncoder::ObMicroBlockEncoder() : ctx_(), header_(NULL),
data_buffer_(0, blocksstable::OB_ENCODING_LABEL_DATA_BUFFER),
data_buffer_(blocksstable::OB_ENCODING_LABEL_DATA_BUFFER),
datum_rows_(), all_col_datums_(),
buffered_rows_checksum_(0), estimate_size_(0), estimate_size_limit_(0),
header_size_(0), expand_pct_(DEFAULT_ESTIMATE_REAL_SIZE_PCT),

View File

@ -52,9 +52,6 @@ public:
// int ObMacroBlockWriter::get_current_micro_block_buffer(const char *&buf, int64_t &size)
static const int64_t DEFAULT_DATA_BUFFER_SIZE = common::OB_DEFAULT_MACRO_BLOCK_SIZE;
// For rowkey_buffer_, length, must great than OB_MAX_ROW_KEY_LENGTH
static const int64_t DEFAULT_ROWKEY_BUFFER_SIZE = 20 * 1024;
struct CellCopyIndex
{
uint32_t index_;
@ -155,7 +152,6 @@ private:
ObMicroBlockEncodingCtx ctx_;
ObMicroBlockHeader *header_;
ObSelfBufferWriter data_buffer_;
ObSelfBufferWriter rowkey_buffer_;
ObConstDatumRowArray datum_rows_;
common::ObArray<ObColDatums *> all_col_datums_;
int64_t buffered_rows_checksum_;

View File

@ -24,7 +24,7 @@ namespace blocksstable
{
ObBloomFilterMicroBlockWriter::ObBloomFilterMicroBlockWriter()
: bf_micro_header_(NULL),
data_buffer_(0, ObModIds::OB_BF_DATA_WRITER, false),
data_buffer_(ObModIds::OB_BF_DATA_WRITER),
is_inited_(false)
{
}
@ -123,7 +123,7 @@ int ObBloomFilterMicroBlockWriter::write(const ObBloomFilterCacheValue &bf_cache
}
ObBloomFilterMacroBlockWriter::ObBloomFilterMacroBlockWriter()
: data_buffer_(0, ObModIds::OB_BF_DATA_WRITER, false),
: data_buffer_(ObModIds::OB_BF_DATA_WRITER),
bf_macro_header_(NULL),
common_header_(),
compressor_(),

View File

@ -23,7 +23,7 @@ namespace oceanbase
namespace blocksstable
{
ObSelfBufferWriter::ObSelfBufferWriter(
const int64_t size, const char *label, const bool need_align)
const char *label, const int64_t size, const bool need_align)
: ObBufferWriter(NULL, 0, 0), label_(label), is_aligned_(need_align),
macro_block_mem_ctx_()
{

View File

@ -349,8 +349,8 @@ public:
public:
ObSelfBufferWriter(
const char *label,
const int64_t size = 0,
const char *label = 0,
const bool need_align = false);
virtual ~ObSelfBufferWriter();
int ensure_space(const int64_t size);

View File

@ -372,8 +372,8 @@ ObMicroBlockCompressor::ObMicroBlockCompressor()
: is_none_(false),
micro_block_size_(0),
compressor_(NULL),
comp_buf_(0, "MicrBlocComp"),
decomp_buf_(0, "MicrBlocDecomp")
comp_buf_("MicrBlocComp"),
decomp_buf_("MicrBlocDecomp")
{
}
@ -478,7 +478,7 @@ int ObMicroBlockCompressor::decompress(const char *in, const int64_t in_size,
*/
ObMacroBlock::ObMacroBlock()
: spec_(NULL),
data_(0, "MacrBlocData"),
data_("MacrBlocData"),
macro_header_(),
data_base_offset_(0),
last_rowkey_(),

View File

@ -24,8 +24,8 @@ ObMicroBlockWriter::ObMicroBlockWriter()
:micro_block_size_limit_(0),
column_count_(0),
rowkey_column_count_(0),
data_buffer_(0, "MicrBlocWriter", false),
index_buffer_(0, "MicrBlocWriter", false),
data_buffer_("MicrBlocWriter"),
index_buffer_("MicrBlocWriter"),
col_desc_array_(nullptr),
need_calc_column_chksum_(false),
is_inited_(false)

View File

@ -336,7 +336,7 @@ int ObDirectLoadDataBlockWriter2::write_large_item(const ObDirectLoadExternalRow
int ret = OB_SUCCESS;
char *new_buf;
const int64_t align_buf_size = upper_align(new_buf_size, DIO_ALIGN_SIZE);
if (OB_ISNULL(new_buf = static_cast<char *>(ob_malloc(align_buf_size)))) {
if (OB_ISNULL(new_buf = static_cast<char *>(ob_malloc(align_buf_size, ObModIds::OB_SQL_LOAD_DATA)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate buffer", KR(ret), K(align_buf_size));
} else {

View File

@ -378,7 +378,7 @@ int ObDirectLoadSSTableScanner::read_buffer(uint64_t offset, uint64_t size)
int64_t read_size = size;
if (large_buf_ == nullptr) {
int64_t large_buf_size = OB_SERVER_BLOCK_MGR.get_macro_block_size();
if (OB_ISNULL(large_buf_ = static_cast<char *>(ob_malloc(large_buf_size)))) {
if (OB_ISNULL(large_buf_ = static_cast<char *>(ob_malloc(large_buf_size, ObModIds::OB_SQL_LOAD_DATA)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate buffer", KR(ret), K(large_buf_size));
}
@ -393,7 +393,7 @@ int ObDirectLoadSSTableScanner::read_buffer(uint64_t offset, uint64_t size)
int ObDirectLoadSSTableScanner::get_large_buffer(int64_t buf_size)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(large_buf_ = static_cast<char *>(ob_malloc(buf_size)))) {
if (OB_ISNULL(large_buf_ = static_cast<char *>(ob_malloc(buf_size, ObModIds::OB_SQL_LOAD_DATA)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate buffer", KR(ret), K(buf_size));
} else {

View File

@ -508,7 +508,7 @@ int ObCopyMacroBlockRestoreReader::get_next_macro_block(
/******************ObCopyMacroBlockHandle*********************/
ObCopyMacroBlockHandle::ObCopyMacroBlockHandle()
: is_reuse_macro_block_(false),
end_key_buf_(),
end_key_buf_("CMacBlockHandle"),
read_handle_()
{
}

View File

@ -244,7 +244,7 @@ int ObStorageHATabletsBuilder::get_tablet_info_restore_reader_(ObICopyTabletInfo
} else if (!param_.is_leader_restore_) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get tablet info restore reader get invalid argument", K(ret), K(param_));
} else if (FALSE_IT(buf = ob_malloc(sizeof(ObCopyTabletInfoRestoreReader)))) {
} else if (FALSE_IT(buf = ob_malloc(sizeof(ObCopyTabletInfoRestoreReader), "TabletReader"))) {
} else if (OB_ISNULL(buf)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to alloc memory", K(ret), KP(buf));
@ -470,7 +470,7 @@ int ObStorageHATabletsBuilder::get_tablets_sstable_restore_reader_(ObICopySSTabl
} else if (!param_.is_leader_restore_) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get tablets sstable restore reader get invalid argument", K(ret), K(param_));
} else if (FALSE_IT(buf = ob_malloc(sizeof(ObCopySSTableInfoRestoreReader)))) {
} else if (FALSE_IT(buf = ob_malloc(sizeof(ObCopySSTableInfoRestoreReader), "TabletReader"))) {
} else if (OB_ISNULL(buf)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to alloc memory", K(ret), KP(buf));

View File

@ -370,7 +370,8 @@ int ObTabletStreamPool::init(
} else if (max_free_list_num <= 0 || max_dynamic_node_num < 0) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("get invalid argument", K(ret), K(max_free_list_num), K(max_dynamic_node_num));
} else if (OB_FAIL(dynamic_allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_NORMAL_BLOCK_SIZE))) {
} else if (OB_FAIL(dynamic_allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_NORMAL_BLOCK_SIZE,
ObMemAttr(MTL_ID(), LABEL)))) {
LOG_WARN("failed to init fifo allocator", K(ret));
} else if (OB_FAIL(free_list_.init(max_free_list_num, &free_list_allocator_))) {
LOG_WARN("failed to init free list", K(ret), K(max_free_list_num));
@ -378,7 +379,6 @@ int ObTabletStreamPool::init(
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to allocate memory for stream node in free list", K(ret), K(max_free_list_num));
} else {
dynamic_allocator_.set_label(LABEL);
ObTabletStreamNode *node = nullptr;
for (int64_t i = 0; OB_SUCC(ret) && i < max_free_list_num; ++i) {
node = new (buf + i) ObTabletStreamNode(FIXED_ALLOC);

View File

@ -68,10 +68,10 @@ int ObLSRestoreHandler::init(ObLS *ls)
} else if (OB_ISNULL(ls)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("nullptr ls", K(ret));
} else if (OB_FAIL(allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE))) {
} else if (OB_FAIL(allocator_.init(ObMallocAllocator::get_instance(), OB_MALLOC_MIDDLE_BLOCK_SIZE,
ObMemAttr(common::OB_SERVER_TENANT_ID, OB_LS_RESTORE_HANDLER)))) {
LOG_WARN("fail to init allocator", K(ret));
} else {
allocator_.set_label(OB_LS_RESTORE_HANDLER);
ls_ = ls;
rebuild_seq_ = ls->get_rebuild_seq();
is_inited_ = true;

View File

@ -313,7 +313,7 @@ class ObOBJLockMap
public:
ObOBJLockMap() :
lock_map_(),
allocator_(),
allocator_("ObOBJLockMap"),
is_inited_(false)
{}
int init();

View File

@ -789,7 +789,7 @@ int ObTransDeadlockDetectorAdapter::autonomous_register_to_deadlock(const ObTran
ObSharedGuard<char> ptr;
ptr.assign((char*)"detector", [](char*){});
report_info.set_module_name(ptr);
char *buffer = (char *)ob_malloc(sizeof(char) * 64);
char *buffer = (char *)ob_malloc(sizeof(char) * 64, "DeadLockDA");
if (OB_NOT_NULL(buffer)) {
last_trans_id.to_string(buffer, 64);
buffer[63] = '\0';

View File

@ -1491,7 +1491,7 @@ inline int ObTransService::rollback_savepoint_slowpath_(ObTxDesc &tx,
ARRAY_FOREACH_NORET(parts, i) {
if (parts[i].epoch_ <= 0) {
int64_t len = tx.get_serialize_size() + sizeof(ObTxDesc);
char *buf = (char*)ob_malloc(len);
char *buf = (char*)ob_malloc(len, "TxDesc");
int64_t pos = sizeof(ObTxDesc);
if (OB_FAIL(tx.serialize(buf, len, pos))) {
TRANS_LOG(WARN, "serialize tx fail", KR(ret), K(tx));

View File

@ -95,7 +95,7 @@ OB_DEF_DESERIALIZE(ObTxRollbackSPMsg)
bool has_tx_ptr = false;
OB_UNIS_DECODE(has_tx_ptr);
if (has_tx_ptr) {
void *buffer = ob_malloc(sizeof(ObTxDesc));
void *buffer = ob_malloc(sizeof(ObTxDesc), "TxDesc");
if (OB_ISNULL(buffer)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {

View File

@ -32,7 +32,7 @@ TEST(ObDataDictMetaInfoItem, test_data_dict_meta_info_item)
const int64_t __MB__ = 1L << 20;
const int64_t item_cnt = 100;
const int64_t buf_size = 2 * __MB__;
char *buf = static_cast<char*>(ob_malloc(buf_size));
char *buf = static_cast<char*>(ob_malloc(buf_size, ObNewModIds::TEST));
int64_t pos = 0;
DataDictMetaInfoItemArr item_arr;
for (int64_t i = 0; i < item_cnt; i++) {
@ -54,7 +54,7 @@ TEST(ObDataDictMetaInfoHeader, test_data_dict_meta_info_header)
ObRandom random;
const int64_t __MB__ = 1L << 20;
const int64_t buf_size = 2 * __MB__;
char *buf = static_cast<char*>(ob_malloc(buf_size));
char *buf = static_cast<char*>(ob_malloc(buf_size, ObNewModIds::TEST));
header.magic_ = random.get_int32() && 0xFFFF;
header.meta_version_ = 1;
header.item_cnt_ = random.get_int32();
@ -118,7 +118,7 @@ TEST(ObDataDictMetaInfo, test_data_dict_meta_info)
EXPECT_EQ(meta_info_item_arr.at(i), item_arr.at(i));
}
char *new_buf = static_cast<char*>(ob_malloc(buffer_size));
char *new_buf = static_cast<char*>(ob_malloc(buffer_size, ObNewModIds::TEST));
int64_t new_ser_pos = 0;
EXPECT_EQ(OB_SUCCESS, meta_info.serialize(new_buf, buffer_size, new_ser_pos));
ObDataDictMetaInfo new_meta_info;

View File

@ -33,7 +33,7 @@ public:
virtual void SetUp()
{
ASSERT_EQ(0, queue_.init(1024));
ASSERT_EQ(0, queue_.init(1024, ObMemAttr(OB_SERVER_TENANT_ID, ObNewModIds::TEST)));
produce_seq_ = 0;
consume_seq_ = 0;
consume_thread_counter_ = 0;
@ -70,7 +70,7 @@ TEST_F(TestConSeqQueue, basic)
ObConcurrentSeqQueue queue;
void *data = 0;
EXPECT_EQ(0, queue.init(1024));
EXPECT_EQ(0, queue.init(1024, ObMemAttr(OB_SERVER_TENANT_ID, ObNewModIds::TEST)));
EXPECT_EQ(0, queue.push((void*)0, 0, 0));
EXPECT_EQ(0, queue.push((void*)1, 1, 0));

View File

@ -68,7 +68,7 @@ public:
void TestObLogDlist::generate_data(const int64_t count, Type *&datas)
{
datas = (Type *)ob_malloc(sizeof(Type) * count);
datas = (Type *)ob_malloc(sizeof(Type) * count, ObNewModIds::TEST);
OB_ASSERT(NULL != datas);
for (int64_t idx = 0; idx < count; idx++) {
new (datas + idx) Type();

View File

@ -159,7 +159,7 @@ TEST_F(TestObMapQueue, push_pop_test)
EXPECT_TRUE(map_queue.is_inited());
// malloc array
Type *array = (Type *)ob_malloc(sizeof(Type) * VALUE_COUNT);
Type *array = (Type *)ob_malloc(sizeof(Type) * VALUE_COUNT, ObNewModIds::TEST);
OB_ASSERT(NULL != array);
for (int64_t test_type = 0, test_cnt = 4; test_type < test_cnt; ++test_type) {
@ -344,7 +344,7 @@ TEST_F(TestObMapQueue, DISABLED_performance)
TestPopWorker pop_workers[POP_THREAD_NUM];
// malloc array
Type *array = (Type *)ob_malloc(sizeof(Type) * VALUE_COUNT);
Type *array = (Type *)ob_malloc(sizeof(Type) * VALUE_COUNT, ObNewModIds::TEST);
OB_ASSERT(NULL != array);
memset(array, 0, sizeof(Type) * VALUE_COUNT);

View File

@ -71,7 +71,7 @@ public:
void TestObMapQueueThread::generate_data(const int64_t count, Type *&datas)
{
datas = (Type *)ob_malloc(sizeof(Type) * count);
datas = (Type *)ob_malloc(sizeof(Type) * count, ObNewModIds::TEST);
OB_ASSERT(NULL != datas);
for (int64_t idx = 0; idx < count; idx++) {
datas[idx].reset(idx, idx % THREAD_NUM);

View File

@ -48,11 +48,12 @@ public:
TEST_F(TestSeqThread, basic)
{
CThread thread;
ObMemAttr attr(OB_SERVER_TENANT_ID, ObNewModIds::TEST);
// Parameter not legal
EXPECT_EQ(OB_INVALID_ARGUMENT, thread.init(257, 100));
EXPECT_EQ(OB_INVALID_ARGUMENT, thread.init(0, 0));
EXPECT_EQ(OB_INVALID_ARGUMENT, thread.init(257, 100, attr));
EXPECT_EQ(OB_INVALID_ARGUMENT, thread.init(0, 0, attr));
EXPECT_EQ(OB_SUCCESS, thread.init(256, 10000));
EXPECT_EQ(OB_SUCCESS, thread.init(256, 10000, attr));
EXPECT_EQ(OB_SUCCESS, thread.start());
for (int64_t index = 0; index < 1000; index++) {
EXPECT_EQ(OB_SUCCESS, thread.push((void*)(index + 1), index, 0));

View File

@ -102,7 +102,7 @@ void TestLogSlidingWindow::SetUp()
OB_ASSERT(FALSE);
}
alloc_mgr_ = new (buf) common::ObTenantMutilAllocator(tenant_id);
data_buf_ = (char*)ob_malloc(64 * 1024 * 1024);
data_buf_ = (char*)ob_malloc(64 * 1024 * 1024, attr);
// init MTL
ObTenantBase tbase(tenant_id);
ObTenantEnv::set_tenant(&tbase);
@ -949,7 +949,7 @@ TEST_F(TestLogSlidingWindow, test_append_disk_log)
// non-continous buf
group_header.reset();
write_buf.reset();
char *second_buf = (char *)ob_malloc(second_part_len);
char *second_buf = (char *)ob_malloc(second_part_len, ObNewModIds::TEST);
EXPECT_TRUE(NULL != second_buf);
memcpy(second_buf, data_buf_ + first_part_len, second_part_len);
EXPECT_EQ(OB_SUCCESS, write_buf.push_back(data_buf_, first_part_len));

View File

@ -325,7 +325,7 @@ public:
int ret = OB_SUCCESS;
const int64_t buf_size = sizeof(task);
void *ptr = NULL;
if (NULL == (ptr = ob_malloc(buf_size))) {
if (NULL == (ptr = ob_malloc(buf_size, ObNewModIds::TEST))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
COMMON_LOG(WARN, "ob_malloc failed", K(ret), K(buf_size));
} else {

View File

@ -153,7 +153,8 @@ public:
cout << "\n<<<<<<<<<<<<<<<<<<<<" << "start case" << case_num << ">>>>>>>>>>>>>>>>>>>>" << endl;
// do not use rpc, will core dump
// ASSERT_EQ(OB_SUCCESS, MTL(ObDeadLockDetectorMgr*)->init());
oceancase::unittest::MockDeadLockRpc *rpc = (oceancase::unittest::MockDeadLockRpc *)ob_malloc(sizeof(oceancase::unittest::MockDeadLockRpc));
oceancase::unittest::MockDeadLockRpc *rpc = (oceancase::unittest::MockDeadLockRpc *)ob_malloc(sizeof(oceancase::unittest::MockDeadLockRpc),
ObNewModIds::TEST);
rpc = new (rpc) oceancase::unittest::MockDeadLockRpc();
MTL(ObDeadLockDetectorMgr*)->rpc_ = rpc;

View File

@ -279,7 +279,8 @@ TEST_F(TestTenantResource, mtl_switch)
TEST_F(TestTenantResource, tenant_base_set)
{
transaction::ObTransService* trans_service = (transaction::ObTransService*)ob_malloc(sizeof(transaction::ObTransService));
transaction::ObTransService* trans_service = (transaction::ObTransService*)ob_malloc(sizeof(transaction::ObTransService),
ObNewModIds::TEST);
ObTenantBase tenant_base(1);
tenant_base.set(trans_service);
ObTenantEnv::set_tenant(&tenant_base);

View File

@ -148,7 +148,7 @@ TEST_F(TestParser, general_parser)
ObDataInFileStruct file_struct;
file_struct.field_term_str_ = "|";
void *temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE));
void *temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE, ObNewModIds::TEST));
ASSERT_TRUE(temp_buf != NULL);
ObLoadFileBuffer *buffer = new(temp_buf)ObLoadFileBuffer(OB_MALLOC_BIG_BLOCK_SIZE
- sizeof(ObLoadFileBuffer) - 1024);
@ -228,11 +228,11 @@ TEST_F(TestParser, general_parser_escape)
file_struct.field_enclosed_char_ = '"';
void *temp_buf = NULL;
temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE));
temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE, ObNewModIds::TEST));
ASSERT_TRUE(temp_buf != NULL);
ObLoadFileBuffer *buffer = new(temp_buf)ObLoadFileBuffer(OB_MALLOC_BIG_BLOCK_SIZE
- sizeof(ObLoadFileBuffer) - 1024);
temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE));
temp_buf = (ob_malloc(OB_MALLOC_BIG_BLOCK_SIZE, ObNewModIds::TEST));
ASSERT_TRUE(temp_buf != NULL);
ObLoadFileBuffer *escape = new(temp_buf)ObLoadFileBuffer(OB_MALLOC_BIG_BLOCK_SIZE
- sizeof(ObLoadFileBuffer) - 1024);

View File

@ -66,8 +66,8 @@ TEST_F(TestDataBuffer, test_ObSelfBufferWriter)
{
int ret = OB_SUCCESS;
int64_t big_size = 256L * 1024L * 1024L * 1024L * 1024L * 1024L;//256TB
ObSelfBufferWriter buf_align(4096, ObModIds::TEST, true);
ObSelfBufferWriter buf_not_align(0, ObModIds::TEST, false);
ObSelfBufferWriter buf_align(ObModIds::TEST, 4096, true);
ObSelfBufferWriter buf_not_align(ObModIds::TEST, 0, false);
ret = buf_align.ensure_space(ALIGNED_SIZE);
ASSERT_EQ(ret, OB_SUCCESS);

View File

@ -226,7 +226,7 @@ TEST_F(TestStorageLogRW, test_basic)
// test read multi-param normal-size log
for (int i = 0; i < 10; i++) {
disk_addr = param_arr.at(i).disk_addr_;
buf = ob_malloc(disk_addr.size_);
buf = ob_malloc(disk_addr.size_, ObNewModIds::TEST);
ret = ObStorageLogReader::read_log(slogger_->get_dir(), disk_addr, disk_addr.size_, buf, pos, OB_SERVER_TENANT_ID);
ASSERT_EQ(OB_SUCCESS, ret);
cmp = MEMCMP(slog_arr1[i].buf_, (char *)buf + pos, data_len[i]);
@ -273,7 +273,7 @@ TEST_F(TestStorageLogRW, test_basic)
// test read multi-param large-size log
for (int i = 0; i < 10; i++) {
disk_addr = param_arr2.at(i).disk_addr_;
buf = ob_malloc(disk_addr.size_);
buf = ob_malloc(disk_addr.size_, ObNewModIds::TEST);
ret = ObStorageLogReader::read_log(slogger2->get_dir(), disk_addr, disk_addr.size_, buf, pos, OB_SERVER_TENANT_ID);
ASSERT_EQ(OB_SUCCESS, ret);
cmp = MEMCMP(slog_arr2[i].buf_, (char *)buf + pos, data_len[i]);

View File

@ -1610,7 +1610,7 @@ int IOPerfRunner::init(const int64_t absolute_ts, const IOPerfLoad &load)
// prepare write buffer
if (OB_SUCC(ret) && ObIOMode::WRITE == load_.mode_ && nullptr == write_buf_) {
const int64_t buf_size = load_.size_ + DIO_READ_ALIGN_SIZE;
void *tmp_buf = ob_malloc(buf_size);
void *tmp_buf = ob_malloc(buf_size, ObNewModIds::TEST);
if (nullptr == tmp_buf) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("allocate memory failed", K(ret), K(buf_size));

View File

@ -540,7 +540,7 @@ int MockObServer::assign_resp_tx_state_(ObResp &resp, ObTxDesc *tx_desc, ObTxnFr
#define ENCODE_TX_STATE_(t) \
if (OB_SUCC(ret) && ctx.t##_changed_) { \
int64_t len = tx_node_.txn_free_route__get_##t##_state_serialize_size(tx_desc, ctx); \
char *buf = (char*)ob_malloc(len); \
char *buf = (char*)ob_malloc(len, ObMemAttr(OB_SERVER_TENANT_ID, ObNewModIds::TEST)); \
int64_t pos = 0; \
if (OB_FAIL(tx_node_.txn_free_route__serialize_##t##_state(session_.get_sessid(), tx_desc, ctx, buf, len, pos))) { \
TRANS_LOG(ERROR, "serialize fail", K(ret), K(tx_desc)); \

View File

@ -429,7 +429,7 @@ int ObTxNode::handle_msg_(MsgPack *pkt)
ObTxFreeRoutePushStateResp resp;
resp.ret_ = ret;
int64_t buf_len = resp.get_serialize_size();
char *buf = (char*)ob_malloc(buf_len);
char *buf = (char*)ob_malloc(buf_len, ObNewModIds::TEST);
int64_t pos = 0;
OZ(resp.serialize(buf, buf_len, pos));
pkt->resp_ = ObString(buf_len, buf);

View File

@ -86,7 +86,7 @@ public:
}
virtual int alloc_undo_status_node(ObUndoStatusNode *&undo_status_node) override
{
void *ptr = ob_malloc(TX_DATA_SLICE_SIZE);
void *ptr = ob_malloc(TX_DATA_SLICE_SIZE, ObNewModIds::TEST);
undo_status_node = new (ptr) ObUndoStatusNode();
return OB_SUCCESS;
}

View File

@ -108,7 +108,7 @@ public:
{
int ret = OB_SUCCESS;
int64_t size = msg.get_serialize_size() + 1 /*for msg category*/ + sizeof(int16_t) /* for tx_msg.type_ */;
char *buf = (char*)ob_malloc(size);
char *buf = (char*)ob_malloc(size, ObNewModIds::TEST);
buf[0] = 0; // 0 not callback msg
int64_t pos = 1;
int16_t msg_type = msg.type_;
@ -131,7 +131,7 @@ public:
{
int ret = OB_SUCCESS;
int64_t size = msg.get_serialize_size() + 1 /*for msg category*/ + sizeof(int16_t) /* for tx_msg.type_ */;
char *buf = (char*)ob_malloc(size);
char *buf = (char*)ob_malloc(size, ObNewModIds::TEST);
buf[0] = 0; // not callback msg
int64_t pos = 1;
int16_t msg_type = msg.type_;
@ -148,7 +148,7 @@ public:
{
int ret = OB_SUCCESS;
int64_t size = msg.get_serialize_size() + 1 + sizeof(int16_t);
char *buf = (char*)ob_malloc(size);
char *buf = (char*)ob_malloc(size, ObNewModIds::TEST);
buf[0] = 0; // not callback msg
int64_t pos = 1;
int16_t msg_type = TX_MSG_TYPE::TX_FREE_ROUTE_PUSH_STATE;
@ -180,7 +180,7 @@ int ObFakeTransRpc::send_msg_callback(const ObAddr &recv,
int ret = OB_SUCCESS;
TxMsgCallbackMsg rmsg(msg, addr_, rslt);
int64_t size = rmsg.get_serialize_size() + 1 /* for msg_category */;
char *buf = (char*)ob_malloc(size);
char *buf = (char*)ob_malloc(size, ObNewModIds::TEST);
buf[0] = 1;// callback
int64_t pos = 1;
OZ(rmsg.serialize(buf, size, pos));

View File

@ -441,7 +441,7 @@ TEST_F(TestObTxLog, test_compat_bytes)
K(fill_commit_info.get_serialize_size()));
ASSERT_EQ(true, fill_commit_info.is_dup_tx());
ASSERT_EQ(false, fill_commit_info.get_participants().empty());
void *tmp_buf = ob_malloc(1 * 1024 * 1024);
void *tmp_buf = ob_malloc(1 * 1024 * 1024, ObNewModIds::TEST);
int64_t pos = 0;
fill_commit_info.compat_bytes_.set_object_flag(2, false);
fill_commit_info.compat_bytes_.set_object_flag(5, false);