[Fix]manage the memory_usage of checksum_array in ObMacroBlockMeta
This commit is contained in:
@ -956,6 +956,25 @@ TEST_F(TestIndexTree, test_merge_info_build_row)
|
|||||||
ASSERT_EQ(info_val.column_checksums_[i], parsed_meta.val_.column_checksums_[i]);
|
ASSERT_EQ(info_val.column_checksums_[i], parsed_meta.val_.column_checksums_[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
ObDataMacroBlockMeta *copy_meta = nullptr;
|
||||||
|
ObDataMacroBlockMeta &large_meta = *merge_info_list->at(0);
|
||||||
|
int64_t test_col_cnt = 100;
|
||||||
|
for (int64_t i = 0; i < test_col_cnt; ++i) {
|
||||||
|
OK(large_meta.val_.column_checksums_.push_back(i));
|
||||||
|
}
|
||||||
|
ASSERT_EQ(safe_allocator.current_using_, nullptr);
|
||||||
|
ASSERT_EQ(safe_allocator.normal_used_, 0);
|
||||||
|
OK(large_meta.deep_copy(copy_meta, safe_allocator));
|
||||||
|
ASSERT_NE(safe_allocator.current_using_, nullptr);
|
||||||
|
safe_allocator.free(copy_meta);
|
||||||
|
copy_meta->~ObDataMacroBlockMeta();
|
||||||
|
const int64_t end_key_deep_copy_size = 64; // due to end_key::reset by memset
|
||||||
|
ASSERT_EQ(safe_allocator.normal_used_, end_key_deep_copy_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(TestIndexTree, test_meta_builder)
|
TEST_F(TestIndexTree, test_meta_builder)
|
||||||
|
|||||||
@ -48,13 +48,48 @@ ObDataBlockMetaVal::ObDataBlockMetaVal()
|
|||||||
snapshot_version_(0),
|
snapshot_version_(0),
|
||||||
logic_id_(),
|
logic_id_(),
|
||||||
macro_id_(),
|
macro_id_(),
|
||||||
column_checksums_(),
|
column_checksums_(common::OB_MALLOC_NORMAL_BLOCK_SIZE, ModulePageAllocator("MacroMetaChksum", MTL_ID())),
|
||||||
has_string_out_row_(false),
|
has_string_out_row_(false),
|
||||||
all_lob_in_row_(false)
|
all_lob_in_row_(false)
|
||||||
{
|
{
|
||||||
MEMSET(encrypt_key_, 0, share::OB_MAX_TABLESPACE_ENCRYPT_KEY_LENGTH);
|
MEMSET(encrypt_key_, 0, share::OB_MAX_TABLESPACE_ENCRYPT_KEY_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObDataBlockMetaVal::ObDataBlockMetaVal(ObIAllocator &allocator)
|
||||||
|
: version_(DATA_BLOCK_META_VAL_VERSION),
|
||||||
|
length_(0),
|
||||||
|
data_checksum_(0),
|
||||||
|
rowkey_count_(0),
|
||||||
|
column_count_(0),
|
||||||
|
micro_block_count_(0),
|
||||||
|
occupy_size_(0),
|
||||||
|
data_size_(0),
|
||||||
|
data_zsize_(0),
|
||||||
|
original_size_(0),
|
||||||
|
progressive_merge_round_(0),
|
||||||
|
block_offset_(0),
|
||||||
|
block_size_(0),
|
||||||
|
row_count_(0),
|
||||||
|
row_count_delta_(0),
|
||||||
|
max_merged_trans_version_(0),
|
||||||
|
is_encrypted_(false),
|
||||||
|
is_deleted_(false),
|
||||||
|
contain_uncommitted_row_(false),
|
||||||
|
is_last_row_last_flag_(false),
|
||||||
|
compressor_type_(ObCompressorType::INVALID_COMPRESSOR),
|
||||||
|
master_key_id_(0),
|
||||||
|
encrypt_id_(0),
|
||||||
|
row_store_type_(ObRowStoreType::MAX_ROW_STORE),
|
||||||
|
schema_version_(0),
|
||||||
|
snapshot_version_(0),
|
||||||
|
logic_id_(),
|
||||||
|
macro_id_(),
|
||||||
|
column_checksums_(common::OB_MALLOC_NORMAL_BLOCK_SIZE, ModulePageAllocator(allocator, "MacroMetaChksum")),
|
||||||
|
has_string_out_row_(false),
|
||||||
|
all_lob_in_row_(false)
|
||||||
|
{
|
||||||
|
MEMSET(encrypt_key_, 0, share::OB_MAX_TABLESPACE_ENCRYPT_KEY_LENGTH);
|
||||||
|
}
|
||||||
ObDataBlockMetaVal::~ObDataBlockMetaVal()
|
ObDataBlockMetaVal::~ObDataBlockMetaVal()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -361,6 +396,14 @@ ObDataMacroBlockMeta::ObDataMacroBlockMeta()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ObDataMacroBlockMeta::ObDataMacroBlockMeta(ObIAllocator &allocator)
|
||||||
|
: val_(allocator),
|
||||||
|
end_key_(),
|
||||||
|
nested_offset_(0),
|
||||||
|
nested_size_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ObDataMacroBlockMeta::~ObDataMacroBlockMeta()
|
ObDataMacroBlockMeta::~ObDataMacroBlockMeta()
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
@ -395,7 +438,7 @@ int ObDataMacroBlockMeta::deep_copy(ObDataMacroBlockMeta *&dst, ObIAllocator &al
|
|||||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||||
LOG_WARN("fail to allocate memory", K(ret), K(buf_len));
|
LOG_WARN("fail to allocate memory", K(ret), K(buf_len));
|
||||||
} else {
|
} else {
|
||||||
ObDataMacroBlockMeta *meta = new (buf) ObDataMacroBlockMeta();
|
ObDataMacroBlockMeta *meta = new (buf) ObDataMacroBlockMeta(allocator);
|
||||||
ObStorageDatum *endkey = new (buf + sizeof(ObDataMacroBlockMeta)) ObStorageDatum[rowkey_count];
|
ObStorageDatum *endkey = new (buf + sizeof(ObDataMacroBlockMeta)) ObStorageDatum[rowkey_count];
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < rowkey_count; ++i) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < rowkey_count; ++i) {
|
||||||
if (OB_FAIL(endkey[i].deep_copy(end_key_.datums_[i], allocator))) {
|
if (OB_FAIL(endkey[i].deep_copy(end_key_.datums_[i], allocator))) {
|
||||||
|
|||||||
@ -38,6 +38,7 @@ private:
|
|||||||
static const int32_t DATA_BLOCK_META_VAL_VERSION = 1;
|
static const int32_t DATA_BLOCK_META_VAL_VERSION = 1;
|
||||||
public:
|
public:
|
||||||
ObDataBlockMetaVal();
|
ObDataBlockMetaVal();
|
||||||
|
explicit ObDataBlockMetaVal(ObIAllocator &allocator);
|
||||||
~ObDataBlockMetaVal();
|
~ObDataBlockMetaVal();
|
||||||
void reset();
|
void reset();
|
||||||
bool is_valid() const;
|
bool is_valid() const;
|
||||||
@ -97,6 +98,7 @@ class ObDataMacroBlockMeta final
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ObDataMacroBlockMeta();
|
ObDataMacroBlockMeta();
|
||||||
|
explicit ObDataMacroBlockMeta(ObIAllocator &allocator);
|
||||||
~ObDataMacroBlockMeta();
|
~ObDataMacroBlockMeta();
|
||||||
int assign(const ObDataMacroBlockMeta &meta);
|
int assign(const ObDataMacroBlockMeta &meta);
|
||||||
int deep_copy(ObDataMacroBlockMeta *&dst, ObIAllocator &allocator) const;
|
int deep_copy(ObDataMacroBlockMeta *&dst, ObIAllocator &allocator) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user