empty addr semantic support for complex addr
This commit is contained in:
parent
5b22d0a0af
commit
09e955551a
@ -20,6 +20,7 @@ storage_dml_unittest(test_multi_version_sstable_single_get)
|
||||
#storage_dml_unittest(test_multi_version_sstable_merge) TODO(dengzhi.ldz): fix it
|
||||
storage_dml_unittest(test_medium_info_reader test_medium_info_reader.cpp)
|
||||
storage_dml_unittest(test_tablet_mds_data test_tablet_mds_data.cpp)
|
||||
storage_dml_unittest(test_mds_data_read_write test_mds_data_read_write.cpp)
|
||||
storage_unittest(test_physical_copy_task test_physical_copy_task.cpp)
|
||||
storage_unittest(test_shared_block_reader_writer)
|
||||
storage_dml_unittest(test_macro_ref_cnt test_macro_ref_cnt.cpp)
|
||||
|
488
mittest/mtlenv/storage/test_mds_data_read_write.cpp
Normal file
488
mittest/mtlenv/storage/test_mds_data_read_write.cpp
Normal file
@ -0,0 +1,488 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OceanBase
|
||||
* OceanBase CE is licensed under Mulan PubL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PubL v2.
|
||||
* You may obtain a copy of Mulan PubL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPubL-2.0
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define protected public
|
||||
#define private public
|
||||
|
||||
#include "lib/ob_errno.h"
|
||||
#include "lib/allocator/page_arena.h"
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "mtlenv/mock_tenant_module_env.h"
|
||||
#include "mtlenv/storage/medium_info_helper.h"
|
||||
#include "storage/tablet/ob_tablet_mds_data.h"
|
||||
#include "storage/tablet/ob_tablet_complex_addr.h"
|
||||
#include "storage/tablet/ob_tablet_obj_load_helper.h"
|
||||
#include "storage/slog_ckpt/ob_tenant_checkpoint_slog_handler.h"
|
||||
|
||||
#define USING_LOG_PREFIX STORAGE
|
||||
|
||||
using namespace oceanbase::common;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace storage
|
||||
{
|
||||
class TestMdsDataReadWrite : public::testing::Test
|
||||
{
|
||||
public:
|
||||
TestMdsDataReadWrite();
|
||||
virtual ~TestMdsDataReadWrite() = default;
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
//virtual void SetUp() override;
|
||||
//virtual void TearDown() override;
|
||||
private:
|
||||
static int mock_tablet_status_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int mock_empty_tablet_status_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int mock_auto_inc_seq_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int mock_empty_auto_inc_seq_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr);
|
||||
};
|
||||
|
||||
TestMdsDataReadWrite::TestMdsDataReadWrite()
|
||||
{
|
||||
}
|
||||
|
||||
void TestMdsDataReadWrite::SetUpTestCase()
|
||||
{
|
||||
EXPECT_EQ(OB_SUCCESS, MockTenantModuleEnv::get_instance().init());
|
||||
}
|
||||
|
||||
void TestMdsDataReadWrite::TearDownTestCase()
|
||||
{
|
||||
MockTenantModuleEnv::get_instance().destroy();
|
||||
}
|
||||
|
||||
int TestMdsDataReadWrite::mock_tablet_status_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
mds::MdsDumpKV kv;
|
||||
|
||||
{
|
||||
ObTabletCreateDeleteMdsUserData user_data;
|
||||
user_data.tablet_status_ = ObTabletStatus::NORMAL;
|
||||
const int64_t size = user_data.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
char *buf = static_cast<char*>(allocator.alloc(size));
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(user_data.serialize(buf, size, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret));
|
||||
} else {
|
||||
ObString &str = kv.v_.user_data_;
|
||||
str.assign(buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const int64_t size = kv.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
|
||||
char *buf = static_cast<char*>(allocator.alloc(size));
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(kv.serialize(buf, size, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret));
|
||||
} else {
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
write_info.buffer_ = buf;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
|
||||
ObSharedBlockWriteHandle handle;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_write(write_info, handle))) {
|
||||
LOG_WARN("failed to do async write", K(ret));
|
||||
} else if (OB_FAIL(handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret));
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != buf) {
|
||||
allocator.free(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestMdsDataReadWrite::mock_empty_tablet_status_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
mds::MdsDumpKV kv;
|
||||
const int64_t size = kv.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
|
||||
char *buf = static_cast<char*>(allocator.alloc(size));
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(kv.serialize(buf, size, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret));
|
||||
} else {
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
write_info.buffer_ = buf;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
|
||||
ObSharedBlockWriteHandle handle;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_write(write_info, handle))) {
|
||||
LOG_WARN("failed to do async write", K(ret));
|
||||
} else if (OB_FAIL(handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret));
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != buf) {
|
||||
allocator.free(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestMdsDataReadWrite::mock_auto_inc_seq_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
share::ObTabletAutoincSeq auto_inc_seq;
|
||||
|
||||
{
|
||||
if (OB_FAIL(auto_inc_seq.set_autoinc_seq_value(allocator, 100))) {
|
||||
LOG_WARN("failed to set auto inc seq", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
const int64_t size = auto_inc_seq.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
|
||||
char *buf = static_cast<char*>(allocator.alloc(size));
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(auto_inc_seq.serialize(buf, size, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret));
|
||||
} else {
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
write_info.buffer_ = buf;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
|
||||
ObSharedBlockWriteHandle handle;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_write(write_info, handle))) {
|
||||
LOG_WARN("failed to do async write", K(ret));
|
||||
} else if (OB_FAIL(handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret));
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != buf) {
|
||||
allocator.free(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int TestMdsDataReadWrite::mock_empty_auto_inc_seq_disk_addr(
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
share::ObTabletAutoincSeq auto_inc_seq;
|
||||
const int64_t size = auto_inc_seq.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
|
||||
char *buf = static_cast<char*>(allocator.alloc(size));
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(auto_inc_seq.serialize(buf, size, pos))) {
|
||||
LOG_WARN("failed to serialize", K(ret));
|
||||
} else {
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
write_info.buffer_ = buf;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
|
||||
ObSharedBlockWriteHandle handle;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_write(write_info, handle))) {
|
||||
LOG_WARN("failed to do async write", K(ret));
|
||||
} else if (OB_FAIL(handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret));
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != buf) {
|
||||
allocator.free(buf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TEST_F(TestMdsDataReadWrite, mds_dump_kv)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObArenaAllocator allocator;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> src_addr;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> dst_addr;
|
||||
|
||||
{
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_INVALID_ARGUMENT, ret);
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, src_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
src_addr.addr_.set_none_addr();
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
|
||||
ObMetaDiskAddr addr;
|
||||
ret = TestMdsDataReadWrite::mock_empty_tablet_status_disk_addr(allocator, addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(addr.is_block());
|
||||
src_addr.ptr_ = nullptr;
|
||||
src_addr.addr_ = addr;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
|
||||
ObMetaDiskAddr addr;
|
||||
ret = TestMdsDataReadWrite::mock_tablet_status_disk_addr(allocator, addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(addr.is_block());
|
||||
src_addr.ptr_ = nullptr;
|
||||
src_addr.addr_ = addr;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_memory_object());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestMdsDataReadWrite, auto_inc_seq)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObArenaAllocator allocator;
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> src_addr;
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> dst_addr;
|
||||
|
||||
{
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_INVALID_ARGUMENT, ret);
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, src_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
src_addr.addr_.set_none_addr();
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
|
||||
ObMetaDiskAddr addr;
|
||||
ret = TestMdsDataReadWrite::mock_empty_auto_inc_seq_disk_addr(allocator, addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(addr.is_block());
|
||||
src_addr.ptr_ = nullptr;
|
||||
src_addr.addr_ = addr;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
|
||||
ObMetaDiskAddr addr;
|
||||
ret = TestMdsDataReadWrite::mock_auto_inc_seq_disk_addr(allocator, addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(addr.is_block());
|
||||
src_addr.ptr_ = nullptr;
|
||||
src_addr.addr_ = addr;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_memory_object());
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(TestMdsDataReadWrite, medium_info_list)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObArenaAllocator allocator;
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> src_addr;
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> dst_addr;
|
||||
|
||||
{
|
||||
const int64_t finish_medium_scn = 0;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, 0, dst_addr);
|
||||
ASSERT_EQ(OB_INVALID_ARGUMENT, ret);
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, src_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = src_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
src_addr.addr_.set_none_addr();
|
||||
|
||||
const int64_t finish_medium_scn = 0;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, finish_medium_scn, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, src_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = src_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
src_addr.addr_.set_none_addr();
|
||||
|
||||
compaction::ObMediumCompactionInfo medium_info;
|
||||
ret = MediumInfoHelper::build_medium_compaction_info(allocator, medium_info, 100);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = src_addr.ptr_->append(medium_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
int64_t finish_medium_scn = 80;
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, finish_medium_scn, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_memory_object());
|
||||
|
||||
finish_medium_scn = 200;
|
||||
dst_addr.reset();
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, src_addr, finish_medium_scn, dst_addr);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
|
||||
{
|
||||
src_addr.reset();
|
||||
dst_addr.reset();
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, src_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = src_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
src_addr.addr_.set_none_addr();
|
||||
|
||||
compaction::ObMediumCompactionInfo medium_info;
|
||||
ret = MediumInfoHelper::build_medium_compaction_info(allocator, medium_info, 100);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = src_addr.ptr_->append(medium_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
ObTabletDumpedMediumInfo src_data;
|
||||
ret = src_data.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
medium_info.medium_snapshot_ = 120;
|
||||
ret = src_data.append(medium_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
compaction::ObExtraMediumInfo src_addr_extra_info;
|
||||
src_addr_extra_info.last_medium_scn_ = 10;
|
||||
compaction::ObExtraMediumInfo src_data_extra_info;
|
||||
src_data_extra_info.last_medium_scn_ = 20;
|
||||
compaction::ObExtraMediumInfo dst_extra_info;
|
||||
|
||||
int64_t finish_medium_scn = 80;
|
||||
ret = ObTabletMdsData::init_single_complex_addr_and_extra_info(allocator, src_addr, src_addr_extra_info,
|
||||
src_data, src_data_extra_info, finish_medium_scn, dst_addr, dst_extra_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_memory_object());
|
||||
ASSERT_EQ(2, dst_addr.ptr_->medium_info_list_.count());
|
||||
|
||||
finish_medium_scn = 110;
|
||||
ret = ObTabletMdsData::init_single_complex_addr_and_extra_info(allocator, src_addr, src_addr_extra_info,
|
||||
src_data, src_data_extra_info, finish_medium_scn, dst_addr, dst_extra_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_memory_object());
|
||||
ASSERT_EQ(1, dst_addr.ptr_->medium_info_list_.count());
|
||||
|
||||
finish_medium_scn = 130;
|
||||
ret = ObTabletMdsData::init_single_complex_addr_and_extra_info(allocator, src_addr, src_addr_extra_info,
|
||||
src_data, src_data_extra_info, finish_medium_scn, dst_addr, dst_extra_info);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_TRUE(dst_addr.is_none_object());
|
||||
}
|
||||
}
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
system("rm -f test_mds_data_read_write.log*");
|
||||
oceanbase::common::ObLogger::get_logger().set_log_level("INFO");
|
||||
OB_LOGGER.set_file_name("test_mds_data_read_write.log", true);
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@ -351,7 +351,13 @@ TEST_F(TestMediumInfoReader, pure_dump_data)
|
||||
|
||||
// insert data into tablet
|
||||
{
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *tablet->mds_data_.medium_info_list_.ptr_;
|
||||
common::ObIAllocator &allocator = *tablet_handle.get_allocator();
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_complex_addr = tablet->mds_data_.medium_info_list_;
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, medium_info_list_complex_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = medium_info_list_complex_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *medium_info_list_complex_addr.ptr_;
|
||||
|
||||
constexpr uint8_t table_id = mds::TupleTypeIdx<mds::MdsTableTypeTuple, mds::NormalMdsTable>::value;
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<compaction::ObMediumCompactionInfoKey, compaction::ObMediumCompactionInfo>>::value;
|
||||
@ -417,7 +423,13 @@ TEST_F(TestMediumInfoReader, mds_table_dump_data_overlap)
|
||||
|
||||
// insert data into mds data
|
||||
{
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *tablet->mds_data_.medium_info_list_.ptr_;
|
||||
common::ObIAllocator &allocator = *tablet_handle.get_allocator();
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_complex_addr = tablet->mds_data_.medium_info_list_;
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, medium_info_list_complex_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = medium_info_list_complex_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *medium_info_list_complex_addr.ptr_;
|
||||
|
||||
constexpr uint8_t table_id = mds::TupleTypeIdx<mds::MdsTableTypeTuple, mds::NormalMdsTable>::value;
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<compaction::ObMediumCompactionInfoKey, compaction::ObMediumCompactionInfo>>::value;
|
||||
@ -529,7 +541,13 @@ TEST_F(TestMediumInfoReader, mds_table_dump_data_no_overlap)
|
||||
|
||||
// insert data into mds data
|
||||
{
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *tablet->mds_data_.medium_info_list_.ptr_;
|
||||
common::ObIAllocator &allocator = *tablet_handle.get_allocator();
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_complex_addr = tablet->mds_data_.medium_info_list_;
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, medium_info_list_complex_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = medium_info_list_complex_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *medium_info_list_complex_addr.ptr_;
|
||||
|
||||
constexpr uint8_t table_id = mds::TupleTypeIdx<mds::MdsTableTypeTuple, mds::NormalMdsTable>::value;
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<compaction::ObMediumCompactionInfoKey, compaction::ObMediumCompactionInfo>>::value;
|
||||
@ -631,7 +649,13 @@ TEST_F(TestMediumInfoReader, mds_table_dump_data_full_inclusion)
|
||||
|
||||
// insert data into mds data
|
||||
{
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *tablet->mds_data_.medium_info_list_.ptr_;
|
||||
common::ObIAllocator &allocator = *tablet_handle.get_allocator();
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list_complex_addr = tablet->mds_data_.medium_info_list_;
|
||||
ret = ObTabletObjLoadHelper::alloc_and_new(allocator, medium_info_list_complex_addr.ptr_);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ret = medium_info_list_complex_addr.ptr_->init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletDumpedMediumInfo &medium_info_list = *medium_info_list_complex_addr.ptr_;
|
||||
|
||||
constexpr uint8_t table_id = mds::TupleTypeIdx<mds::MdsTableTypeTuple, mds::NormalMdsTable>::value;
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<compaction::ObMediumCompactionInfoKey, compaction::ObMediumCompactionInfo>>::value;
|
||||
|
@ -17,6 +17,7 @@
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace blocksstable;
|
||||
using namespace common;
|
||||
namespace storage
|
||||
{
|
||||
|
||||
|
@ -239,7 +239,7 @@ public:
|
||||
const ObSharedBlockWriteInfo &write_info,
|
||||
ObSharedBlockWriteHandle &block_handle);
|
||||
int async_batch_write(
|
||||
const ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
const common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
ObSharedBlockBatchHandle &block_handle);
|
||||
int async_link_write(
|
||||
const ObSharedBlockWriteInfo &write_infos,
|
||||
|
@ -18,7 +18,8 @@
|
||||
#include "logservice/ob_log_base_header.h"
|
||||
#include "storage/multi_data_source/mds_ctx.h"
|
||||
#include "storage/multi_data_source/mds_writer.h"
|
||||
#include "src/storage/tx/ob_trans_define.h"
|
||||
#include "storage/tx/ob_trans_define.h"
|
||||
#include "storage/tablet/ob_tablet_obj_load_helper.h"
|
||||
#include "storage/tablet/ob_tablet_service_clog_replay_executor.h"
|
||||
|
||||
namespace oceanbase
|
||||
@ -448,7 +449,7 @@ int ObMediumCompactionInfoList::init(
|
||||
int ObMediumCompactionInfoList::init(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObExtraMediumInfo &extra_medium_info,
|
||||
const ObTabletDumpedMediumInfo &medium_info_list)
|
||||
const ObTabletDumpedMediumInfo *medium_info_list)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -457,32 +458,30 @@ int ObMediumCompactionInfoList::init(
|
||||
LOG_WARN("init twice", K(ret));
|
||||
} else {
|
||||
allocator_ = &allocator;
|
||||
const common::ObIArray<ObMediumCompactionInfo*> &array = medium_info_list.medium_info_list_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
const ObMediumCompactionInfo *src_medium_info = array.at(i);
|
||||
if (OB_ISNULL(src_medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), K(i), KP(src_medium_info));
|
||||
} else {
|
||||
ObMediumCompactionInfo *medium_info = nullptr;
|
||||
void *buffer = allocator.alloc(sizeof(ObMediumCompactionInfo));
|
||||
if (OB_ISNULL(buffer)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to allocate memory", K(ret), "size", sizeof(ObMediumCompactionInfo));
|
||||
} else {
|
||||
medium_info = new (buffer) ObMediumCompactionInfo();
|
||||
if (OB_FAIL(medium_info->init(allocator, *src_medium_info))) {
|
||||
LOG_WARN("failed to copy medium info", K(ret), KPC(src_medium_info));
|
||||
} else if (OB_UNLIKELY(!medium_info_list_.add_last(medium_info))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to add last", K(ret), KPC(medium_info));
|
||||
}
|
||||
if (nullptr == medium_info_list) {
|
||||
// medium info is null, no need to copy
|
||||
} else {
|
||||
const common::ObIArray<ObMediumCompactionInfo*> &array = medium_info_list->medium_info_list_;
|
||||
ObMediumCompactionInfo *medium_info = nullptr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
medium_info = nullptr;
|
||||
const ObMediumCompactionInfo *src_medium_info = array.at(i);
|
||||
if (OB_ISNULL(src_medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), K(i), KP(src_medium_info));
|
||||
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, medium_info))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(medium_info->init(allocator, *src_medium_info))) {
|
||||
LOG_WARN("failed to copy medium info", K(ret), KPC(src_medium_info));
|
||||
} else if (OB_UNLIKELY(!medium_info_list_.add_last(medium_info))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("failed to add last", K(ret), KPC(medium_info));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
if (OB_NOT_NULL(medium_info)) {
|
||||
medium_info->~ObMediumCompactionInfo();
|
||||
allocator.free(medium_info);
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
if (OB_NOT_NULL(medium_info)) {
|
||||
medium_info->~ObMediumCompactionInfo();
|
||||
allocator.free(medium_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,8 @@ public:
|
||||
int init(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObExtraMediumInfo &extra_medium_info,
|
||||
const ObTabletDumpedMediumInfo &medium_info_list);
|
||||
const ObTabletDumpedMediumInfo *medium_info_list);
|
||||
|
||||
void reset();
|
||||
OB_INLINE bool is_empty() const { return 0 == medium_info_list_.get_size(); }
|
||||
OB_INLINE int64_t size() const { return medium_info_list_.get_size(); }
|
||||
|
@ -71,7 +71,6 @@ protected:// implemented by ObTablet
|
||||
virtual int get_mds_table_handle_(mds::MdsTableHandle &handle,
|
||||
const bool create_if_not_exist) const = 0;
|
||||
virtual ObTabletPointer *get_tablet_ponter_() const = 0;
|
||||
virtual int fetch_autoinc_seq(ObTabletMemberWrapper<share::ObTabletAutoincSeq> &wrapper) const = 0;
|
||||
template <typename T>
|
||||
int get_mds_data_from_tablet(const common::ObFunction<int(const T&)> &read_op) const;
|
||||
|
||||
|
@ -183,9 +183,8 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<ObTabletCreateDeleteM
|
||||
} else {
|
||||
if (CLICK_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, tablet_status_addr, kv))) {
|
||||
MDS_LOG_GET(WARN, "failed to load mds dump kv");
|
||||
} else if (OB_ISNULL(kv)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
MDS_LOG_GET(WARN, "unexpected error, mds dump kv is null");
|
||||
} else if (nullptr == kv) {
|
||||
ret = OB_EMPTY_RESULT;
|
||||
} else {
|
||||
const common::ObString &user_data = kv->v_.user_data_;
|
||||
int64_t pos = 0;
|
||||
@ -224,9 +223,8 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<ObTabletBindingMdsUse
|
||||
if (aux_tablet_info_addr.is_disk_object() && !aux_tablet_info_cache.is_valid()) {
|
||||
if (CLICK_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, aux_tablet_info_addr, kv))) {
|
||||
MDS_LOG_GET(WARN, "failed to load mds dump kv");
|
||||
} else if (OB_ISNULL(kv)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
MDS_LOG_GET(WARN, "unexpected error, mds dump kv is null");
|
||||
} else if (nullptr == kv) {
|
||||
ret = OB_EMPTY_RESULT;
|
||||
} else {
|
||||
const common::ObString &user_data = kv->v_.user_data_;
|
||||
int64_t pos = 0;
|
||||
@ -261,16 +259,18 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<share::ObTabletAutoin
|
||||
int ret = OB_SUCCESS;
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq_addr = get_mds_data_().auto_inc_seq_;
|
||||
const share::ObTabletAutoincSeq *auto_inc_seq = nullptr;
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> wrapper;
|
||||
ObArenaAllocator allocator("mds_reader");
|
||||
|
||||
if (CLICK_FAIL(ObTabletMdsData::fetch_auto_inc_seq(auto_inc_seq_addr, wrapper))) {
|
||||
MDS_LOG_GET(WARN, "failed to fetch auto inc seq");
|
||||
} else if (CLICK_FAIL(wrapper.get_member(auto_inc_seq))) {
|
||||
MDS_LOG_GET(WARN, "failed to get member");
|
||||
if (CLICK_FAIL(ObTabletMdsData::load_auto_inc_seq(allocator, auto_inc_seq_addr, auto_inc_seq))) {
|
||||
MDS_LOG_GET(WARN, "failed to load auto inc seq");
|
||||
} else if (nullptr == auto_inc_seq) {
|
||||
ret = OB_EMPTY_RESULT;
|
||||
} else if (CLICK_FAIL(read_op(*auto_inc_seq))) {
|
||||
MDS_LOG_GET(WARN, "failed to read_op");
|
||||
}
|
||||
|
||||
ObTabletMdsData::free_auto_inc_seq(allocator, auto_inc_seq);
|
||||
|
||||
return ret;
|
||||
#undef PRINT_WRAPPER
|
||||
}
|
||||
@ -680,17 +680,14 @@ int ObITabletMdsInterface::fill_virtual_info_by_complex_addr_(const ObTabletComp
|
||||
const mds::MdsDumpKV *dump_kv = nullptr;
|
||||
|
||||
if (CLICK_FAIL(mds_node_info_array.push_back(mds::MdsNodeInfoForVirtualTable()))) {
|
||||
MDS_LOG_GET(WARN, "fatil to push_back");
|
||||
MDS_LOG_GET(WARN, "fail to push_back");
|
||||
} else if (FALSE_IT(cur_virtual_info = &mds_node_info_array.at(mds_node_info_array.count() - 1))) {
|
||||
} else {
|
||||
if (CLICK_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, addr, dump_kv))) {
|
||||
MDS_LOG_GET(WARN, "fatil to read tablet_status_addr");
|
||||
} else if (!dump_kv->is_valid()) {
|
||||
} else if (nullptr == dump_kv || (nullptr != dump_kv && !dump_kv->is_valid())) {
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
MDS_LOG_GET(INFO, "dump kv not exist");
|
||||
if (OB_NOT_NULL(dump_kv)) {
|
||||
MDS_LOG_GET(INFO, "xuwang.txw debug", K(dump_kv->k_), K(dump_kv->v_));
|
||||
}
|
||||
} else if (CLICK_FAIL(obj_to_string_holder_(dump_kv->k_, cur_virtual_info->user_key_))) {
|
||||
MDS_LOG_GET(WARN, "fatil to fill string holder");
|
||||
} else if (CLICK_FAIL(dump_kv->v_.convert_to_user_mds_node(user_mds_node, get_tablet_meta_().ls_id_, get_tablet_meta_().tablet_id_))) {
|
||||
|
@ -239,24 +239,24 @@ int ObTablet::init_for_first_time_creation(
|
||||
ALLOC_AND_INIT(allocator, storage_schema_addr_, table_schema, compat_mode,
|
||||
true/*skip_column_info*/, ObStorageSchema::STORAGE_SCHEMA_VERSION_V2);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_FAIL(check_sstable_column_checksum())) {
|
||||
LOG_WARN("failed to check sstable column checksum", K(ret), KPC(this));
|
||||
} else if (OB_FAIL(build_read_info(allocator))) {
|
||||
LOG_WARN("failed to build read info", K(ret));
|
||||
} else if (OB_FAIL(mds_data_.init(allocator))) {
|
||||
LOG_WARN("failed to init mds data", K(ret));
|
||||
} else if (is_ls_inner_tablet() &&
|
||||
OB_FAIL(mds_data_.set_tablet_status(allocator_, ObTabletStatus::Status::NORMAL, ObTabletMdsUserDataType::CREATE_TABLET))) {
|
||||
LOG_WARN("failed to set normal status for ls inner tablet", K(ret));
|
||||
} else if (FALSE_IT(set_mem_addr())) {
|
||||
} else if (OB_FAIL(inner_inc_macro_ref_cnt())) {
|
||||
LOG_WARN("failed to increase macro ref cnt", K(ret));
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
LOG_INFO("succeeded to init tablet for first time creation", K(ret), KPC(sstable), K(*this));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(check_sstable_column_checksum())) {
|
||||
LOG_WARN("failed to check sstable column checksum", K(ret), KPC(this));
|
||||
} else if (OB_FAIL(build_read_info(allocator))) {
|
||||
LOG_WARN("failed to build read info", K(ret));
|
||||
} else if (!is_ls_inner_tablet() && OB_FAIL(mds_data_.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init mds data", K(ret));
|
||||
} else if (is_ls_inner_tablet() && OB_FAIL(mds_data_.init_with_tablet_status(allocator, ObTabletStatus::NORMAL, ObTabletMdsUserDataType::CREATE_TABLET))) {
|
||||
LOG_WARN("failed to init mds data for ls inner tablet", K(ret));
|
||||
} else if (FALSE_IT(set_mem_addr())) {
|
||||
} else if (OB_FAIL(inner_inc_macro_ref_cnt())) {
|
||||
LOG_WARN("failed to increase macro ref cnt", K(ret));
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
LOG_INFO("succeeded to init tablet for first time creation", K(ret), KPC(sstable), K(*this));
|
||||
}
|
||||
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
reset();
|
||||
}
|
||||
@ -331,7 +331,7 @@ int ObTablet::init_for_merge(
|
||||
LOG_WARN("failed to update table store flag", K(ret), K(param), K(table_store_addr_));
|
||||
} else if (OB_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
} else if (OB_FAIL(mds_data_.init(allocator, old_mds_data, finish_medium_scn, param.merge_type_))) {
|
||||
} else if (OB_FAIL(mds_data_.init_for_evict_medium_info(allocator, old_mds_data, finish_medium_scn, param.merge_type_))) {
|
||||
LOG_WARN("failed to init mds data", K(ret), K(old_mds_data), K(finish_medium_scn), "merge_type", param.merge_type_);
|
||||
} else if (OB_FAIL(build_read_info(allocator))) {
|
||||
LOG_WARN("failed to build read info", K(ret));
|
||||
@ -412,7 +412,7 @@ int ObTablet::init_for_mds_table_dump(
|
||||
LOG_WARN("fail to init table store", K(ret), KPC(old_table_store));
|
||||
} else if (CLICK_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
} else if (CLICK_FAIL(mds_data_.init(allocator, mds_table_data, base_data, finish_medium_scn))) {
|
||||
} else if (CLICK_FAIL(mds_data_.init_for_mds_table_dump(allocator, mds_table_data, base_data, finish_medium_scn))) {
|
||||
LOG_WARN("failed to init mds data", K(ret), K(finish_medium_scn));
|
||||
} else {
|
||||
ddl_kvs_ = ddl_kvs_addr;
|
||||
@ -496,7 +496,7 @@ int ObTablet::init_with_migrate_param(
|
||||
LOG_INFO("succeeded to init empty shell tablet", K(ret), K(param), KPC(this));
|
||||
}
|
||||
} else {
|
||||
if (OB_FAIL(mds_data_.init(*allocator_, param.mds_data_))) {
|
||||
if (OB_FAIL(mds_data_.init_by_full_memory_mds_data(*allocator_, param.mds_data_))) {
|
||||
LOG_WARN("failed to assign mds data", K(ret), K(param));
|
||||
} else if (OB_FAIL(pull_memtables(allocator, ddl_kvs_addr, ddl_kv_count))) {
|
||||
LOG_WARN("fail to pull memtable", K(ret));
|
||||
@ -580,7 +580,7 @@ int ObTablet::init_for_defragment(
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(mds_data_.init(allocator, old_mds_data, 0/*finish_medium_scn*/))) {
|
||||
} else if (OB_FAIL(mds_data_.init_for_evict_medium_info(allocator, old_mds_data, 0/*finish_medium_scn*/))) {
|
||||
LOG_WARN("failed to init mds data", K(ret), K(old_mds_data));
|
||||
} else if (OB_FAIL(build_read_info(*allocator_))) {
|
||||
LOG_WARN("fail to build read info", K(ret));
|
||||
@ -663,10 +663,10 @@ int ObTablet::init_for_sstable_replace(
|
||||
} else if (OB_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
} else if (nullptr != param.tablet_meta_
|
||||
&& OB_FAIL(mds_data_.init(allocator, old_tablet.mds_data_, param.tablet_meta_->mds_data_.medium_info_list_, finish_medium_scn))) {
|
||||
&& OB_FAIL(mds_data_.init_for_merge_with_full_mds_data(allocator, old_tablet.mds_data_, param.tablet_meta_->mds_data_.medium_info_list_, finish_medium_scn))) {
|
||||
LOG_WARN("failed to init mds data", K(ret), "mds_data", param.tablet_meta_->mds_data_, K(finish_medium_scn));
|
||||
} else if (nullptr == param.tablet_meta_
|
||||
&& OB_FAIL(mds_data_.init(allocator, old_tablet.mds_data_, finish_medium_scn))) {
|
||||
&& OB_FAIL(mds_data_.init_for_evict_medium_info(allocator, old_tablet.mds_data_, finish_medium_scn))) {
|
||||
LOG_WARN("failed to init mds data", K(ret), "mds_data", old_tablet.mds_data_, K(finish_medium_scn));
|
||||
} else if (OB_FAIL(build_read_info(*allocator_))) {
|
||||
LOG_WARN("failed to build read info", K(ret));
|
||||
@ -835,7 +835,7 @@ int ObTablet::read_medium_info_list(
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (OB_FAIL(fused_medium_info_list.init(allocator))) {
|
||||
} else if (OB_FAIL(fused_medium_info_list.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init medium info list", K(ret));
|
||||
} else if (OB_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
@ -850,7 +850,8 @@ int ObTablet::read_medium_info_list(
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_medium_info_list(allocator, complex_addr, base_medium_info_list))) {
|
||||
LOG_WARN("failed to load medium info list", K(ret));
|
||||
} else if (OB_FAIL(ObTabletMdsData::copy_medium_info_list(finish_medium_scn, *base_medium_info_list, fused_medium_info_list))) {
|
||||
} else if (nullptr != base_medium_info_list
|
||||
&& OB_FAIL(ObTabletMdsData::copy_medium_info_list(finish_medium_scn, *base_medium_info_list, fused_medium_info_list))) {
|
||||
LOG_WARN("failed to copy base medium info list", K(ret));
|
||||
} else if (OB_FAIL(ObTabletMdsData::copy_medium_info_list(finish_medium_scn, mds_table_medium_info_list, fused_medium_info_list))) {
|
||||
LOG_WARN("failed to copy mds table medium info list", K(ret));
|
||||
@ -858,7 +859,7 @@ int ObTablet::read_medium_info_list(
|
||||
compaction::ObMediumCompactionInfoList *tmp_list = nullptr;
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, tmp_list))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(tmp_list->init(allocator, mds_data_.extra_medium_info_, fused_medium_info_list))) {
|
||||
} else if (OB_FAIL(tmp_list->init(allocator, mds_data_.extra_medium_info_, &fused_medium_info_list))) {
|
||||
LOG_WARN("failed to init", K(ret));
|
||||
} else {
|
||||
medium_info_list = tmp_list;
|
||||
@ -1994,6 +1995,9 @@ void ObTablet::set_mem_addr()
|
||||
int ObTablet::check_meta_addr() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObLSID &ls_id = tablet_meta_.ls_id_;
|
||||
const common::ObTabletID &tablet_id = tablet_meta_.tablet_id_;
|
||||
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_uncommitted_kv_addr = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_committed_kv_addr = mds_data_.tablet_status_.committed_kv_;
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_uncommitted_kv_addr = mds_data_.aux_tablet_info_.uncommitted_kv_;
|
||||
@ -2008,7 +2012,7 @@ int ObTablet::check_meta_addr() const
|
||||
|| !aux_tablet_info_committed_kv_addr.is_valid()))
|
||||
{
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("meta addrs are invalid", K(ret), K(tablet_addr_), K(table_store_addr_.addr_),
|
||||
LOG_WARN("meta addrs are invalid", K(ret), K(ls_id), K(tablet_id), K(tablet_addr_), K(table_store_addr_.addr_),
|
||||
K(auto_inc_seq_addr.addr_), K(storage_schema_addr_.addr_), K(medium_info_list_addr.addr_),
|
||||
K(tablet_status_uncommitted_kv_addr.addr_), K(tablet_status_committed_kv_addr.addr_),
|
||||
K(aux_tablet_info_uncommitted_kv_addr.addr_), K(aux_tablet_info_committed_kv_addr.addr_));
|
||||
@ -2017,8 +2021,8 @@ int ObTablet::check_meta_addr() const
|
||||
&& ((tablet_addr_.is_block() ^ table_store_addr_.addr_.is_none())
|
||||
|| (tablet_addr_.is_block() ^ storage_schema_addr_.addr_.is_none()))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("meta addrs are inconsistent",
|
||||
K(ret), K(tablet_addr_), K(table_store_addr_.addr_), K(storage_schema_addr_.addr_));
|
||||
LOG_WARN("meta addrs are inconsistent", K(ret), K(ls_id), K(tablet_id),
|
||||
K(tablet_addr_), K(table_store_addr_.addr_), K(storage_schema_addr_.addr_));
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -4762,6 +4766,8 @@ int ObTablet::check_and_set_initial_state()
|
||||
int ObTablet::check_medium_list() const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObLSID &ls_id = tablet_meta_.ls_id_;
|
||||
const common::ObTabletID &tablet_id = tablet_meta_.tablet_id_;
|
||||
if (tablet_meta_.ha_status_.is_none()) {
|
||||
ObTabletMemberWrapper<ObTabletTableStore> table_store_wrapper;
|
||||
ObITable *last_major = nullptr;
|
||||
@ -4771,21 +4777,20 @@ int ObTablet::check_medium_list() const
|
||||
ObArenaAllocator arena_allocator("check_medium", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
|
||||
const ObTabletDumpedMediumInfo *dumped_list = nullptr;
|
||||
if (OB_FAIL(ObTabletMdsData::load_medium_info_list(arena_allocator, mds_data_.medium_info_list_, dumped_list))) {
|
||||
LOG_WARN("failed to load medium info list", K(ret), K(mds_data_));
|
||||
} else if (OB_ISNULL(dumped_list)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, list is null", K(ret), KP(dumped_list));
|
||||
LOG_WARN("failed to load medium info list", K(ret), K(ls_id), K(tablet_id), K(mds_data_));
|
||||
} else if (nullptr == dumped_list) {
|
||||
// do nothing
|
||||
LOG_INFO("skip check medium list for empty dumped medium info list", KR(ret), K(ls_id), K(tablet_id));
|
||||
} else if (OB_FAIL(ObMediumListChecker::validate_medium_info_list(
|
||||
mds_data_.extra_medium_info_,
|
||||
dumped_list->medium_info_list_,
|
||||
last_major->get_snapshot_version()))) {
|
||||
LOG_WARN("fail to validate medium info list", K(ret), K(mds_data_), KPC(dumped_list), KPC(last_major));
|
||||
LOG_WARN("fail to validate medium info list", K(ret), K(ls_id), K(tablet_id), K(mds_data_), KPC(dumped_list), KPC(last_major));
|
||||
}
|
||||
ObTabletMdsData::free_medium_info_list(arena_allocator, dumped_list);
|
||||
}
|
||||
} else {
|
||||
LOG_INFO("skip check medium list for non empty ha_status", KR(ret),
|
||||
"tablet_id", tablet_meta_.tablet_id_, K(tablet_meta_.ha_status_));
|
||||
LOG_INFO("skip check medium list for non empty ha_status", KR(ret), K(ls_id), K(tablet_id), "ha_status", tablet_meta_.ha_status_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -4979,7 +4984,7 @@ int ObTablet::build_transfer_tablet_param(
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
} else if (OB_FAIL(new_mds_data.init(mig_tablet_param.allocator_, mds_table_data, mds_data_, finish_medium_scn))) {
|
||||
} else if (OB_FAIL(new_mds_data.init_for_mds_table_dump(mig_tablet_param.allocator_, mds_table_data, mds_data_, finish_medium_scn))) {
|
||||
LOG_WARN("failed to init new mds data", K(ret), K(finish_medium_scn));
|
||||
} else if (OB_FAIL(build_transfer_in_tablet_status_(user_data, new_mds_data, mig_tablet_param.allocator_))) {
|
||||
LOG_WARN("failed to build transfer in tablet status", K(new_mds_data), K(mds_data_), KPC(this));
|
||||
@ -5149,11 +5154,17 @@ int ObTablet::build_transfer_in_tablet_status_(
|
||||
} else if (OB_FAIL(new_user_data.serialize(buffer, length, pos))) {
|
||||
LOG_WARN("failed to serialize user data", K(ret));
|
||||
} else {
|
||||
mds::MdsDumpKV *uncommitted_kv = mds_data.tablet_status_.uncommitted_kv_.ptr_;
|
||||
mds::MdsDumpKV *&uncommitted_kv = mds_data.tablet_status_.uncommitted_kv_.ptr_;
|
||||
const mds::MdsDumpKV *committed_kv = mds_data.tablet_status_.committed_kv_.ptr_;
|
||||
if (OB_ISNULL(uncommitted_kv) || OB_ISNULL(committed_kv)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("dump kv is null", K(ret), KP(uncommitted_kv), KP(committed_kv));
|
||||
if (nullptr == uncommitted_kv) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, uncommitted_kv))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (nullptr == committed_kv) {
|
||||
// do nothing, no need to copy
|
||||
} else if (OB_FAIL(uncommitted_kv->assign(*committed_kv, allocator))) {
|
||||
LOG_WARN("failed to copy committed kv to uncommitted kv", K(ret));
|
||||
} else {
|
||||
@ -5255,7 +5266,7 @@ int ObTablet::read_mds_table(common::ObIAllocator &allocator,
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (CLICK_FAIL(mds_data.init(allocator))) {
|
||||
} else if (CLICK_FAIL(mds_data.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init mds data", K(ret));
|
||||
} else if (CLICK_FAIL(inner_get_mds_table(mds_table_handle))) {
|
||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||
@ -5288,7 +5299,7 @@ int ObTablet::read_mds_table_medium_info_list(
|
||||
medium_info_list.reset();
|
||||
mds::MdsTableHandle mds_table_handle;
|
||||
|
||||
if (CLICK_FAIL(medium_info_list.init(allocator))) {
|
||||
if (CLICK_FAIL(medium_info_list.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init medium info list", K(ret));
|
||||
} else if (CLICK_FAIL(inner_get_mds_table(mds_table_handle))) {
|
||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||
@ -5668,10 +5679,7 @@ int ObTablet::load_medium_info_list(
|
||||
|
||||
if (OB_FAIL(ObTabletMdsData::load_medium_info_list(allocator, complex_addr, list))) {
|
||||
LOG_WARN("failed to load medium info list", K(ret), K(complex_addr));
|
||||
} else if (OB_ISNULL(list)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, list is null", K(ret), KP(list));
|
||||
} else if (OB_FAIL(medium_info_list.init(allocator, extra_info, *list))) {
|
||||
} else if (OB_FAIL(medium_info_list.init(allocator, extra_info, list))) {
|
||||
LOG_WARN("failed to init", K(ret));
|
||||
}
|
||||
|
||||
@ -5704,7 +5712,7 @@ int ObTablet::get_fused_medium_info_list(
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(get_finish_medium_scn(finish_medium_scn))) {
|
||||
LOG_WARN("failed to get finish medium scn", K(ret));
|
||||
} else if (OB_FAIL(new_mds_data.init(allocator, mds_table_data, mds_data_, finish_medium_scn))) {
|
||||
} else if (OB_FAIL(new_mds_data.init_for_mds_table_dump(allocator, mds_table_data, mds_data_, finish_medium_scn))) {
|
||||
LOG_WARN("failed to init new mds data", K(ret), K(finish_medium_scn));
|
||||
} else if (OB_FAIL(validate_medium_info_list(finish_medium_scn, new_mds_data))) {
|
||||
LOG_WARN("failed to validate medium info list", K(ret), K(finish_medium_scn));
|
||||
@ -5724,9 +5732,11 @@ int ObTablet::validate_medium_info_list(
|
||||
const ObTabletDumpedMediumInfo *medium_info_list = mds_data.medium_info_list_.ptr_;
|
||||
const ObExtraMediumInfo &extra_info = mds_data.extra_medium_info_;
|
||||
|
||||
if (OB_ISNULL(medium_info_list)) {
|
||||
if (mds_data.medium_info_list_.is_none_object()) {
|
||||
LOG_INFO("medium info list addr is none, no need to validate", K(ret), K(ls_id), K(tablet_id), K(finish_medium_scn), "medium_info_list_complex_addr", mds_data.medium_info_list_);
|
||||
} else if (OB_ISNULL(medium_info_list)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("medium info list is null", K(ret), K(mds_data), KP(medium_info_list));
|
||||
LOG_WARN("medium info list is null", K(ret), K(ls_id), K(tablet_id), K(finish_medium_scn), KP(medium_info_list));
|
||||
} else if (OB_FAIL(ObMediumListChecker::validate_medium_info_list(extra_info, medium_info_list->medium_info_list_, finish_medium_scn))) {
|
||||
LOG_WARN("failed to validate medium info list", KR(ret), K(ls_id), K(tablet_id), K(mds_data), K(finish_medium_scn));
|
||||
}
|
||||
@ -5866,20 +5876,25 @@ int ObTablet::get_auto_inc_seq_mds_dump_kv(
|
||||
mds::MdsDumpKV *&kv)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
kv = nullptr;
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &complex_addr = mds_data_.auto_inc_seq_;
|
||||
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (complex_addr.is_none_object()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, kv))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else {
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> wrapper;
|
||||
const share::ObTabletAutoincSeq *auto_inc_seq = nullptr;
|
||||
if (OB_FAIL(ObTabletMdsData::fetch_auto_inc_seq(complex_addr, wrapper))) {
|
||||
LOG_WARN("failed to fetch auto inc seq", K(ret));
|
||||
} else if (OB_FAIL(wrapper.get_member(auto_inc_seq))) {
|
||||
LOG_WARN("failed to get member", K(ret));
|
||||
if (OB_FAIL(ObTabletMdsData::load_auto_inc_seq(allocator, complex_addr, auto_inc_seq))) {
|
||||
LOG_WARN("failed to load auto inc seq", K(ret), K(complex_addr));
|
||||
} else if (nullptr == auto_inc_seq) {
|
||||
// do nothing
|
||||
if (nullptr != kv) {
|
||||
allocator.free(kv);
|
||||
}
|
||||
} else if (OB_FAIL(convert_to_mds_dump_kv(allocator, *auto_inc_seq, *kv))) {
|
||||
LOG_WARN("failed to convert to mds dump kv", K(ret));
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ class ObDDLKVHandle;
|
||||
class ObStorageSchema;
|
||||
class ObTabletTableIterator;
|
||||
class ObMetaDiskAddr;
|
||||
class ObTabletMdsDumpStruct;
|
||||
class ObTabletCreateDeleteMdsUserData;
|
||||
class ObTabletBindingMdsUserData;
|
||||
class ObMemtableArray;
|
||||
|
@ -53,7 +53,7 @@ void ObTabletDumpedMediumInfo::reset()
|
||||
is_inited_ = false;
|
||||
}
|
||||
|
||||
int ObTabletDumpedMediumInfo::init(common::ObIAllocator &allocator)
|
||||
int ObTabletDumpedMediumInfo::init_for_first_creation(common::ObIAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -69,6 +69,139 @@ int ObTabletDumpedMediumInfo::init(common::ObIAllocator &allocator)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletDumpedMediumInfo::init_for_evict_medium_info(
|
||||
common::ObIAllocator &allocator,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObTabletDumpedMediumInfo &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const common::ObIArray<compaction::ObMediumCompactionInfo*> &array = other.medium_info_list_;
|
||||
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret), K_(is_inited));
|
||||
} else {
|
||||
allocator_ = &allocator;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
const compaction::ObMediumCompactionInfo *src_info = array.at(i);
|
||||
if (OB_ISNULL(src_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), K(i), KP(src_info));
|
||||
} else if (src_info->medium_snapshot_ <= finish_medium_scn) {
|
||||
// medium snapshot no bigger than finish medium scn(which is from last major sstable),
|
||||
// no need to copy it
|
||||
} else if (src_info->medium_snapshot_ <= get_max_medium_snapshot()) {
|
||||
// medium info no bigger than current max medium snapshot,
|
||||
// no need to copy it
|
||||
} else if (OB_FAIL(do_append(*src_info))) {
|
||||
LOG_WARN("failed to append medium info", K(ret), K(i), KPC(src_info));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
reset();
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletDumpedMediumInfo::init_for_mds_table_dump(
|
||||
common::ObIAllocator &allocator,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObTabletDumpedMediumInfo &other1,
|
||||
const ObTabletDumpedMediumInfo &other2)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret), K_(is_inited));
|
||||
} else {
|
||||
allocator_ = &allocator;
|
||||
common::ObSEArray<compaction::ObMediumCompactionInfo*, 1> array1;
|
||||
common::ObSEArray<compaction::ObMediumCompactionInfo*, 1> array2;
|
||||
|
||||
if (OB_FAIL(array1.assign(other1.medium_info_list_))) {
|
||||
LOG_WARN("failed to assign", K(ret));
|
||||
} else if (OB_FAIL(array2.assign(other2.medium_info_list_))) {
|
||||
LOG_WARN("failed to assign", K(ret));
|
||||
} else {
|
||||
// sort first
|
||||
std::sort(array1.begin(), array1.end(), ObTabletDumpedMediumInfo::compare);
|
||||
std::sort(array2.begin(), array2.end(), ObTabletDumpedMediumInfo::compare);
|
||||
|
||||
// merge
|
||||
bool contain = false;
|
||||
int64_t i = 0;
|
||||
int64_t j = 0;
|
||||
while (OB_SUCC(ret) && i < array1.count() && j < array2.count()) {
|
||||
const compaction::ObMediumCompactionInfo *info1 = array1.at(i);
|
||||
const compaction::ObMediumCompactionInfo *info2 = array2.at(j);
|
||||
const compaction::ObMediumCompactionInfo *chosen_info = nullptr;
|
||||
|
||||
if (OB_ISNULL(info1) || OB_ISNULL(info2)) {
|
||||
LOG_WARN("medium info is null", K(ret), K(i), K(j), KP(info1), KP(info2));
|
||||
} else if (info1->medium_snapshot_ < info2->medium_snapshot_) {
|
||||
chosen_info = info1;
|
||||
++i;
|
||||
} else if (info1->medium_snapshot_ > info2->medium_snapshot_) {
|
||||
chosen_info = info2;
|
||||
++j;
|
||||
} else {
|
||||
chosen_info = info2;
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (chosen_info->medium_snapshot_ <= finish_medium_scn) {
|
||||
// medium snapshot no bigger than finish medium scn(which is from last major sstable),
|
||||
// no need to copy it
|
||||
} else if (chosen_info->medium_snapshot_ <= get_max_medium_snapshot()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(do_append(*chosen_info))) {
|
||||
LOG_WARN("failed to append medium info", K(ret), K(i), K(j), KPC(chosen_info));
|
||||
}
|
||||
}
|
||||
|
||||
for (; OB_SUCC(ret) && i < array1.count(); ++i) {
|
||||
const compaction::ObMediumCompactionInfo *info = array1.at(i);
|
||||
if (info->medium_snapshot_ <= finish_medium_scn) {
|
||||
// medium snapshot no bigger than finish medium scn(which is from last major sstable),
|
||||
// no need to copy it
|
||||
} else if (info->medium_snapshot_ <= get_max_medium_snapshot()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(do_append(*info))) {
|
||||
LOG_WARN("failed to append medium info", K(ret), K(i), KPC(info));
|
||||
}
|
||||
}
|
||||
|
||||
for (; OB_SUCC(ret) && j < array2.count(); ++j) {
|
||||
const compaction::ObMediumCompactionInfo *info = array2.at(j);
|
||||
if (info->medium_snapshot_ <= finish_medium_scn) {
|
||||
// medium snapshot no bigger than finish medium scn(which is from last major sstable),
|
||||
// no need to copy it
|
||||
} else if (info->medium_snapshot_ <= get_max_medium_snapshot()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(do_append(*info))) {
|
||||
LOG_WARN("failed to append medium info", K(ret), K(j), KPC(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
reset();
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletDumpedMediumInfo::assign(const ObTabletDumpedMediumInfo &other, common::ObIAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -152,7 +285,19 @@ int ObTabletDumpedMediumInfo::append(const compaction::ObMediumCompactionInfo &m
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(*allocator_, info))) {
|
||||
} else if (OB_FAIL(do_append(medium_info))) {
|
||||
LOG_WARN("failed to do append", K(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletDumpedMediumInfo::do_append(const compaction::ObMediumCompactionInfo &medium_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(*allocator_, info))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(info->assign(*allocator_, medium_info))) {
|
||||
LOG_WARN("failed to copy medium info", K(ret), K(medium_info));
|
||||
@ -202,7 +347,7 @@ int ObTabletDumpedMediumInfo::get_min_medium_info_key(compaction::ObMediumCompac
|
||||
} else {
|
||||
ObTabletDumpedMediumInfoIterator iter;
|
||||
ObArenaAllocator arena_allocator("iter");
|
||||
if (OB_FAIL(iter.init(arena_allocator, *this))) {
|
||||
if (OB_FAIL(iter.init(arena_allocator, this))) {
|
||||
LOG_WARN("failed to init", K(ret));
|
||||
} else {
|
||||
while (OB_SUCC(ret)) {
|
||||
@ -234,7 +379,7 @@ int ObTabletDumpedMediumInfo::get_max_medium_info_key(compaction::ObMediumCompac
|
||||
} else {
|
||||
ObTabletDumpedMediumInfoIterator iter;
|
||||
ObArenaAllocator arena_allocator("iter");
|
||||
if (OB_FAIL(iter.init(arena_allocator, *this))) {
|
||||
if (OB_FAIL(iter.init(arena_allocator, this))) {
|
||||
LOG_WARN("failed to init", K(ret));
|
||||
} else if (OB_FAIL(iter.get_next_key(key))) {
|
||||
LOG_WARN("failed to get next medium info", K(ret));
|
||||
@ -479,7 +624,7 @@ ObTabletDumpedMediumInfoIterator::~ObTabletDumpedMediumInfoIterator()
|
||||
|
||||
int ObTabletDumpedMediumInfoIterator::init(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo &dumped_medium_info)
|
||||
const ObTabletDumpedMediumInfo *dumped_medium_info)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -487,25 +632,30 @@ int ObTabletDumpedMediumInfoIterator::init(
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret), K_(is_inited));
|
||||
} else {
|
||||
const common::ObSEArray<compaction::ObMediumCompactionInfo*, 1> &array = dumped_medium_info.medium_info_list_;
|
||||
compaction::ObMediumCompactionInfo* info = nullptr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
compaction::ObMediumCompactionInfo* src_medium_info = array.at(i);
|
||||
info = nullptr;
|
||||
if (OB_ISNULL(src_medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, src medium info is null", K(ret), K(i), KP(src_medium_info));
|
||||
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, info))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(info->assign(allocator, *src_medium_info))) {
|
||||
LOG_WARN("failed to copy medium info", K(ret), KPC(src_medium_info));
|
||||
} else if (OB_FAIL(medium_info_list_.push_back(info))) {
|
||||
LOG_WARN("failed to push back to array", K(ret));
|
||||
}
|
||||
if (nullptr == dumped_medium_info) {
|
||||
// no need to copy medium info
|
||||
} else {
|
||||
const common::ObSEArray<compaction::ObMediumCompactionInfo*, 1> &array = dumped_medium_info->medium_info_list_;
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
info = nullptr;
|
||||
compaction::ObMediumCompactionInfo *src_medium_info = array.at(i);
|
||||
if (OB_ISNULL(src_medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, src medium info is null", K(ret), K(i), KP(src_medium_info));
|
||||
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, info))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(info->assign(allocator, *src_medium_info))) {
|
||||
LOG_WARN("failed to copy medium info", K(ret), KPC(src_medium_info));
|
||||
} else if (OB_FAIL(medium_info_list_.push_back(info))) {
|
||||
LOG_WARN("failed to push back to array", K(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
if (nullptr != info) {
|
||||
allocator.free(info);
|
||||
if (OB_FAIL(ret)) {
|
||||
if (nullptr != info) {
|
||||
info->compaction::ObMediumCompactionInfo::~ObMediumCompactionInfo();
|
||||
allocator.free(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,16 @@ public:
|
||||
ObTabletDumpedMediumInfo(const ObTabletDumpedMediumInfo &) = delete;
|
||||
ObTabletDumpedMediumInfo &operator=(const ObTabletDumpedMediumInfo &) = delete;
|
||||
public:
|
||||
int init(common::ObIAllocator &allocator);
|
||||
int init_for_first_creation(common::ObIAllocator &allocator);
|
||||
int init_for_evict_medium_info(
|
||||
common::ObIAllocator &allocator,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObTabletDumpedMediumInfo &other);
|
||||
int init_for_mds_table_dump(
|
||||
common::ObIAllocator &allocator,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObTabletDumpedMediumInfo &other1,
|
||||
const ObTabletDumpedMediumInfo &other2);
|
||||
void reset();
|
||||
|
||||
// key order in array: big -> small
|
||||
@ -70,6 +79,8 @@ public:
|
||||
int64_t simple_to_string(char* buf, const int64_t buf_len, int64_t &pos) const;
|
||||
public:
|
||||
static bool compare(const compaction::ObMediumCompactionInfo *lhs, const compaction::ObMediumCompactionInfo *rhs);
|
||||
private:
|
||||
int do_append(const compaction::ObMediumCompactionInfo &medium_info);
|
||||
public:
|
||||
bool is_inited_;
|
||||
common::ObIAllocator *allocator_;
|
||||
@ -86,7 +97,7 @@ public:
|
||||
public:
|
||||
int init(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo &dumped_medium_info);
|
||||
const ObTabletDumpedMediumInfo *dumped_medium_info);
|
||||
void reset();
|
||||
int get_next_key(compaction::ObMediumCompactionInfoKey &key);
|
||||
int get_next_medium_info(
|
||||
|
@ -47,7 +47,7 @@ int ObTabletFullMemoryMdsData::init(common::ObArenaAllocator &allocator)
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret), K_(is_inited));
|
||||
} else if (OB_FAIL(medium_info_list_.medium_info_list_.init(allocator))) {
|
||||
} else if (OB_FAIL(medium_info_list_.medium_info_list_.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init medium info list", K(ret));
|
||||
} else {
|
||||
is_inited_ = true;
|
||||
@ -136,9 +136,9 @@ int ObTabletFullMemoryMdsData::read_mds_dump_kv(
|
||||
LOG_WARN("invalid args", K(ret), K(mds_dump_kv_addr));
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, mds_dump_kv_addr, ptr))) {
|
||||
LOG_WARN("failed to load mds dump kv", K(ret));
|
||||
} else if (OB_ISNULL(ptr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ptr is null", K(ret), KP(ptr));
|
||||
} else if (nullptr == ptr) {
|
||||
// do nothing
|
||||
dump_kv.reset();
|
||||
} else if (OB_FAIL(dump_kv.assign(*ptr, allocator))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
}
|
||||
@ -161,11 +161,10 @@ int ObTabletFullMemoryMdsData::read_medium_info_list(
|
||||
LOG_WARN("invalid args", K(ret), K(medium_info_list_addr));
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_medium_info_list(allocator, medium_info_list_addr, ptr))) {
|
||||
LOG_WARN("failed to load medium info list", K(ret));
|
||||
} else if (OB_ISNULL(ptr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ptr is null", K(ret), KP(ptr));
|
||||
} else if (OB_FAIL(medium_info_list.assign(*ptr, allocator))) {
|
||||
LOG_WARN("failed to medium info list", K(ret));
|
||||
} else if (nullptr == ptr && OB_FAIL(medium_info_list.init_for_first_creation(allocator))) {
|
||||
LOG_WARN("failed to init medium info list", K(ret));
|
||||
} else if (nullptr != ptr && OB_FAIL(medium_info_list.assign(*ptr, allocator))) {
|
||||
LOG_WARN("failed to copy medium info list", K(ret));
|
||||
}
|
||||
|
||||
ObTabletMdsData::free_medium_info_list(allocator, ptr);
|
||||
@ -180,15 +179,11 @@ int ObTabletFullMemoryMdsData::read_auto_inc_seq(
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObTabletAutoincSeq *ptr = nullptr;
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> auto_inc_seq_wrapper;
|
||||
|
||||
if (OB_FAIL(ObTabletMdsData::fetch_auto_inc_seq(auto_inc_seq_addr, auto_inc_seq_wrapper))) {
|
||||
LOG_WARN("failed to fetch auto inc seq", K(ret));
|
||||
} else if (OB_FAIL(auto_inc_seq_wrapper.get_member(ptr))) {
|
||||
LOG_WARN("ObTabletMemberWrapper get member failed", K(ret));
|
||||
} else if (OB_ISNULL(ptr)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ptr is null", K(ret), KP(ptr));
|
||||
if (OB_FAIL(ObTabletMdsData::load_auto_inc_seq(allocator, auto_inc_seq_addr, ptr))) {
|
||||
LOG_WARN("failed to load auto inc seq", K(ret), K(auto_inc_seq_addr));
|
||||
} else if (nullptr == ptr) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(auto_inc_seq.assign(allocator, *ptr))) {
|
||||
LOG_WARN("failed to copy auto inc seq", K(ret));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,7 @@
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "share/ob_tablet_autoincrement_param.h"
|
||||
#include "storage/compaction/ob_compaction_util.h"
|
||||
#include "storage/compaction/ob_extra_medium_info.h"
|
||||
#include "storage/multi_data_source/adapter_define/mds_dump_node.h"
|
||||
#include "storage/tablet/ob_tablet_complex_addr.h"
|
||||
#include "storage/tablet/ob_tablet_member_wrapper.h"
|
||||
@ -35,7 +36,6 @@ namespace compaction
|
||||
class ObMediumCompactionInfoKey;
|
||||
class ObMediumCompactionInfo;
|
||||
class ObMediumCompactionInfoList;
|
||||
class ObExtraMediumInfo;
|
||||
}
|
||||
|
||||
namespace storage
|
||||
@ -71,21 +71,25 @@ public:
|
||||
ObTabletMdsData &operator=(const ObTabletMdsData&) = delete;
|
||||
public:
|
||||
void reset();
|
||||
int init(common::ObIAllocator &allocator);
|
||||
int init(
|
||||
int init_for_first_creation(common::ObIAllocator &allocator);
|
||||
int init_with_tablet_status(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletStatus::Status &tablet_status,
|
||||
const ObTabletMdsUserDataType &data_type);
|
||||
int init_by_full_memory_mds_data(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletFullMemoryMdsData &full_memory_mds_data);
|
||||
int init(
|
||||
int init_for_mds_table_dump(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletMdsData &mds_table_data,
|
||||
const ObTabletMdsData &base_data,
|
||||
const int64_t finish_medium_scn);
|
||||
int init(
|
||||
int init_for_evict_medium_info(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletMdsData &other,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObMergeType merge_type = ObMergeType::MERGE_TYPE_MAX);
|
||||
int init(
|
||||
int init_for_merge_with_full_mds_data(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletMdsData &other,
|
||||
const ObTabletFullMediumInfo &full_memory_medium_info_list,
|
||||
@ -93,11 +97,8 @@ public:
|
||||
int init_with_update_medium_info(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletMdsData &other);
|
||||
int init_empty_shell(const ObTabletCreateDeleteMdsUserData &tablet_status);
|
||||
int set_tablet_status(
|
||||
ObArenaAllocator *allocator,
|
||||
const ObTabletStatus::Status &tablet_status,
|
||||
const ObTabletMdsUserDataType &data_type);
|
||||
int init_empty_shell(
|
||||
const ObTabletCreateDeleteMdsUserData &tablet_status);
|
||||
bool is_valid() const;
|
||||
void set_mem_addr();
|
||||
public:
|
||||
@ -122,15 +123,19 @@ public:
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr,
|
||||
const ObTabletDumpedMediumInfo *&medium_info_list);
|
||||
static int load_auto_inc_seq(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &complex_addr,
|
||||
const share::ObTabletAutoincSeq *&auto_inc_seq);
|
||||
static void free_mds_dump_kv(
|
||||
common::ObIAllocator &allocator,
|
||||
const mds::MdsDumpKV *kv);
|
||||
static void free_auto_inc_seq(
|
||||
common::ObIAllocator &allocator,
|
||||
const share::ObTabletAutoincSeq *auto_inc_seq);
|
||||
static void free_medium_info_list(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo *medium_info_list);
|
||||
static int fetch_auto_inc_seq(
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq_addr,
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> &wrapper);
|
||||
static int build_tablet_status(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletTxMultiSourceDataUnit &tx_data,
|
||||
@ -156,50 +161,60 @@ public:
|
||||
const compaction::ObMediumCompactionInfoList &info_list,
|
||||
ObTabletMdsData &mds_data);
|
||||
private:
|
||||
int alloc_and_new(common::ObIAllocator &allocator);
|
||||
int do_init(
|
||||
void reset(common::ObIAllocator &allocator);
|
||||
int set_tablet_status(
|
||||
common::ObIAllocator &allocator,
|
||||
const mds::MdsDumpKV *tablet_status_uncommitted_kv,
|
||||
const mds::MdsDumpKV *tablet_status_committed_kv,
|
||||
const mds::MdsDumpKV *aux_tablet_info_uncommitted_kv,
|
||||
const mds::MdsDumpKV *aux_tablet_info_committed_kv,
|
||||
const share::ObTabletAutoincSeq *auto_inc_seq);
|
||||
int init_medium_info_list(
|
||||
const ObTabletStatus::Status &tablet_status,
|
||||
const ObTabletMdsUserDataType &data_type);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo *old_medium_info_list,
|
||||
const compaction::ObExtraMediumInfo &old_extra_medium_info,
|
||||
const int64_t finish_medium_scn = 0,
|
||||
const ObMergeType merge_type = ObMergeType::MERGE_TYPE_MAX);
|
||||
int init_medium_info_list(
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &src_addr,
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &dst_addr);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo *old_medium_info_list,
|
||||
const ObTabletFullMediumInfo &full_memory_medium_info_list,
|
||||
const compaction::ObExtraMediumInfo &old_extra_medium_info,
|
||||
const int64_t finish_medium_scn);
|
||||
int init_with_update_medium_info(
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &src_addr,
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> &dst_addr);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo *old_medium_info_list,
|
||||
const compaction::ObExtraMediumInfo &old_extra_medium_info);
|
||||
static int fuse_mds_dump_node(
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &src_addr,
|
||||
const int64_t finish_medium_scn,
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &dst_addr);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const mds::MdsDumpKV &src_data,
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &dst_addr);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const share::ObTabletAutoincSeq &src_data,
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> &dst_addr);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletDumpedMediumInfo &src_data,
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &dst_addr);
|
||||
static int init_single_complex_addr_and_extra_info(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &src_addr,
|
||||
const compaction::ObExtraMediumInfo &src_addr_extra_info,
|
||||
const ObTabletDumpedMediumInfo &src_data,
|
||||
const compaction::ObExtraMediumInfo &src_data_extra_info,
|
||||
const int64_t finish_medium_scn,
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &dst_addr,
|
||||
compaction::ObExtraMediumInfo &dst_extra_info);
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &mds_table_data,
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &base_data,
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &fused_data);
|
||||
static int fuse_mds_dump_node(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletMdsDumpStruct &mds_table_data,
|
||||
const ObTabletMdsDumpStruct &base_data,
|
||||
ObTabletMdsDumpStruct &fused_data);
|
||||
static int fuse_mds_dump_node(
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &mds_table_data,
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &base_data,
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> &fused_data);
|
||||
static int fuse_mds_dump_node(
|
||||
static int init_single_complex_addr(
|
||||
common::ObIAllocator &allocator,
|
||||
const int64_t finish_medium_scn,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &mds_table_data,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &base_data,
|
||||
const int64_t finish_medium_scn,
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &fused_data);
|
||||
static int read_medium_info(
|
||||
common::ObIAllocator &allocator,
|
||||
@ -214,6 +229,10 @@ private:
|
||||
const ObTabletDumpedMediumInfo &input_medium_info_list1,
|
||||
const ObTabletDumpedMediumInfo &input_medium_info_list2,
|
||||
ObTabletDumpedMediumInfo &medium_info_list);
|
||||
static int init_single_mds_dump_kv(
|
||||
common::ObIAllocator &allocator,
|
||||
const mds::MdsDumpKV *input_kv,
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &kv);
|
||||
template <typename T>
|
||||
static int update_user_data_from_complex_addr(
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
|
||||
@ -238,9 +257,11 @@ int ObTabletMdsData::update_user_data_from_complex_addr(
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
|
||||
if (OB_UNLIKELY(!complex_addr.is_memory_object())) {
|
||||
if (OB_UNLIKELY(!complex_addr.is_memory_object() && !complex_addr.is_none_object())) {
|
||||
ret = common::OB_INVALID_ARGUMENT;
|
||||
STORAGE_LOG(WARN, "complex addr is not memory type", K(ret), K(complex_addr));
|
||||
STORAGE_LOG(WARN, "complex addr is not memory or none type", K(ret), K(complex_addr));
|
||||
} else if (complex_addr.is_none_object()) {
|
||||
// do nothing
|
||||
} else {
|
||||
const mds::MdsDumpKV *kv = complex_addr.ptr_;
|
||||
const common::ObString &str = kv->v_.user_data_;
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "share/ob_tablet_autoincrement_param.h"
|
||||
#include "storage/tablet/ob_tablet_mds_data.h"
|
||||
#include "storage/tablet/ob_tablet_create_delete_mds_user_data.h"
|
||||
#include "storage/tablet/ob_tablet_obj_load_helper.h"
|
||||
#include "storage/multi_data_source/adapter_define/mds_dump_node.h"
|
||||
#include "storage/multi_data_source/compile_utility/mds_dummy_key.h"
|
||||
#include "storage/multi_data_source/mds_table_handle.h"
|
||||
@ -43,6 +44,8 @@ int ObTabletDumpMdsNodeOperator::dump<mds::DummyKey, ObTabletCreateDeleteMdsUser
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<mds::DummyKey, ObTabletCreateDeleteMdsUserData>>::value;
|
||||
const mds::MdsDumpKey &key = kv.k_;
|
||||
const mds::MdsDumpNode &node = kv.v_;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &uncommitted_tablet_status = mds_data_.tablet_status_.uncommitted_kv_;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &committed_tablet_status = mds_data_.tablet_status_.committed_kv_;
|
||||
|
||||
if (table_id == key.mds_table_id_ && unit_id == key.mds_unit_id_) {
|
||||
const mds::TwoPhaseCommitState &state = node.status_.get_state();
|
||||
@ -51,13 +54,29 @@ int ObTabletDumpMdsNodeOperator::dump<mds::DummyKey, ObTabletCreateDeleteMdsUser
|
||||
case mds::TwoPhaseCommitState::BEFORE_PREPARE:
|
||||
case mds::TwoPhaseCommitState::ON_ABORT:
|
||||
case mds::TwoPhaseCommitState::ON_PREPARE:
|
||||
if (OB_FAIL(mds_data_.tablet_status_.uncommitted_kv_.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
{
|
||||
if (!uncommitted_tablet_status.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, uncommitted_tablet_status.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(uncommitted_tablet_status.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mds::TwoPhaseCommitState::ON_COMMIT:
|
||||
if (OB_FAIL(mds_data_.tablet_status_.committed_kv_.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
{
|
||||
if (!committed_tablet_status.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, committed_tablet_status.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(committed_tablet_status.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mds::TwoPhaseCommitState::STATE_END:
|
||||
@ -82,6 +101,8 @@ int ObTabletDumpMdsNodeOperator::dump<mds::DummyKey, ObTabletBindingMdsUserData>
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<mds::DummyKey, ObTabletBindingMdsUserData>>::value;
|
||||
const mds::MdsDumpKey &key = kv.k_;
|
||||
const mds::MdsDumpNode &node = kv.v_;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &uncommitted_aux_tablet_info = mds_data_.aux_tablet_info_.uncommitted_kv_;
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &committed_aux_tablet_info = mds_data_.aux_tablet_info_.committed_kv_;
|
||||
|
||||
if (table_id == key.mds_table_id_ && unit_id == key.mds_unit_id_) {
|
||||
const mds::TwoPhaseCommitState &state = node.status_.get_state();
|
||||
@ -90,13 +111,29 @@ int ObTabletDumpMdsNodeOperator::dump<mds::DummyKey, ObTabletBindingMdsUserData>
|
||||
case mds::TwoPhaseCommitState::BEFORE_PREPARE:
|
||||
case mds::TwoPhaseCommitState::ON_ABORT:
|
||||
case mds::TwoPhaseCommitState::ON_PREPARE:
|
||||
if (OB_FAIL(mds_data_.aux_tablet_info_.uncommitted_kv_.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
{
|
||||
if (!uncommitted_aux_tablet_info.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, uncommitted_aux_tablet_info.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(uncommitted_aux_tablet_info.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mds::TwoPhaseCommitState::ON_COMMIT:
|
||||
if (OB_FAIL(mds_data_.aux_tablet_info_.committed_kv_.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
{
|
||||
if (!committed_aux_tablet_info.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, committed_aux_tablet_info.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(committed_aux_tablet_info.ptr_->assign(kv, allocator_))) {
|
||||
LOG_WARN("failed to copy mds dump kv", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mds::TwoPhaseCommitState::STATE_END:
|
||||
@ -121,16 +158,23 @@ int ObTabletDumpMdsNodeOperator::dump<mds::DummyKey, share::ObTabletAutoincSeq>(
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<mds::DummyKey, share::ObTabletAutoincSeq>>::value;
|
||||
const mds::MdsDumpKey &key = kv.k_;
|
||||
const mds::MdsDumpNode &node = kv.v_;
|
||||
ObTabletComplexAddr<share::ObTabletAutoincSeq> &auto_inc_seq = mds_data_.auto_inc_seq_;
|
||||
|
||||
if (table_id == key.mds_table_id_ && unit_id == key.mds_unit_id_) {
|
||||
const mds::TwoPhaseCommitState &state = node.status_.get_state();
|
||||
const common::ObString &user_data = kv.v_.user_data_;
|
||||
int64_t pos = 0;
|
||||
share::ObTabletAutoincSeq *auto_inc_seq = mds_data_.auto_inc_seq_.ptr_;
|
||||
if (OB_UNLIKELY(state != mds::TwoPhaseCommitState::ON_COMMIT)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid state", K(ret), K(state));
|
||||
} else if (OB_FAIL(auto_inc_seq->deserialize(allocator_, user_data.ptr(), user_data.length(), pos))) {
|
||||
} else if (!auto_inc_seq.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, auto_inc_seq.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(auto_inc_seq.ptr_->deserialize(allocator_, user_data.ptr(), user_data.length(), pos))) {
|
||||
LOG_WARN("failed to deserialize", K(ret));
|
||||
} else {
|
||||
dumped = true;
|
||||
@ -148,14 +192,23 @@ int ObTabletDumpMdsNodeOperator::dump<compaction::ObMediumCompactionInfoKey, com
|
||||
constexpr uint8_t unit_id = mds::TupleTypeIdx<mds::NormalMdsTable, mds::MdsUnit<compaction::ObMediumCompactionInfoKey, compaction::ObMediumCompactionInfo>>::value;
|
||||
const mds::MdsDumpKey &key = kv.k_;
|
||||
const mds::MdsDumpNode &node = kv.v_;
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> &medium_info_list = mds_data_.medium_info_list_;
|
||||
|
||||
if (table_id == key.mds_table_id_ && unit_id == key.mds_unit_id_) {
|
||||
const mds::TwoPhaseCommitState &state = node.status_.get_state();
|
||||
ObTabletDumpedMediumInfo *medium_info_list = mds_data_.medium_info_list_.ptr_;
|
||||
if (OB_UNLIKELY(state != mds::TwoPhaseCommitState::ON_COMMIT)) {
|
||||
ret = OB_SUCCESS;
|
||||
LOG_WARN("invalid state", K(ret), K(state));
|
||||
} else if (OB_FAIL(medium_info_list->append(key, node))) {
|
||||
} else if (!medium_info_list.is_memory_object()) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator_, medium_info_list.ptr_))) {
|
||||
LOG_WARN("failed to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(medium_info_list.ptr_->init_for_first_creation(allocator_))) {
|
||||
LOG_WARN("failed to init medium info list", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(medium_info_list.ptr_->append(key, node))) {
|
||||
LOG_WARN("failed to copy mds dump node", K(ret));
|
||||
} else {
|
||||
dumped = true;
|
||||
|
@ -46,35 +46,32 @@ ObTabletMediumInfoReader::~ObTabletMediumInfoReader()
|
||||
int ObTabletMediumInfoReader::init(common::ObArenaAllocator &allocator)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObLSID &ls_id = tablet_.get_tablet_meta().ls_id_;
|
||||
const common::ObTabletID &tablet_id = tablet_.get_tablet_meta().tablet_id_;
|
||||
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
ret = OB_INIT_TWICE;
|
||||
LOG_WARN("init twice", K(ret), K_(is_inited));
|
||||
LOG_WARN("init twice", K(ret), K(ls_id), K(tablet_id), K_(is_inited));
|
||||
} else {
|
||||
mds::MdsTableHandle mds_table;
|
||||
const ObTabletDumpedMediumInfo *dumped_medium_info = nullptr;
|
||||
if (OB_FAIL(tablet_.inner_get_mds_table(mds_table, false/*not_exist_create*/))) {
|
||||
if (OB_ENTRY_NOT_EXIST != ret) {
|
||||
LOG_WARN("failed to get mds table", K(ret));
|
||||
LOG_WARN("failed to get mds table", K(ret), K(ls_id), K(tablet_id));
|
||||
} else {
|
||||
mds_end_ = true; // no mds table, directly iter end
|
||||
ret = OB_SUCCESS;
|
||||
LOG_DEBUG("no mds table", K(ret), K_(mds_end));
|
||||
LOG_DEBUG("no mds table", K(ret), K(ls_id), K(tablet_id), K_(mds_end));
|
||||
}
|
||||
} else if (OB_FAIL(mds_iter_.init(mds_table))) {
|
||||
LOG_WARN("failed to init mds iter", K(ret));
|
||||
LOG_WARN("failed to init mds iter", K(ret), K(ls_id), K(tablet_id));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_medium_info_list(allocator, tablet_.mds_data_.medium_info_list_, dumped_medium_info))) {
|
||||
LOG_WARN("failed to load medium info list", K(ret),
|
||||
"ls_id", tablet_.get_tablet_meta().ls_id_,
|
||||
"tablet_id", tablet_.get_tablet_meta().tablet_id_);
|
||||
} else if (OB_ISNULL(dumped_medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), KP(dumped_medium_info));
|
||||
} else if (OB_FAIL(dump_iter_.init(allocator, *dumped_medium_info))) {
|
||||
LOG_WARN("failed to init dumped iter", K(ret));
|
||||
LOG_WARN("failed to load medium info list", K(ret), K(ls_id), K(tablet_id));
|
||||
} else if (OB_FAIL(dump_iter_.init(allocator, dumped_medium_info))) {
|
||||
LOG_WARN("failed to init dumped iter", K(ret), K(ls_id), K(tablet_id));
|
||||
} else {
|
||||
allocator_ = &allocator;
|
||||
}
|
||||
|
@ -69,6 +69,12 @@ void ObTabletTransformArg::reset()
|
||||
auto_inc_seq_addr_.reset();
|
||||
tablet_status_cache_.reset();
|
||||
aux_tablet_info_cache_.reset();
|
||||
ddl_kvs_ = nullptr;
|
||||
ddl_kv_count_ = 0;
|
||||
for (int64_t i = 0; i < MAX_MEMSTORE_CNT; ++i) {
|
||||
memtables_[i] = nullptr;
|
||||
}
|
||||
memtable_count_ = 0;
|
||||
}
|
||||
|
||||
bool ObTabletTransformArg::is_valid() const
|
||||
@ -92,7 +98,7 @@ int ObTabletPersister::persist_and_transform_tablet(
|
||||
{
|
||||
TIMEGUARD_INIT(STORAGE, 10_ms);
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObArenaAllocator allocator(common::ObMemAttr(MTL_ID(), "PesistTranf"));
|
||||
common::ObArenaAllocator allocator(common::ObMemAttr(MTL_ID(), "PATF"));
|
||||
common::ObSEArray<ObSharedBlocksWriteCtx, 16> tablet_meta_write_ctxs;
|
||||
common::ObSEArray<ObSharedBlocksWriteCtx, 16> sstable_meta_write_ctxs;
|
||||
|
||||
@ -176,13 +182,13 @@ int ObTabletPersister::convert_tablet_to_mem_arg(
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::convert_tablet_to_disk_arg(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTablet &tablet,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &tablet_meta_write_ctxs,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &sstable_meta_write_ctxs,
|
||||
ObTabletPoolType &type,
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> &auto_inc_seq,
|
||||
ObTabletTransformArg &arg)
|
||||
{
|
||||
TIMEGUARD_INIT(STORAGE, 10_ms);
|
||||
@ -191,18 +197,7 @@ int ObTabletPersister::convert_tablet_to_disk_arg(
|
||||
|
||||
common::ObSEArray<ObSharedBlockWriteInfo, 8> write_infos;
|
||||
// fetch member wrapper
|
||||
ObTabletMemberWrapper<ObTabletTableStore> table_store;
|
||||
// fetch member function
|
||||
FetchTableStore fetch_table_store =
|
||||
std::bind(&ObTablet::fetch_table_store, &tablet, _1);
|
||||
FetchAutoincSeq fetch_auto_inc_seq =
|
||||
std::bind(&ObTabletMdsData::fetch_auto_inc_seq, std::cref(tablet.mds_data_.auto_inc_seq_), _1);
|
||||
|
||||
// load member
|
||||
const ObStorageSchema *storage_schema = nullptr;
|
||||
// load member function
|
||||
LoadStorageSchema load_storage_schema =
|
||||
std::bind(&ObTablet::load_storage_schema, &tablet, _1, _2);
|
||||
ObTabletMemberWrapper<ObTabletTableStore> table_store_wrapper;
|
||||
|
||||
// load new mds data
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &uncommitted_tablet_status_addr = tablet.mds_data_.tablet_status_.uncommitted_kv_;
|
||||
@ -219,40 +214,36 @@ int ObTabletPersister::convert_tablet_to_disk_arg(
|
||||
LOG_WARN("fail to assign tablet meta", K(ret), K(tablet));
|
||||
} else if (FALSE_IT(arg.rowkey_read_info_ptr_ = tablet.rowkey_read_info_)) {
|
||||
} else if (FALSE_IT(arg.extra_medium_info_ = tablet.mds_data_.extra_medium_info_)) {
|
||||
} else if (CLICK_FAIL(fetch_wrapper_and_write_info(allocator, fetch_table_store, table_store, write_infos, sstable_meta_write_ctxs))) {
|
||||
LOG_WARN("fail to fetch table store wrapper and write info", K(ret));
|
||||
} else if (CLICK_FAIL(fetch_wrapper_and_write_info(
|
||||
allocator, fetch_auto_inc_seq, auto_inc_seq, write_infos, tablet_meta_write_ctxs))) {
|
||||
LOG_WARN("fail to fetch auto inc seq wrapper and write info", K(ret));
|
||||
} else if (FALSE_IT(arg.auto_inc_seq_ptr_ = auto_inc_seq.get_member())) {
|
||||
} else if (CLICK_FAIL(fetch_table_store_and_write_info(tablet, allocator, table_store_wrapper, write_infos, sstable_meta_write_ctxs))) {
|
||||
LOG_WARN("fail to fetch table store and write info", K(ret));
|
||||
} else if (CLICK_FAIL(load_auto_inc_seq_and_write_info(allocator, tablet.mds_data_.auto_inc_seq_, arg.auto_inc_seq_ptr_, write_infos, arg.auto_inc_seq_addr_))) {
|
||||
LOG_WARN("fail to load auto inc seq and write info", K(ret));
|
||||
} else if (FALSE_IT(arg.ddl_kvs_ = tablet.ddl_kvs_)) {
|
||||
} else if (FALSE_IT(arg.ddl_kv_count_ = tablet.ddl_kv_count_)) {
|
||||
} else if (FALSE_IT(arg.memtable_count_ = tablet.memtable_count_)) {
|
||||
} else if (OB_ISNULL(MEMCPY(arg.memtables_, tablet.memtables_, sizeof(arg.memtables_)))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("fail to memcpy memtables", K(ret), KP(arg.memtables_), KP(tablet.memtables_));
|
||||
} else if (CLICK_FAIL(load_member_and_write_info(
|
||||
allocator, load_storage_schema, storage_schema, write_infos))) {
|
||||
LOG_WARN("fail to load storage schema and write info", K(ret));
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, uncommitted_tablet_status_addr, write_infos))) {
|
||||
} else if (CLICK_FAIL(load_storage_schema_and_fill_write_info(tablet, allocator, write_infos))) {
|
||||
LOG_WARN("fail to load storage schema and fill write info", K(ret));
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, uncommitted_tablet_status_addr, write_infos, arg.tablet_status_uncommitted_kv_addr_))) {
|
||||
LOG_WARN("fail to load tablet status uncommitted kv", K(ret), K(uncommitted_tablet_status_addr));
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, committed_tablet_status_addr, write_infos))) {
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, committed_tablet_status_addr, write_infos, arg.tablet_status_committed_kv_addr_))) {
|
||||
LOG_WARN("fail to load tablet status committed kv", K(ret), K(committed_tablet_status_addr));
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, uncommitted_aux_tablet_info_addr, write_infos))) {
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, uncommitted_aux_tablet_info_addr, write_infos, arg.aux_tablet_info_uncommitted_kv_addr_))) {
|
||||
LOG_WARN("fail to load aux tablet info uncommitted kv", K(ret), K(uncommitted_aux_tablet_info_addr));
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, committed_aux_tablet_info_addr, write_infos))) {
|
||||
} else if (CLICK_FAIL(load_dump_kv_and_fill_write_info(allocator, committed_aux_tablet_info_addr, write_infos, arg.aux_tablet_info_committed_kv_addr_))) {
|
||||
LOG_WARN("fail to load aux tablet info committed kv", K(ret), K(committed_aux_tablet_info_addr));
|
||||
} else if (CLICK_FAIL(write_and_fill_args(write_infos, arg, tablet_meta_write_ctxs))) {
|
||||
LOG_WARN("fail to write and fill address", K(ret), K(write_infos), K(auto_inc_seq));
|
||||
} else if (CLICK_FAIL(load_medium_info_list_and_write(allocator, medium_info_list_addr, arg.medium_info_list_addr_, tablet_meta_write_ctxs))) {
|
||||
LOG_WARN("fail to write and fill address", K(ret));
|
||||
} else if (CLICK_FAIL(load_medium_info_list_and_write(allocator, medium_info_list_addr, tablet_meta_write_ctxs, arg.medium_info_list_addr_))) {
|
||||
LOG_WARN("fail to load medium info list and write", K(ret), K(medium_info_list_addr));
|
||||
} else {
|
||||
const int64_t try_cache_size = tablet.get_try_cache_size() + table_store.get_member()->get_deep_copy_size();
|
||||
const int64_t try_cache_size = tablet.get_try_cache_size() + table_store_wrapper.get_member()->get_deep_copy_size();
|
||||
if (try_cache_size > ObTenantMetaMemMgr::NORMAL_TABLET_POOL_SIZE) {
|
||||
type = ObTabletPoolType::TP_LARGE;
|
||||
}
|
||||
}
|
||||
ObTablet::free_storage_schema(allocator, storage_schema);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -266,7 +257,6 @@ int ObTabletPersister::persist_and_fill_tablet(
|
||||
{
|
||||
TIMEGUARD_INIT(STORAGE, 10_ms);
|
||||
int ret = OB_SUCCESS;
|
||||
common::ObSEArray<ObSharedBlockWriteInfo, 8> write_infos;
|
||||
ObTabletTransformArg arg;
|
||||
|
||||
const ObTabletMeta &tablet_meta = old_tablet.get_tablet_meta();
|
||||
@ -280,13 +270,14 @@ int ObTabletPersister::persist_and_fill_tablet(
|
||||
LOG_WARN("fail to conver tablet to mem arg", K(ret), K(old_tablet));
|
||||
}
|
||||
} else if (CLICK_FAIL(convert_tablet_to_disk_arg(
|
||||
allocator, old_tablet, tablet_meta_write_ctxs, sstable_meta_write_ctxs, type, auto_inc_seq, arg))) {
|
||||
allocator, old_tablet, tablet_meta_write_ctxs, sstable_meta_write_ctxs, type, arg))) {
|
||||
LOG_WARN("fail to conver tablet to disk arg", K(ret), K(old_tablet));
|
||||
} else if (old_tablet.get_try_cache_size() > ObTenantMetaMemMgr::NORMAL_TABLET_POOL_SIZE) {
|
||||
try_smaller_pool = false;
|
||||
}
|
||||
|
||||
if (CLICK() && FAILEDx(acquire_tablet(type, key, try_smaller_pool, new_handle))) {
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (CLICK_FAIL(acquire_tablet(type, key, try_smaller_pool, new_handle))) {
|
||||
LOG_WARN("fail to acquire tablet", K(ret), K(key), K(type));
|
||||
} else if (CLICK_FAIL(transform(arg, new_handle.get_buf(), new_handle.get_buf_len()))) {
|
||||
LOG_WARN("fail to transform old tablet", K(ret), K(arg), K(new_handle), K(type));
|
||||
@ -366,17 +357,14 @@ int ObTabletPersister::persist_4k_tablet(common::ObArenaAllocator &allocator, Ob
|
||||
TIMEGUARD_INIT(STORAGE, 10_ms);
|
||||
int ret = OB_SUCCESS;
|
||||
ObTablet *new_tablet = new_handle.get_obj();
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_hanlder = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
common::ObSEArray<ObSharedBlockWriteInfo, 1> write_infos;
|
||||
ObSharedBlockWriteHandle handle;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (CLICK_FAIL(fill_write_info(allocator, new_tablet, write_infos))) {
|
||||
LOG_WARN("fail to fill write info", K(ret), KPC(new_tablet));
|
||||
} else if (OB_ISNULL(ckpt_slog_hanlder)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ckpt slog handler is nullptr", K(ret), KP(ckpt_slog_hanlder));
|
||||
} else if (CLICK_FAIL(ckpt_slog_hanlder->get_shared_block_reader_writer().async_write(write_infos.at(0), handle))) {
|
||||
LOG_WARN("fail to async write", K(ret), K(write_infos));
|
||||
} else if (CLICK_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_write(write_infos.at(0), handle))) {
|
||||
LOG_WARN("fail to async write", K(ret), "write_info", write_infos.at(0));
|
||||
} else if (CLICK_FAIL(handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("fail to batch get address", K(ret), K(handle));
|
||||
} else if (FALSE_IT(new_tablet->set_tablet_addr(write_ctx.addr_))) {
|
||||
@ -410,8 +398,7 @@ int ObTabletPersister::convert_arg_to_tablet(
|
||||
tablet.mds_data_.tablet_status_.committed_kv_.addr_ = arg.tablet_status_committed_kv_addr_;
|
||||
tablet.mds_data_.aux_tablet_info_.uncommitted_kv_.addr_ = arg.aux_tablet_info_uncommitted_kv_addr_;
|
||||
tablet.mds_data_.aux_tablet_info_.committed_kv_.addr_ = arg.aux_tablet_info_committed_kv_addr_;
|
||||
tablet.mds_data_.extra_medium_info_.info_ = arg.extra_medium_info_.info_;
|
||||
tablet.mds_data_.extra_medium_info_.last_medium_scn_ = arg.extra_medium_info_.last_medium_scn_;
|
||||
tablet.mds_data_.extra_medium_info_ = arg.extra_medium_info_;
|
||||
tablet.mds_data_.medium_info_list_.addr_ = arg.medium_info_list_addr_;
|
||||
tablet.mds_data_.auto_inc_seq_.addr_ = arg.auto_inc_seq_addr_;
|
||||
tablet.mds_data_.is_inited_ = true;
|
||||
@ -526,6 +513,7 @@ int ObTabletPersister::transform(
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_ISNULL(arg.auto_inc_seq_ptr_)) {
|
||||
tiny_tablet->mds_data_.auto_inc_seq_.ptr_ = nullptr;
|
||||
tiny_tablet->mds_data_.auto_inc_seq_.addr_.set_none_addr();
|
||||
} else {
|
||||
LOG_DEBUG("TINY TABLET: tablet + rowkey_read_info + tablet store", KP(buf), K(start_pos), K(remain));
|
||||
ObIStorageMetaObj *auto_inc_obj = nullptr;
|
||||
@ -590,11 +578,11 @@ int ObTabletPersister::fetch_and_persist_sstable(
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
if (OB_SUCC(ret) && write_infos.count() > 0) {
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_hanlder = MTL(ObTenantCheckpointSlogHandler*);
|
||||
if (OB_ISNULL(ckpt_slog_hanlder)) {
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
if (OB_ISNULL(ckpt_slog_handler)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ckpt slog handler is nullptr", K(ret), KP(ckpt_slog_hanlder));
|
||||
} else if (OB_FAIL(ckpt_slog_hanlder->get_shared_block_reader_writer().async_batch_write(write_infos, handle))) {
|
||||
LOG_WARN("unexpected error, ckpt slog handler is nullptr", K(ret), KP(ckpt_slog_handler));
|
||||
} else if (OB_FAIL(ckpt_slog_handler->get_shared_block_reader_writer().async_batch_write(write_infos, handle))) {
|
||||
LOG_WARN("fail to batch async write", K(ret), K(write_infos));
|
||||
} else if (OB_FAIL(handle.batch_get_write_ctx(write_ctxs))) {
|
||||
LOG_WARN("fail to batch get addr", K(ret), K(handle));
|
||||
@ -624,8 +612,8 @@ int ObTabletPersister::write_and_fill_args(
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_hanlder = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObSharedBlockReaderWriter &reader_writer = ckpt_slog_hanlder->get_shared_block_reader_writer();
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObSharedBlockReaderWriter &reader_writer = ckpt_slog_handler->get_shared_block_reader_writer();
|
||||
ObSharedBlockBatchHandle handle;
|
||||
ObMetaDiskAddr* addr[] = { // NOTE: The order must be the same as the batch async write.
|
||||
&arg.table_store_addr_,
|
||||
@ -636,29 +624,43 @@ int ObTabletPersister::write_and_fill_args(
|
||||
&arg.aux_tablet_info_uncommitted_kv_addr_,
|
||||
&arg.aux_tablet_info_committed_kv_addr_,
|
||||
};
|
||||
common::ObSEArray<ObSharedBlocksWriteCtx, sizeof(addr)/sizeof(addr[0])> write_ctxs;
|
||||
if (OB_UNLIKELY(sizeof(addr)/sizeof(addr[0]) != write_infos.count())) {
|
||||
constexpr int64_t total_addr_cnt = sizeof(addr) / sizeof(addr[0]);
|
||||
int64_t none_addr_cnt = 0;
|
||||
for (int64_t i = 0; i < total_addr_cnt; ++i) {
|
||||
if (addr[i]->is_none()) {
|
||||
++none_addr_cnt;
|
||||
}
|
||||
}
|
||||
|
||||
common::ObSEArray<ObSharedBlocksWriteCtx, total_addr_cnt> write_ctxs;
|
||||
if (OB_UNLIKELY(total_addr_cnt != write_infos.count() + none_addr_cnt)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid arguments", K(ret), "write info count", write_infos.count(), K(write_infos));
|
||||
} else if (OB_ISNULL(ckpt_slog_hanlder)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, ckpt slog handler is nullptr", K(ret), KP(ckpt_slog_hanlder));
|
||||
} else if (OB_FAIL(ckpt_slog_hanlder->get_shared_block_reader_writer().async_batch_write(write_infos, handle))) {
|
||||
LOG_WARN("fail to batch async write", K(ret), K(write_infos));
|
||||
LOG_WARN("invalid arguments", K(ret), K(total_addr_cnt), "write_info_count", write_infos.count(), K(none_addr_cnt));
|
||||
} else if (OB_FAIL(reader_writer.async_batch_write(write_infos, handle))) {
|
||||
LOG_WARN("fail to batch async write", K(ret));
|
||||
} else if (OB_FAIL(handle.batch_get_write_ctx(write_ctxs))) {
|
||||
LOG_WARN("fail to batch get addr", K(ret), K(handle));
|
||||
} else if (OB_UNLIKELY(sizeof(addr)/sizeof(addr[0]) != write_ctxs.count())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid arguments", K(ret), "write ctx count", write_ctxs.count(), K(write_ctxs), K(handle));
|
||||
} else if (OB_UNLIKELY(write_infos.count() != write_ctxs.count())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("write ctx count does not equal to write info count", K(ret),
|
||||
"write_info_count", write_infos.count(),
|
||||
"write_ctx_count", write_ctxs.count(),
|
||||
K(write_ctxs), K(handle));
|
||||
} else {
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < write_ctxs.count(); ++i) {
|
||||
if (OB_UNLIKELY(!write_ctxs.at(i).is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected invalid addr", K(ret), K(i), K(write_ctxs.at(i)), K(handle));
|
||||
} else if (OB_FAIL(meta_write_ctxs.push_back(write_ctxs.at(i)))) {
|
||||
LOG_WARN("fail to push write ctx to array", K(ret), K(i), K(write_ctxs.at(i)));
|
||||
int64_t pos = 0;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < total_addr_cnt; ++i) {
|
||||
if (addr[i]->is_none()) {
|
||||
// skip none addr
|
||||
} else {
|
||||
*addr[i] = write_ctxs.at(i).addr_;
|
||||
const ObSharedBlocksWriteCtx &write_ctx = write_ctxs.at(pos++);
|
||||
if (OB_UNLIKELY(!write_ctx.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected write ctx", K(ret), K(i), K(write_ctx), K(handle));
|
||||
} else if (OB_FAIL(meta_write_ctxs.push_back(write_ctx))) {
|
||||
LOG_WARN("fail to push write ctx to array", K(ret), K(i), K(write_ctx));
|
||||
} else {
|
||||
*addr[i] = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -669,20 +671,21 @@ int ObTabletPersister::write_and_fill_args(
|
||||
int ObTabletPersister::load_dump_kv_and_fill_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos)
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const mds::MdsDumpKV *kv = nullptr;
|
||||
|
||||
if (complex_addr.addr_.is_none()) {
|
||||
// do nothing
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, complex_addr, kv))) {
|
||||
if (OB_FAIL(ObTabletMdsData::load_mds_dump_kv(allocator, complex_addr, kv))) {
|
||||
LOG_WARN("fail to load mds dump kv", K(ret), K(complex_addr));
|
||||
} else if (OB_ISNULL(kv)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, kv is null", K(ret), KP(kv));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, kv, write_infos))) {
|
||||
LOG_WARN("fail to fill write info", K(ret), KPC(kv));
|
||||
} else if (nullptr == kv) {
|
||||
// read nothing from complex addr, so disk addr is set to NONE
|
||||
addr.set_none_addr();
|
||||
} else {
|
||||
if (OB_FAIL(fill_write_info(allocator, kv, write_infos))) {
|
||||
LOG_WARN("fail to fill write info", K(ret), KPC(kv));
|
||||
}
|
||||
}
|
||||
|
||||
ObTabletMdsData::free_mds_dump_kv(allocator, kv);
|
||||
@ -693,19 +696,20 @@ int ObTabletPersister::load_dump_kv_and_fill_write_info(
|
||||
int ObTabletPersister::load_medium_info_list_and_write(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr,
|
||||
ObMetaDiskAddr &addr,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObTabletDumpedMediumInfo *medium_info_list = nullptr;
|
||||
|
||||
if (OB_FAIL(ObTabletMdsData::load_medium_info_list(allocator, complex_addr, medium_info_list))) {
|
||||
LOG_WARN("fail to load medium info list", K(ret), K(complex_addr));
|
||||
} else if (OB_ISNULL(medium_info_list)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info list is null", K(ret), KP(medium_info_list));
|
||||
} else if (OB_FAIL(link_write_medium_info_list(*medium_info_list, addr, meta_write_ctxs))) {
|
||||
LOG_WARN("failed to link write medium info list", K(ret));
|
||||
} else if (nullptr == medium_info_list) {
|
||||
addr.set_none_addr();
|
||||
} else {
|
||||
if (OB_FAIL(link_write_medium_info_list(medium_info_list, meta_write_ctxs, addr))) {
|
||||
LOG_WARN("failed to link write medium info list", K(ret));
|
||||
}
|
||||
}
|
||||
|
||||
ObTabletMdsData::free_medium_info_list(allocator, medium_info_list);
|
||||
@ -714,68 +718,76 @@ int ObTabletPersister::load_medium_info_list_and_write(
|
||||
}
|
||||
|
||||
int ObTabletPersister::link_write_medium_info_list(
|
||||
const ObTabletDumpedMediumInfo &medium_info_list,
|
||||
ObMetaDiskAddr &addr,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
const ObTabletDumpedMediumInfo *medium_info_list,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_hanlder = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObSharedBlockReaderWriter &reader_writer = ckpt_slog_hanlder->get_shared_block_reader_writer();
|
||||
ObTenantCheckpointSlogHandler *ckpt_slog_handler = MTL(ObTenantCheckpointSlogHandler*);
|
||||
ObSharedBlockReaderWriter &reader_writer = ckpt_slog_handler->get_shared_block_reader_writer();
|
||||
common::ObArenaAllocator arena_allocator(common::ObMemAttr(MTL_ID(), "serializer"));
|
||||
ObSharedBlockWriteInfo write_info;
|
||||
ObSharedBlockLinkHandle write_handle;
|
||||
|
||||
const common::ObIArray<compaction::ObMediumCompactionInfo*> &array = medium_info_list.medium_info_list_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
const compaction::ObMediumCompactionInfo *medium_info = array.at(i);
|
||||
if (OB_ISNULL(medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), K(i), KP(medium_info));
|
||||
} else {
|
||||
const int64_t size = medium_info->get_serialize_size();
|
||||
|
||||
if (0 == size) {
|
||||
LOG_INFO("medium info serialize size is 0, just skip", K(ret));
|
||||
if (nullptr == medium_info_list) {
|
||||
// no need to do link write, just return NONE addr
|
||||
addr.set_none_addr();
|
||||
} else {
|
||||
const common::ObIArray<compaction::ObMediumCompactionInfo*> &array = medium_info_list->medium_info_list_;
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < array.count(); ++i) {
|
||||
const compaction::ObMediumCompactionInfo *medium_info = array.at(i);
|
||||
if (OB_ISNULL(medium_info)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, medium info is null", K(ret), K(i), KP(medium_info));
|
||||
} else {
|
||||
int64_t pos = 0;
|
||||
char *buffer = static_cast<char*>(arena_allocator.alloc(size));
|
||||
if (OB_ISNULL(buffer)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(medium_info->serialize(buffer, size, pos))) {
|
||||
LOG_WARN("failed to serialize medium info", K(ret));
|
||||
} else {
|
||||
write_info.reset();
|
||||
write_info.buffer_ = buffer;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
if (OB_FAIL(reader_writer.async_link_write(write_info, write_handle))) {
|
||||
LOG_WARN("failed to do async link write", K(ret), K(write_info));
|
||||
} else if (OB_UNLIKELY(!write_handle.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, write handle is invalid", K(ret), K(write_handle));
|
||||
}
|
||||
}
|
||||
const int64_t size = medium_info->get_serialize_size();
|
||||
|
||||
if (nullptr != buffer) {
|
||||
arena_allocator.free(buffer);
|
||||
if (0 == size) {
|
||||
LOG_INFO("medium info serialize size is 0, just skip", K(ret));
|
||||
} else {
|
||||
int64_t pos = 0;
|
||||
char *buffer = static_cast<char*>(arena_allocator.alloc(size));
|
||||
if (OB_ISNULL(buffer)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to alloc memory", K(ret), K(size));
|
||||
} else if (OB_FAIL(medium_info->serialize(buffer, size, pos))) {
|
||||
LOG_WARN("failed to serialize medium info", K(ret));
|
||||
} else {
|
||||
write_info.reset();
|
||||
write_info.buffer_ = buffer;
|
||||
write_info.offset_ = 0;
|
||||
write_info.size_ = size;
|
||||
write_info.io_desc_.set_wait_event(ObWaitEventIds::DB_FILE_COMPACT_WRITE);
|
||||
if (OB_FAIL(reader_writer.async_link_write(write_info, write_handle))) {
|
||||
LOG_WARN("failed to do async link write", K(ret), K(write_info));
|
||||
} else if (OB_UNLIKELY(!write_handle.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected error, write handle is invalid", K(ret), K(write_handle));
|
||||
}
|
||||
}
|
||||
|
||||
if (nullptr != buffer) {
|
||||
arena_allocator.free(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (array.empty()) {
|
||||
addr.set_none_addr();
|
||||
} else {
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(write_handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret), K(write_handle));
|
||||
} else if (OB_FAIL(meta_write_ctxs.push_back(write_ctx))) {
|
||||
LOG_WARN("failed to push back write ctx", K(ret), K(write_ctx));
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (array.empty()) {
|
||||
addr.set_none_addr();
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
ObSharedBlocksWriteCtx write_ctx;
|
||||
if (OB_FAIL(write_handle.get_write_ctx(write_ctx))) {
|
||||
LOG_WARN("failed to get write ctx", K(ret), K(write_handle));
|
||||
} else if (OB_UNLIKELY(!write_ctx.is_valid())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("write ctx is invalid", K(ret), K(write_ctx));
|
||||
} else if (OB_FAIL(meta_write_ctxs.push_back(write_ctx))) {
|
||||
LOG_WARN("failed to push back write ctx", K(ret), K(write_ctx));
|
||||
} else {
|
||||
addr = write_ctx.addr_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -847,5 +859,80 @@ int ObTabletPersister::transform_tablet_memory_footprint(
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::fetch_table_store_and_write_info(
|
||||
const ObTablet &tablet,
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObTabletMemberWrapper<ObTabletTableStore> &wrapper,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObTabletTableStore new_table_store;
|
||||
const ObTabletTableStore *table_store = nullptr;
|
||||
ObTableStoreIterator table_iter;
|
||||
if (OB_FAIL(tablet.fetch_table_store(wrapper))) {
|
||||
LOG_WARN("fail to fetch table store", K(ret));
|
||||
} else if (OB_FAIL(wrapper.get_member(table_store))) {
|
||||
LOG_WARN("fail to get table store from wrapper", K(ret), K(wrapper));
|
||||
} else if (OB_FAIL(table_store->get_all_sstable(table_iter))) {
|
||||
LOG_WARN("fail to get all sstable iterator", K(ret), KPC(table_store));
|
||||
} else if (OB_FAIL(fetch_and_persist_sstable(allocator, table_iter, new_table_store, meta_write_ctxs))) {
|
||||
LOG_WARN("fail to fetch and persist sstable", K(ret), K(table_iter));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, &new_table_store, write_infos))) {
|
||||
LOG_WARN("fail to fill table store write info", K(ret), K(new_table_store));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::load_auto_inc_seq_and_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &complex_addr,
|
||||
const share::ObTabletAutoincSeq *&auto_inc_seq,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
ObMetaDiskAddr &addr)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
auto_inc_seq = nullptr;
|
||||
const share::ObTabletAutoincSeq *ptr = nullptr;
|
||||
|
||||
if (OB_UNLIKELY(!complex_addr.is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid args", K(ret), K(complex_addr));
|
||||
} else if (OB_FAIL(ObTabletMdsData::load_auto_inc_seq(allocator, complex_addr, ptr))) {
|
||||
LOG_WARN("failed to load auto inc seq", K(ret), K(complex_addr));
|
||||
} else if (nullptr == ptr) {
|
||||
addr.set_none_addr();
|
||||
} else if (OB_FAIL(fill_write_info(allocator, ptr, write_infos))) {
|
||||
LOG_WARN("fail to fill empty write info", K(ret));
|
||||
} else {
|
||||
auto_inc_seq = ptr;
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
ObTabletMdsData::free_auto_inc_seq(allocator, ptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletPersister::load_storage_schema_and_fill_write_info(
|
||||
const ObTablet &tablet,
|
||||
common::ObArenaAllocator &allocator,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObStorageSchema *storage_schema = nullptr;
|
||||
if (OB_FAIL(tablet.load_storage_schema(allocator, storage_schema))) {
|
||||
LOG_WARN("fail to load storage schema", K(ret));
|
||||
} else if (OB_ISNULL(storage_schema)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("storage schema is null", K(ret), KP(storage_schema));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, storage_schema, write_infos))) {
|
||||
LOG_WARN("fail to fill write info", K(ret), KP(storage_schema));
|
||||
}
|
||||
ObTablet::free_storage_schema(allocator, storage_schema);
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace storage
|
||||
} // end namespace oceanbase
|
||||
|
@ -90,12 +90,6 @@ public:
|
||||
const ObTablet &old_tablet,
|
||||
char *buf,
|
||||
const int64_t len);
|
||||
private:
|
||||
using FetchTableStore = std::function<int(ObTabletMemberWrapper<ObTabletTableStore> &)>;
|
||||
using FetchAutoincSeq = std::function<int(ObTabletMemberWrapper<share::ObTabletAutoincSeq> &)>;
|
||||
using LoadStorageSchema = std::function<int(common::ObArenaAllocator &, const ObStorageSchema *&)>;
|
||||
using LoadMediumInfoList = std::function<int(common::ObArenaAllocator &, const compaction::ObMediumCompactionInfoList *&)>;
|
||||
using LoadMdsDumpKV = std::function<int(common::ObArenaAllocator &, const mds::MdsDumpKV *&)>;
|
||||
private:
|
||||
static int check_tablet_meta_ids(
|
||||
const common::ObIArray<ObSharedBlocksWriteCtx> &tablet_meta_write_ctxs,
|
||||
@ -115,7 +109,6 @@ private:
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &tablet_meta_write_ctxs,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &sstable_meta_write_ctxs,
|
||||
ObTabletPoolType &type,
|
||||
ObTabletMemberWrapper<share::ObTabletAutoincSeq> &auto_inc_seq,
|
||||
ObTabletTransformArg &arg);
|
||||
static int convert_arg_to_tablet(
|
||||
const ObTabletTransformArg &arg,
|
||||
@ -142,32 +135,36 @@ private:
|
||||
ObTableStoreIterator &table_iter,
|
||||
ObTabletTableStore &new_table_store,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs);
|
||||
template <typename Fetch, typename T>
|
||||
static int fetch_wrapper_and_write_info(
|
||||
static int load_auto_inc_seq_and_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
Fetch &fetch,
|
||||
ObTabletMemberWrapper<T> &wrapper,
|
||||
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &complex_addr,
|
||||
const share::ObTabletAutoincSeq *&auto_inc_seq,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int fetch_table_store_and_write_info(
|
||||
const ObTablet &tablet,
|
||||
common::ObArenaAllocator &allocator,
|
||||
ObTabletMemberWrapper<ObTabletTableStore> &wrapper,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs);
|
||||
template <typename Load, typename T>
|
||||
static int load_member_and_write_info(
|
||||
static int load_storage_schema_and_fill_write_info(
|
||||
const ObTablet &tablet,
|
||||
common::ObArenaAllocator &allocator,
|
||||
Load &load,
|
||||
T *&t,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos);
|
||||
static int load_dump_kv_and_fill_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos);
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int load_medium_info_list_and_write(
|
||||
common::ObArenaAllocator &allocator,
|
||||
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr,
|
||||
ObMetaDiskAddr &addr,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs);
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs,
|
||||
ObMetaDiskAddr &addr);
|
||||
static int link_write_medium_info_list(
|
||||
const ObTabletDumpedMediumInfo &medium_info_list,
|
||||
ObMetaDiskAddr &addr,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs);
|
||||
const ObTabletDumpedMediumInfo *medium_info_list,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs,
|
||||
ObMetaDiskAddr &addr);
|
||||
template <typename T>
|
||||
static int fill_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
@ -191,78 +188,6 @@ private:
|
||||
ObTabletTableStore *&table_store);
|
||||
};
|
||||
|
||||
template <typename Fetch, typename T>
|
||||
int ObTabletPersister::fetch_wrapper_and_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
Fetch &fetch,
|
||||
ObTabletMemberWrapper<T> &wrapper,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
{
|
||||
UNUSED(meta_write_ctxs);
|
||||
int ret = common::OB_SUCCESS;
|
||||
const T *member = nullptr;
|
||||
if (OB_FAIL(fetch(wrapper))) {
|
||||
STORAGE_LOG(WARN, "fail to fetch tablet wrapper", K(ret));
|
||||
} else if (OB_FAIL(wrapper.get_member(member))) {
|
||||
STORAGE_LOG(WARN, "fail to get tablet member", K(ret), K(wrapper));
|
||||
} else if (OB_ISNULL(member)) {
|
||||
ret = common::OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "unexpected error, member is nullptr", K(ret), KP(member));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, member, write_infos))) {
|
||||
STORAGE_LOG(WARN, "fail to fill write info", K(ret), KP(member));
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline int ObTabletPersister::fetch_wrapper_and_write_info<ObTabletPersister::FetchTableStore, ObTabletTableStore>(
|
||||
common::ObArenaAllocator &allocator,
|
||||
FetchTableStore &fetch,
|
||||
ObTabletMemberWrapper<ObTabletTableStore> &wrapper,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos,
|
||||
common::ObIArray<ObSharedBlocksWriteCtx> &meta_write_ctxs)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
ObTabletTableStore new_table_store;
|
||||
const ObTabletTableStore *table_store = nullptr;
|
||||
ObTableStoreIterator table_iter;
|
||||
if (OB_FAIL(fetch(wrapper))) {
|
||||
STORAGE_LOG(WARN, "fail to fetch table store", K(ret));
|
||||
} else if (OB_FAIL(wrapper.get_member(table_store))) {
|
||||
STORAGE_LOG(WARN, "fail to get table store from wrapper", K(ret), K(wrapper));
|
||||
} else if (OB_ISNULL(table_store)) {
|
||||
ret = common::OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "unexpected error, table store is nullptr", K(ret), KP(table_store));
|
||||
} else if (OB_FAIL(table_store->get_all_sstable(table_iter))) {
|
||||
STORAGE_LOG(WARN, "fail to get all sstable iterator", K(ret), KPC(table_store));
|
||||
} else if (OB_FAIL(fetch_and_persist_sstable(allocator, table_iter, new_table_store, meta_write_ctxs))) {
|
||||
STORAGE_LOG(WARN, "fail to fetch and persist sstable", K(ret), K(table_iter));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, &new_table_store, write_infos))) {
|
||||
STORAGE_LOG(WARN, "fail to fill table store write info", K(ret), K(new_table_store));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename Load, typename T>
|
||||
int ObTabletPersister::load_member_and_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
Load &load,
|
||||
T *&t,
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
if (OB_FAIL(load(allocator, t))) {
|
||||
STORAGE_LOG(WARN, "fail to load tablet member", K(ret));
|
||||
} else if (OB_ISNULL(t)) {
|
||||
ret = common::OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "unexpected error, t is nullptr", K(ret), KP(t));
|
||||
} else if (OB_FAIL(fill_write_info(allocator, t, write_infos))) {
|
||||
STORAGE_LOG(WARN, "fail to fill write info", K(ret), KP(t));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObTabletPersister::fill_write_info(
|
||||
common::ObArenaAllocator &allocator,
|
||||
@ -270,9 +195,10 @@ int ObTabletPersister::fill_write_info(
|
||||
common::ObIArray<ObSharedBlockWriteInfo> &write_infos)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
|
||||
if (OB_ISNULL(t)) {
|
||||
ret = common::OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "unexpected error, tablet member is nullptr", K(ret), KP(t));
|
||||
ret = common::OB_INVALID_ARGUMENT;
|
||||
STORAGE_LOG(WARN, "invalid args", K(ret), KP(t));
|
||||
} else {
|
||||
const int64_t size = t->get_serialize_size();
|
||||
char *buf = static_cast<char *>(allocator.alloc(size));
|
||||
|
@ -94,7 +94,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 5, 4, true, info);
|
||||
@ -102,7 +102,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 7, 6, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 2, 1, true, info);
|
||||
@ -112,7 +112,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 6, 5, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 3;
|
||||
@ -136,7 +136,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 5, 4, true, info);
|
||||
@ -144,7 +144,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 7, 6, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 2, 1, true, info);
|
||||
@ -152,7 +152,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap)
|
||||
|
||||
{
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 1;
|
||||
@ -172,7 +172,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap)
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 4, 3, true, info);
|
||||
{
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 1;
|
||||
@ -198,7 +198,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap_and_filter)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 5, 4, true, info);
|
||||
@ -206,7 +206,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap_and_filter)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 7, 6, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 2, 1, true, info);
|
||||
@ -216,7 +216,7 @@ TEST_F(TestTabletDumpedMediumInfo, overlap_and_filter)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 6, 5, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 6;
|
||||
@ -236,7 +236,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap_and_filter)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 5, 4, true, info);
|
||||
@ -244,7 +244,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap_and_filter)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 7, 6, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 2, 1, true, info);
|
||||
@ -252,7 +252,7 @@ TEST_F(TestTabletDumpedMediumInfo, no_overlap_and_filter)
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 4, 3, true, info);
|
||||
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 7;
|
||||
@ -271,21 +271,21 @@ TEST_F(TestTabletDumpedMediumInfo, standby_cluster)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 7, 5, false, info);
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 9, 8, false, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 2, 1, false, info);
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 4, 2, false, info);
|
||||
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ret = result.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
|
||||
const int64_t finish_medium_scn = 3;
|
||||
@ -307,7 +307,7 @@ TEST_F(TestTabletDumpedMediumInfo, mds_table_dump)
|
||||
compaction::ObMediumCompactionInfo *info = nullptr;
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info1;
|
||||
ret = input_medium_info1.init(allocator);
|
||||
ret = input_medium_info1.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> mds_table_data;
|
||||
mds_table_data.ptr_ = &input_medium_info1;
|
||||
@ -316,7 +316,7 @@ TEST_F(TestTabletDumpedMediumInfo, mds_table_dump)
|
||||
APPEND_MEDIUM_INFO(input_medium_info1, allocator, 9, 7, false, info);
|
||||
|
||||
ObTabletDumpedMediumInfo input_medium_info2;
|
||||
ret = input_medium_info2.init(allocator);
|
||||
ret = input_medium_info2.init_for_first_creation(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> base_data;
|
||||
base_data.ptr_ = &input_medium_info2;
|
||||
@ -326,19 +326,17 @@ TEST_F(TestTabletDumpedMediumInfo, mds_table_dump)
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 6, 4, false, info);
|
||||
APPEND_MEDIUM_INFO(input_medium_info2, allocator, 7, 6, false, info);
|
||||
|
||||
ObTabletDumpedMediumInfo result;
|
||||
ret = result.init(allocator);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ObTabletComplexAddr<ObTabletDumpedMediumInfo> result_data;
|
||||
result_data.ptr_ = &result;
|
||||
ObTabletDumpedMediumInfo *&result = result_data.ptr_;
|
||||
|
||||
const int64_t finish_medium_scn = 4;
|
||||
ret = ObTabletMdsData::fuse_mds_dump_node(allocator, finish_medium_scn, mds_table_data, base_data, result_data);
|
||||
ret = ObTabletMdsData::init_single_complex_addr(allocator, mds_table_data, base_data, finish_medium_scn, result_data);
|
||||
ASSERT_EQ(OB_SUCCESS, ret);
|
||||
ASSERT_EQ(3, result.medium_info_list_.count());
|
||||
ASSERT_EQ(6, result.medium_info_list_.at(0)->medium_snapshot_);
|
||||
ASSERT_EQ(7, result.medium_info_list_.at(1)->medium_snapshot_);
|
||||
ASSERT_EQ(9, result.medium_info_list_.at(2)->medium_snapshot_);
|
||||
ASSERT_EQ(3, result->medium_info_list_.count());
|
||||
ASSERT_EQ(6, result->medium_info_list_.at(0)->medium_snapshot_);
|
||||
ASSERT_EQ(7, result->medium_info_list_.at(1)->medium_snapshot_);
|
||||
ASSERT_EQ(9, result->medium_info_list_.at(2)->medium_snapshot_);
|
||||
}
|
||||
} // namespace unittest
|
||||
} // namespace oceanbase
|
||||
|
@ -19,14 +19,15 @@
|
||||
#include "lib/ob_errno.h"
|
||||
#include "lib/oblog/ob_log_module.h"
|
||||
#include "share/ob_rpc_struct.h"
|
||||
#include "share/scn.h"
|
||||
#include "storage/tx/ob_trans_define.h"
|
||||
#include "storage/ls/ob_ls_tablet_service.h"
|
||||
#include "storage/ls/ob_ls.h"
|
||||
#include "share/scn.h"
|
||||
#include "storage/meta_mem/ob_tenant_meta_mem_mgr.h"
|
||||
#include "storage/tablet/ob_tablet_create_delete_helper.h"
|
||||
#include "storage/tablet/ob_tablet_obj_load_helper.h"
|
||||
#include "storage/tablet/ob_tablet_slog_helper.h"
|
||||
#include "storage/init_basic_struct.h"
|
||||
#include "storage/tablet/ob_tablet_create_delete_helper.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -112,12 +113,9 @@ inline int TestTabletHelper::create_tablet(
|
||||
|
||||
ObTabletCreateSSTableParam param;
|
||||
prepare_sstable_param(tablet_id, table_schema, param);
|
||||
void *buff = nullptr;
|
||||
ObSSTable *sstable = nullptr;
|
||||
if (OB_ISNULL(buff = allocator.alloc(sizeof(ObSSTable)))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
STORAGE_LOG(WARN, "fail to allocate memory", K(ret));
|
||||
} else if (FALSE_IT(sstable = new (buff) ObSSTable())) {
|
||||
if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, sstable))) {
|
||||
STORAGE_LOG(WARN, "fail to alloc and new", K(ret));
|
||||
} else if (OB_FAIL(ObTabletCreateDeleteHelper::create_sstable(param, allocator, *sstable))) {
|
||||
STORAGE_LOG(WARN, "failed to acquire sstable", K(ret));
|
||||
} else if (OB_FAIL(ObSSTableMergeRes::fill_column_checksum_for_empty_major(param.column_cnt_, param.column_checksums_))) {
|
||||
@ -145,13 +143,17 @@ inline int TestTabletHelper::create_tablet(
|
||||
if (tablet_status == ObTabletStatus::Status::DELETED) {
|
||||
data.delete_commit_scn_ = SCN::base_scn();
|
||||
}
|
||||
|
||||
ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_committed_kv = tablet_handle.get_obj()->mds_data_.tablet_status_.committed_kv_;
|
||||
const int64_t data_serialize_size = data.get_serialize_size();
|
||||
int64_t pos = 0;
|
||||
char *buf = static_cast<char *>(t3m->full_tablet_creator_.get_allocator().alloc(data_serialize_size));
|
||||
if (OB_FAIL(data.serialize(buf, data_serialize_size, pos))) {
|
||||
STORAGE_LOG(WARN, "data serialize failed", K(ret), K(data_serialize_size), K(pos));
|
||||
} else if (ObTabletObjLoadHelper::alloc_and_new(*tablet_handle.get_allocator(), tablet_status_committed_kv.ptr_)) {
|
||||
STORAGE_LOG(WARN, "failed to alloc and new", K(ret));
|
||||
} else {
|
||||
tablet_handle.get_obj()->mds_data_.tablet_status_.committed_kv_.get_ptr()->v_.user_data_.assign(buf, data_serialize_size);
|
||||
tablet_status_committed_kv.ptr_->v_.user_data_.assign(buf, data_serialize_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user