[manual CP] fix poor performance due to aux tablet info cache miss

This commit is contained in:
hiddenbomb 2023-11-06 11:09:41 +00:00 committed by ob-robot
parent 001eedfcf6
commit 0cf6465414
17 changed files with 367 additions and 210 deletions

View File

@ -171,8 +171,8 @@ public:
virtual int deep_copy(
char *dst_buf,
const int64_t buf_size,
storage::ObIStorageMetaObj *&value) const;
virtual int64_t get_deep_copy_size() const { return sizeof(ObTabletAutoincSeq) + sizeof(ObTabletAutoincInterval) * intervals_count_; }
storage::ObIStorageMetaObj *&value) const override;
virtual int64_t get_deep_copy_size() const override { return sizeof(ObTabletAutoincSeq) + sizeof(ObTabletAutoincInterval) * intervals_count_; }
virtual void reset() override;
virtual bool is_valid() const override;
virtual inline int64_t get_data_size() const override { return get_deep_copy_size(); }

View File

@ -17,13 +17,12 @@
#include "lib/stat/ob_diagnose_info.h"
#include "lib/statistic_event/ob_stat_event.h"
#include "share/io/ob_io_struct.h"
#include "share/ob_tablet_autoincrement_param.h"
#include "storage/blocksstable/ob_sstable.h"
#include "storage/blocksstable/ob_storage_cache_suite.h"
#include "storage/slog_ckpt/ob_tenant_checkpoint_slog_handler.h"
#include "storage/tablet/ob_tablet_table_store.h"
#include "storage/tablet/ob_tablet.h"
#include "share/ob_tablet_autoincrement_param.h"
#include "storage/tablet/ob_tablet.h"
#include "storage/blocksstable/ob_storage_cache_suite.h"
#include "storage/column_store/ob_column_oriented_sstable.h"
#include "storage/meta_mem/ob_tenant_meta_mem_mgr.h"
@ -115,6 +114,7 @@ ObStorageMetaValue::StorageMetaProcessor ObStorageMetaValue::processor[ObStorage
ObStorageMetaValue::process_co_sstable,
ObStorageMetaValue::process_table_store,
ObStorageMetaValue::process_autoinc_seq,
ObStorageMetaValue::process_aux_tablet_info
};
ObStorageMetaValue::StorageMetaBypassProcessor ObStorageMetaValue::bypass_processor[MetaType::MAX]
@ -122,6 +122,7 @@ ObStorageMetaValue::StorageMetaBypassProcessor ObStorageMetaValue::bypass_proces
ObStorageMetaValue::bypass_process_storage_meta<storage::ObCOSSTableV2>,
nullptr, // not support bypass process table store.
ObStorageMetaValue::bypass_process_storage_meta<share::ObTabletAutoincSeq>,
ObStorageMetaValue::bypass_process_storage_meta_for_aux_tablet_info
};
@ -247,6 +248,21 @@ int ObStorageMetaValue::get_autoinc_seq(const share::ObTabletAutoincSeq *&seq) c
return ret;
}
int ObStorageMetaValue::get_aux_tablet_info(const ObTabletBindingMdsUserData *&aux_tablet_info) const
{
int ret = OB_SUCCESS;
if (OB_ISNULL(obj_)) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret));
} else if (OB_UNLIKELY(MetaType::AUX_TABLET_INFO != type_)) {
ret = OB_STATE_NOT_MATCH;
LOG_WARN("not aux tablet info", K(ret), K(type_));
} else {
aux_tablet_info = static_cast<ObTabletBindingMdsUserData *>(obj_);
}
return ret;
}
int ObStorageMetaValue::process_sstable(
ObStorageMetaValueHandle &handle,
const ObStorageMetaKey &key,
@ -401,6 +417,98 @@ int ObStorageMetaValue::process_autoinc_seq(
return ret;
}
int ObStorageMetaValue::process_aux_tablet_info(
ObStorageMetaValueHandle &handle,
const ObStorageMetaKey &key,
const char *buf,
const int64_t size,
const ObTablet *tablet)
{
UNUSED(tablet);
int ret = OB_SUCCESS;
ObArenaAllocator allocator(common::ObMemAttr(MTL_ID(), "AuxTabletInfo"));
mds::MdsDumpKV dump_kv;
ObTabletBindingMdsUserData aux_tablet_info;
ObIStorageMetaObj *tiny_meta = nullptr;
int64_t pos = 0;
if (OB_ISNULL(buf) || OB_UNLIKELY(size <= 0 || !handle.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguments", K(ret), KP(buf), K(size), K(handle));
} else if (OB_FAIL(dump_kv.deserialize(allocator, buf, size, pos))) {
LOG_WARN("fail to deserialize mds dump kv", K(ret), KP(buf), K(size));
} else {
pos = 0; // reset pos
char *tmp_buf = nullptr;
const common::ObString &str = dump_kv.v_.user_data_;
if (OB_FAIL(aux_tablet_info.deserialize(str.ptr(), str.length(), pos))) {
LOG_WARN("fail to deserialize aux tablet info", K(ret), K(str));
} else if (OB_ISNULL(tmp_buf = static_cast<char *>(allocator.alloc(aux_tablet_info.get_deep_copy_size())))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocate buffer", K(ret), "deep_copy_size", aux_tablet_info.get_deep_copy_size());
} else if (OB_FAIL(aux_tablet_info.deep_copy(tmp_buf, aux_tablet_info.get_deep_copy_size(), tiny_meta))) {
LOG_WARN("fail to deep copy auto inc seq", K(ret), KP(tmp_buf), K(aux_tablet_info));
} else {
ObStorageMetaCacheValue *cache_value = handle.get_cache_value();
ObStorageMetaValue value(MetaType::AUX_TABLET_INFO, tiny_meta);
if (OB_FAIL(OB_STORE_CACHE.get_storage_meta_cache().put_and_fetch(key, value, cache_value->value_, cache_value->cache_handle_))) {
LOG_WARN("fail to put and fetch value into storage meta cache", K(ret), K(key), K(value), K(cache_value));
}
}
}
if (OB_NOT_NULL(tiny_meta)) {
tiny_meta->~ObIStorageMetaObj();
}
return ret;
}
int ObStorageMetaValue::bypass_process_storage_meta_for_aux_tablet_info(
const MetaType type,
common::ObSafeArenaAllocator &allocator,
ObStorageMetaValueHandle &handle,
const char *buf,
const int64_t size)
{
int ret = OB_SUCCESS;
ObArenaAllocator tmp_allocator(common::ObMemAttr(MTL_ID(), "ProcMetaVaule"));
int64_t pos = 0;
mds::MdsDumpKV dump_kv;
char *buffer = nullptr;
if (OB_ISNULL(buf) || OB_UNLIKELY(size <= 0 || !handle.is_valid())) {
ret = OB_INVALID_ARGUMENT;
STORAGE_LOG(WARN, "invalid arguments", K(ret), KP(buf), K(size), K(handle));
} else if (OB_UNLIKELY(type != ObStorageMetaValue::AUX_TABLET_INFO)) {
ret = OB_INVALID_ARGUMENT;
STORAGE_LOG(WARN, "invalid meta type", K(ret), K(type));
} else if (OB_FAIL(dump_kv.deserialize(tmp_allocator, buf, size, pos))) {
STORAGE_LOG(WARN, "fail to deserialize ", K(ret), KP(buf), K(size));
} else {
pos = 0;
ObTabletBindingMdsUserData aux_tablet_info;
const common::ObString &str = dump_kv.v_.user_data_;
if (OB_FAIL(aux_tablet_info.deserialize(str.ptr(), str.length(), pos))) {
STORAGE_LOG(WARN, "fail to deserialize aux tablet info", K(ret), K(str));
} else {
ObIStorageMetaObj *tiny_meta = nullptr;
const int64_t buffer_pos = sizeof(ObStorageMetaValue);
const int64_t buffer_size = sizeof(ObStorageMetaValue) + aux_tablet_info.get_deep_copy_size();
if (OB_ISNULL(buffer = static_cast<char *>(allocator.alloc(buffer_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
STORAGE_LOG(WARN, "fail to allocate memory", K(ret), K(buffer_size));
} else {
if (OB_FAIL(aux_tablet_info.deep_copy(buffer + buffer_pos, aux_tablet_info.get_deep_copy_size(), tiny_meta))) {
STORAGE_LOG(WARN, "fail to deserialize aux tablet info", K(ret), KP(buf), K(size));
} else {
handle.get_cache_value()->value_ = new (buffer) ObStorageMetaValue(type, tiny_meta);
}
}
}
}
return ret;
}
ObStorageMetaValueHandle::ObStorageMetaValueHandle(const ObStorageMetaValueHandle &other)
: cache_value_(nullptr),
allocator_(nullptr)

View File

@ -13,9 +13,11 @@
#ifndef OCEANBASE_STORAGE_OB_STORAGE_META_CACHE_H_
#define OCEANBASE_STORAGE_OB_STORAGE_META_CACHE_H_
#include "lib/literals/ob_literals.h"
#include "share/cache/ob_kv_storecache.h"
#include "storage/meta_mem/ob_meta_obj_struct.h"
#include "storage/blockstore/ob_shared_block_reader_writer.h"
#include "storage/tablet/ob_tablet_binding_mds_user_data.h"
namespace oceanbase
{
@ -35,6 +37,7 @@ namespace storage
class ObTablet;
class ObTabletTableStore;
class ObTabletBindingMdsUserData;
class ObStorageMetaCache;
class ObStorageMetaValueHandle;
@ -69,11 +72,12 @@ class ObStorageMetaValue final : public common::ObIKVCacheValue
public:
enum MetaType : uint16_t
{
SSTABLE = 0,
CO_SSTABLE = 1,
TABLE_STORE = 2,
AUTO_INC_SEQ = 3,
MAX = 4,
SSTABLE = 0,
CO_SSTABLE = 1,
TABLE_STORE = 2,
AUTO_INC_SEQ = 3,
AUX_TABLET_INFO = 4,
MAX = 5,
};
public:
ObStorageMetaValue();
@ -85,6 +89,7 @@ public:
int get_sstable(blocksstable::ObSSTable *&sstable) const;
int get_table_store(const ObTabletTableStore *&store) const;
int get_autoinc_seq(const share::ObTabletAutoincSeq *&seq) const;
int get_aux_tablet_info(const ObTabletBindingMdsUserData *&aux_tablet_info) const;
bool is_valid() const;
void reset()
{
@ -118,6 +123,12 @@ public:
const char *buf,
const int64_t size,
const ObTablet *tablet);
static int process_aux_tablet_info(
ObStorageMetaValueHandle &handle,
const ObStorageMetaKey &key,
const char *buf,
const int64_t size,
const ObTablet *tablet);
TO_STRING_KV(K_(type), KP_(obj));
public:
typedef int (*StorageMetaProcessor)(
@ -142,6 +153,12 @@ private:
ObStorageMetaValueHandle &handle,
const char *buf,
const int64_t size);
static int bypass_process_storage_meta_for_aux_tablet_info(
const MetaType type,
common::ObSafeArenaAllocator &allocator,
ObStorageMetaValueHandle &handle,
const char *buf,
const int64_t size);
private:
MetaType type_;
ObIStorageMetaObj *obj_;
@ -290,8 +307,8 @@ int ObStorageMetaValue::bypass_process_storage_meta(
ObArenaAllocator tmp_allocator(common::ObMemAttr(MTL_ID(), "ProcMetaVaule"));
int64_t pos = 0;
T t;
char *buff = nullptr;
ObTimeGuard time_guard("bypass_process", 10000); //10ms
char *buffer = nullptr;
ObTimeGuard time_guard("bypass_process", 10_ms);
if (OB_ISNULL(buf) || OB_UNLIKELY(size <= 0 || !handle.is_valid())) {
ret = OB_INVALID_ARGUMENT;
STORAGE_LOG(WARN, "invalid arguments", K(ret), KP(buf), K(size), K(handle));
@ -300,19 +317,16 @@ int ObStorageMetaValue::bypass_process_storage_meta(
} else {
time_guard.click("deserialize");
ObIStorageMetaObj *tiny_meta = nullptr;
const int64_t buff_pos = sizeof(ObStorageMetaValue);
const int64_t buff_size = sizeof(ObStorageMetaValue) + t.get_deep_copy_size();
if (OB_ISNULL(buff = static_cast<char *>(allocator.alloc(buff_size)))) {
const int64_t buffer_pos = sizeof(ObStorageMetaValue);
const int64_t buffer_size = sizeof(ObStorageMetaValue) + t.get_deep_copy_size();
if (OB_ISNULL(buffer = static_cast<char *>(allocator.alloc(buffer_size)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
STORAGE_LOG(WARN, "fail to allocate memory", K(ret), K(buff_size));
STORAGE_LOG(WARN, "fail to allocate memory", K(ret), K(buffer_size));
} else if (OB_FAIL(t.deep_copy(buffer + buffer_pos, t.get_deep_copy_size(), tiny_meta))) {
STORAGE_LOG(WARN, "fail to deserialize T", K(ret), KP(buf), K(size));
} else {
if (OB_FAIL(t.deep_copy(buff + buff_pos, t.get_deep_copy_size(), tiny_meta))) {
STORAGE_LOG(WARN, "fail to deserialize sstable", K(ret), KP(buf), K(size));
} else {
time_guard.click("deep_copy");
handle.get_cache_value()->value_ = new (buff) ObStorageMetaValue(type, tiny_meta);
time_guard.click("new_metaValue");
}
time_guard.click("deep_copy");
handle.get_cache_value()->value_ = new (buffer) ObStorageMetaValue(type, tiny_meta);
}
}
return ret;

View File

@ -18,6 +18,7 @@
#include "storage/meta_mem/ob_tablet_pointer.h"
#include "storage/tablet/ob_tablet_mds_data.h"
#include "storage/tablet/ob_tablet_member_wrapper.h"
#include "storage/tablet/ob_tablet_obj_load_helper.h"
#include "storage/ls/ob_ls_switch_checker.h"
namespace oceanbase

View File

@ -144,7 +144,7 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<ObTabletCreateDeleteM
MDS_TG(10_ms);
int ret = OB_SUCCESS;
ObTabletCreateDeleteMdsUserData data;
const mds::MdsDumpKV *kv = nullptr;
mds::MdsDumpKV *kv = nullptr;
ObArenaAllocator allocator("mds_reader");
const ObTabletComplexAddr<mds::MdsDumpKV> &tablet_status_addr = get_mds_data_().tablet_status_.committed_kv_;
const ObTabletCreateDeleteMdsUserData &tablet_status_cache = get_mds_data_().tablet_status_cache_;
@ -179,7 +179,7 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<ObTabletCreateDeleteM
}
}
ObTabletMdsData::free_mds_dump_kv(allocator, kv);
ObTabletObjLoadHelper::free(allocator, kv);
}
return ret;
#undef PRINT_WRAPPER
@ -189,53 +189,23 @@ template <>
inline int ObITabletMdsInterface::get_mds_data_from_tablet<ObTabletBindingMdsUserData>(
const common::ObFunction<int(const ObTabletBindingMdsUserData&)> &read_op) const
{
#define PRINT_WRAPPER KR(ret), K(data), KPC(kv), K(*this)
#define PRINT_WRAPPER KR(ret), K(aux_tablet_info_addr), K(*this)
MDS_TG(10_ms);
int ret = OB_SUCCESS;
ObTabletBindingMdsUserData data;
const mds::MdsDumpKV *kv = nullptr;
ObTabletBindingMdsUserData *aux_tablet_info = nullptr;
ObArenaAllocator allocator("mds_reader");
const ObTabletComplexAddr<mds::MdsDumpKV> &aux_tablet_info_addr = get_mds_data_().aux_tablet_info_.committed_kv_;
const ObTabletBindingMdsUserData &aux_tablet_info_cache = get_mds_data_().aux_tablet_info_cache_;
if (aux_tablet_info_addr.is_memory_object()) {
if (CLICK_FAIL(read_op(aux_tablet_info_cache))) {
MDS_LOG_GET(WARN, "failed to read_op");
}
} else if (aux_tablet_info_addr.is_none_object()) {
if (CLICK_FAIL(ObTabletMdsData::load_aux_tablet_info(allocator, aux_tablet_info_addr, aux_tablet_info))) {
MDS_LOG_GET(WARN, "failed to load auto inc seq");
} else if (nullptr == aux_tablet_info) {
ret = OB_EMPTY_RESULT;
} else if (aux_tablet_info_addr.is_disk_object()) {
if (aux_tablet_info_cache.is_valid()) {
if (CLICK_FAIL(read_op(aux_tablet_info_cache))) {
MDS_LOG_GET(WARN, "failed to read_op");
}
} else {
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 (nullptr == kv) {
ret = OB_EMPTY_RESULT;
} else {
const common::ObString &user_data = kv->v_.user_data_;
int64_t pos = 0;
if (user_data.empty()) {
ret = OB_EMPTY_RESULT;
} else if (CLICK_FAIL(data.deserialize(user_data.ptr(), user_data.length(), pos))) {
MDS_LOG_GET(WARN, "failed to deserialize", K(user_data),
"user_data_length", user_data.length(),
"user_hash:%x", user_data.hash(),
"crc_check_number", kv->v_.crc_check_number_);
} else if (CLICK_FAIL(read_op(data))) {
MDS_LOG_GET(WARN, "failed to read_op");
}
}
ObTabletMdsData::free_mds_dump_kv(allocator, kv);
}
} else {
ret = OB_ERR_UNEXPECTED;
MDS_LOG_GET(WARN, "unexpected addr", K(aux_tablet_info_addr));
} else if (CLICK_FAIL(read_op(*aux_tablet_info))) {
MDS_LOG_GET(WARN, "failed to read_op");
}
ObTabletObjLoadHelper::free(allocator, aux_tablet_info);
return ret;
#undef PRINT_WRAPPER
}
@ -248,7 +218,7 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<share::ObTabletAutoin
MDS_TG(10_ms);
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;
share::ObTabletAutoincSeq *auto_inc_seq = nullptr;
ObArenaAllocator allocator("mds_reader");
if (CLICK_FAIL(ObTabletMdsData::load_auto_inc_seq(allocator, auto_inc_seq_addr, auto_inc_seq))) {
@ -259,7 +229,7 @@ inline int ObITabletMdsInterface::get_mds_data_from_tablet<share::ObTabletAutoin
MDS_LOG_GET(WARN, "failed to read_op");
}
ObTabletMdsData::free_auto_inc_seq(allocator, auto_inc_seq);
ObTabletObjLoadHelper::free(allocator, auto_inc_seq);
return ret;
#undef PRINT_WRAPPER
@ -667,7 +637,7 @@ int ObITabletMdsInterface::fill_virtual_info_by_complex_addr_(const ObTabletComp
ObArenaAllocator allocator("vir_mds_reader");
mds::MdsNodeInfoForVirtualTable *cur_virtual_info = nullptr;
mds::UserMdsNode<mds::DummyKey, T> user_mds_node;
const mds::MdsDumpKV *dump_kv = nullptr;
mds::MdsDumpKV *dump_kv = nullptr;
if (CLICK_FAIL(mds_node_info_array.push_back(mds::MdsNodeInfoForVirtualTable()))) {
MDS_LOG_GET(WARN, "fail to push_back");
@ -697,7 +667,7 @@ int ObITabletMdsInterface::fill_virtual_info_by_complex_addr_(const ObTabletComp
}
}
ObTabletMdsData::free_mds_dump_kv(allocator, dump_kv);
ObTabletObjLoadHelper::free(allocator, dump_kv);
}
return ret;
#undef PRINT_WRAPPER

View File

@ -233,7 +233,7 @@ ObTablet::ObTablet()
table_store_cache_()
{
#if defined(__x86_64__) && !defined(ENABLE_OBJ_LEAK_CHECK)
static_assert(sizeof(ObTablet) + sizeof(ObRowkeyReadInfo) == 1672, "The size of ObTablet will affect the meta memory manager, and the necessity of adding new fields needs to be considered.");
static_assert(sizeof(ObTablet) + sizeof(ObRowkeyReadInfo) <= 1672, "The size of ObTablet will affect the meta memory manager, and the necessity of adding new fields needs to be considered.");
#endif
MEMSET(memtables_, 0x0, sizeof(memtables_));
}
@ -983,7 +983,7 @@ int ObTablet::read_medium_info_list(
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr = mds_data_.medium_info_list_;
int64_t finish_medium_scn = 0;
ObTabletDumpedMediumInfo mds_table_medium_info_list;
const ObTabletDumpedMediumInfo *base_medium_info_list = nullptr;
ObTabletDumpedMediumInfo *base_medium_info_list = nullptr;
ObTabletDumpedMediumInfo fused_medium_info_list;
if (OB_UNLIKELY(!is_inited_)) {
@ -1027,7 +1027,7 @@ int ObTablet::read_medium_info_list(
}
}
ObTabletMdsData::free_medium_info_list(allocator, base_medium_info_list);
ObTabletObjLoadHelper::free(allocator, base_medium_info_list);
return ret;
}
@ -5093,7 +5093,7 @@ int ObTablet::check_medium_list() const
LOG_WARN("fail to fetch table store", K(ret));
} else if (OB_NOT_NULL(last_major = table_store_wrapper.get_member()->get_major_sstables().get_boundary_table(true/*last*/))) {
ObArenaAllocator arena_allocator("check_medium", OB_MALLOC_NORMAL_BLOCK_SIZE, MTL_ID());
const ObTabletDumpedMediumInfo *dumped_list = nullptr;
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(ls_id), K(tablet_id), K(mds_data_));
} else if (OB_FAIL(ObMediumListChecker::validate_medium_info_list(
@ -5102,7 +5102,7 @@ int ObTablet::check_medium_list() const
last_major->get_snapshot_version()))) {
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);
ObTabletObjLoadHelper::free(arena_allocator, dumped_list);
}
} else {
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_);
@ -6003,7 +6003,7 @@ int ObTablet::load_medium_info_list(
compaction::ObMediumCompactionInfoList &medium_info_list)
{
int ret = OB_SUCCESS;
const ObTabletDumpedMediumInfo *list = nullptr;
ObTabletDumpedMediumInfo *list = nullptr;
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));
@ -6011,7 +6011,7 @@ int ObTablet::load_medium_info_list(
LOG_WARN("failed to init", K(ret));
}
ObTabletMdsData::free_medium_info_list(allocator, list);
ObTabletObjLoadHelper::free(allocator, list);
return ret;
}
@ -6133,7 +6133,7 @@ int ObTablet::convert_to_mds_dump_kv(
int ObTablet::get_tablet_status_uncommitted_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv)
mds::MdsDumpKV *&kv)
{
int ret = OB_SUCCESS;
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr = mds_data_.tablet_status_.uncommitted_kv_;
@ -6150,7 +6150,7 @@ int ObTablet::get_tablet_status_uncommitted_mds_dump_kv(
int ObTablet::get_tablet_status_committed_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv)
mds::MdsDumpKV *&kv)
{
int ret = OB_SUCCESS;
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr = mds_data_.tablet_status_.committed_kv_;
@ -6167,7 +6167,7 @@ int ObTablet::get_tablet_status_committed_mds_dump_kv(
int ObTablet::get_aux_tablet_info_uncommitted_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv)
mds::MdsDumpKV *&kv)
{
int ret = OB_SUCCESS;
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr = mds_data_.aux_tablet_info_.uncommitted_kv_;
@ -6184,7 +6184,7 @@ int ObTablet::get_aux_tablet_info_uncommitted_mds_dump_kv(
int ObTablet::get_aux_tablet_info_committed_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv)
mds::MdsDumpKV *&kv)
{
int ret = OB_SUCCESS;
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr = mds_data_.aux_tablet_info_.committed_kv_;
@ -6215,7 +6215,7 @@ int ObTablet::get_auto_inc_seq_mds_dump_kv(
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, kv))) {
LOG_WARN("failed to alloc and new", K(ret));
} else {
const share::ObTabletAutoincSeq *auto_inc_seq = nullptr;
share::ObTabletAutoincSeq *auto_inc_seq = nullptr;
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) {

View File

@ -511,16 +511,16 @@ public:
// tablet mds data read interface
int get_tablet_status_uncommitted_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv);
mds::MdsDumpKV *&kv);
int get_tablet_status_committed_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv);
mds::MdsDumpKV *&kv);
int get_aux_tablet_info_uncommitted_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv);
mds::MdsDumpKV *&kv);
int get_aux_tablet_info_committed_mds_dump_kv(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *&kv);
mds::MdsDumpKV *&kv);
int get_auto_inc_seq_mds_dump_kv(
common::ObIAllocator &allocator,
mds::MdsDumpKV *&kv);

View File

@ -122,6 +122,36 @@ void ObTabletBindingMdsUserData::on_commit(const share::SCN &commit_version, con
return;
}
int ObTabletBindingMdsUserData::deep_copy(char *buf, const int64_t buf_len, ObIStorageMetaObj *&value) const
{
int ret = OB_SUCCESS;
value = nullptr;
const int64_t deep_copy_size = get_deep_copy_size();
if (OB_ISNULL(buf) || OB_UNLIKELY(buf_len < deep_copy_size)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invaild argument", K(ret), KP(buf), K(buf_len), K(deep_copy_size));
} else {
ObTabletBindingMdsUserData *aux_tablet_info = new (buf) ObTabletBindingMdsUserData();
if (OB_FAIL(aux_tablet_info->assign(*this))) {
LOG_WARN("failed to copy", K(ret), KPC(this));
} else {
value = aux_tablet_info;
}
if (OB_FAIL(ret)) {
aux_tablet_info->~ObTabletBindingMdsUserData();
}
}
return ret;
}
int64_t ObTabletBindingMdsUserData::get_deep_copy_size() const
{
return sizeof(ObTabletBindingMdsUserData);
}
OB_SERIALIZE_MEMBER(
ObTabletBindingMdsUserData,
redefined_,

View File

@ -18,6 +18,7 @@
#include "lib/utility/ob_print_utils.h"
#include "share/scn.h"
#include "common/ob_tablet_id.h"
#include "storage/meta_mem/ob_storage_meta_cache.h"
namespace oceanbase
{
@ -30,17 +31,21 @@ namespace storage
{
class ObTabletBindingInfo;
class ObTabletBindingMdsUserData
class ObTabletBindingMdsUserData : public ObIStorageMetaObj
{
public:
OB_UNIS_VERSION(1);
public:
ObTabletBindingMdsUserData();
~ObTabletBindingMdsUserData() = default;
virtual ~ObTabletBindingMdsUserData() = default;
ObTabletBindingMdsUserData(const ObTabletBindingMdsUserData &) = delete;
ObTabletBindingMdsUserData &operator=(const ObTabletBindingMdsUserData &) = delete;
public:
virtual int deep_copy(char *buf, const int64_t buf_len, ObIStorageMetaObj *&value) const override;
virtual int64_t get_deep_copy_size() const override;
public:
bool is_valid() const;
int set_allocator(common::ObIAllocator &allocator);

View File

@ -129,7 +129,7 @@ int ObTabletFullMemoryMdsData::read_mds_dump_kv(
mds::MdsDumpKV &dump_kv)
{
int ret = OB_SUCCESS;
const mds::MdsDumpKV *ptr = nullptr;
mds::MdsDumpKV *ptr = nullptr;
if (OB_UNLIKELY(!mds_dump_kv_addr.is_valid())) {
ret = OB_INVALID_ARGUMENT;
@ -143,7 +143,7 @@ int ObTabletFullMemoryMdsData::read_mds_dump_kv(
LOG_WARN("failed to copy mds dump kv", K(ret));
}
ObTabletMdsData::free_mds_dump_kv(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
return ret;
}
@ -154,7 +154,7 @@ int ObTabletFullMemoryMdsData::read_medium_info_list(
ObTabletDumpedMediumInfo &medium_info_list)
{
int ret = OB_SUCCESS;
const ObTabletDumpedMediumInfo *ptr = nullptr;
ObTabletDumpedMediumInfo *ptr = nullptr;
if (OB_UNLIKELY(!medium_info_list_addr.is_valid())) {
ret = OB_INVALID_ARGUMENT;
@ -167,7 +167,7 @@ int ObTabletFullMemoryMdsData::read_medium_info_list(
LOG_WARN("failed to copy medium info list", K(ret));
}
ObTabletMdsData::free_medium_info_list(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
return ret;
}
@ -178,7 +178,7 @@ int ObTabletFullMemoryMdsData::read_auto_inc_seq(
share::ObTabletAutoincSeq &auto_inc_seq)
{
int ret = OB_SUCCESS;
const share::ObTabletAutoincSeq *ptr = nullptr;
share::ObTabletAutoincSeq *ptr = nullptr;
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));

View File

@ -95,8 +95,7 @@ ObTabletMdsData::ObTabletMdsData()
extra_medium_info_(),
medium_info_list_(),
auto_inc_seq_(),
tablet_status_cache_(),
aux_tablet_info_cache_()
tablet_status_cache_()
{
}
@ -113,18 +112,17 @@ void ObTabletMdsData::reset()
aux_tablet_info_.reset();
tablet_status_.reset();
tablet_status_cache_.reset();
aux_tablet_info_cache_.reset();
is_inited_ = false;
}
void ObTabletMdsData::reset(common::ObIAllocator &allocator)
{
free_auto_inc_seq(allocator, auto_inc_seq_.ptr_);
free_medium_info_list(allocator, medium_info_list_.ptr_);
free_mds_dump_kv(allocator, aux_tablet_info_.uncommitted_kv_.ptr_);
free_mds_dump_kv(allocator, aux_tablet_info_.committed_kv_.ptr_);
free_mds_dump_kv(allocator, tablet_status_.uncommitted_kv_.ptr_);
free_mds_dump_kv(allocator, tablet_status_.committed_kv_.ptr_);
ObTabletObjLoadHelper::free(allocator, auto_inc_seq_.ptr_);
ObTabletObjLoadHelper::free(allocator, medium_info_list_.ptr_);
ObTabletObjLoadHelper::free(allocator, aux_tablet_info_.uncommitted_kv_.ptr_);
ObTabletObjLoadHelper::free(allocator, aux_tablet_info_.committed_kv_.ptr_);
ObTabletObjLoadHelper::free(allocator, tablet_status_.uncommitted_kv_.ptr_);
ObTabletObjLoadHelper::free(allocator, tablet_status_.committed_kv_.ptr_);
auto_inc_seq_.ptr_ = nullptr;
auto_inc_seq_.addr_.reset();
@ -223,8 +221,6 @@ int ObTabletMdsData::init_for_mds_table_dump(
LOG_WARN("failed to init single complex addr", K(ret));
} else if (OB_FAIL(update_user_data_from_complex_addr(tablet_status_.committed_kv_, tablet_status_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", tablet_status_.committed_kv_);
} else if (OB_FAIL(update_user_data_from_complex_addr(aux_tablet_info_.committed_kv_, aux_tablet_info_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", aux_tablet_info_.committed_kv_);
} else {
// always use base data to set extra medium info
extra_medium_info_ = base_data.extra_medium_info_;
@ -252,8 +248,8 @@ int ObTabletMdsData::init_single_complex_addr(
int ret = OB_SUCCESS;
fused_data.reset();
mds::MdsDumpKV *&fused_data_ptr = fused_data.ptr_;
const mds::MdsDumpKV *mds_table_ptr = nullptr;
const mds::MdsDumpKV *base_ptr = nullptr;
mds::MdsDumpKV *mds_table_ptr = nullptr;
mds::MdsDumpKV *base_ptr = nullptr;
if (OB_FAIL(load_mds_dump_kv(allocator, mds_table_data, mds_table_ptr))) {
LOG_WARN("failed to load mds dump kv", K(ret));
@ -268,13 +264,13 @@ int ObTabletMdsData::init_single_complex_addr(
} else if (nullptr != mds_table_ptr) {
// data in mds table is not empty, ignore data in base, use data in mds table as fused data
fused_data_ptr = const_cast<mds::MdsDumpKV*>(mds_table_ptr);
free_mds_dump_kv(allocator, base_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr);
}
if (OB_FAIL(ret)) {
fused_data_ptr = nullptr;
free_mds_dump_kv(allocator, mds_table_ptr);
free_mds_dump_kv(allocator, base_ptr);
ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr);
} else {
fused_data.addr_.set_mem_addr(0, sizeof(mds::MdsDumpKV));
}
@ -292,8 +288,8 @@ int ObTabletMdsData::init_single_complex_addr(
int ret = OB_SUCCESS;
fused_data.reset();
share::ObTabletAutoincSeq *&fused_data_ptr = fused_data.ptr_;
const share::ObTabletAutoincSeq *mds_table_ptr = nullptr;
const share::ObTabletAutoincSeq *base_ptr = nullptr;
share::ObTabletAutoincSeq *mds_table_ptr = nullptr;
share::ObTabletAutoincSeq *base_ptr = nullptr;
if (OB_FAIL(load_auto_inc_seq(allocator, mds_table_data, mds_table_ptr))) {
LOG_WARN("failed to load auto inc seq", K(ret), K(mds_table_data));
@ -308,13 +304,13 @@ int ObTabletMdsData::init_single_complex_addr(
} else if (nullptr != mds_table_ptr) {
// data in mds table is not empty, ignore data in base, use data in mds table as fused data
fused_data_ptr = const_cast<share::ObTabletAutoincSeq*>(mds_table_ptr);
free_auto_inc_seq(allocator, base_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr);
}
if (OB_FAIL(ret)) {
fused_data_ptr = nullptr;
free_auto_inc_seq(allocator, mds_table_ptr);
free_auto_inc_seq(allocator, base_ptr);
ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr);
} else {
fused_data.addr_.set_mem_addr(0, sizeof(share::ObTabletAutoincSeq));
}
@ -333,8 +329,8 @@ int ObTabletMdsData::init_single_complex_addr(
int ret = OB_SUCCESS;
fused_data.reset();
ObTabletDumpedMediumInfo *&fused_data_ptr = fused_data.ptr_;
const ObTabletDumpedMediumInfo *mds_table_ptr = nullptr;
const ObTabletDumpedMediumInfo *base_ptr = nullptr;
ObTabletDumpedMediumInfo *mds_table_ptr = nullptr;
ObTabletDumpedMediumInfo *base_ptr = nullptr;
if (OB_FAIL(load_medium_info_list(allocator, mds_table_data, mds_table_ptr))) {
LOG_WARN("failed to load medium info list", K(ret), K(mds_table_data));
@ -361,15 +357,15 @@ int ObTabletMdsData::init_single_complex_addr(
}
if (OB_FAIL(ret)) {
free_medium_info_list(allocator, fused_data_ptr);
ObTabletObjLoadHelper::free(allocator, fused_data_ptr);
fused_data_ptr = nullptr;
} else {
fused_data.addr_.set_mem_addr(0, sizeof(ObTabletDumpedMediumInfo));
}
// always free medium info list after usage
free_medium_info_list(allocator, mds_table_ptr);
free_medium_info_list(allocator, base_ptr);
ObTabletObjLoadHelper::free(allocator, mds_table_ptr);
ObTabletObjLoadHelper::free(allocator, base_ptr);
}
return ret;
@ -401,8 +397,6 @@ int ObTabletMdsData::init_for_evict_medium_info(
LOG_WARN("failed to init single complex addr", K(ret));
} else if (OB_FAIL(update_user_data_from_complex_addr(tablet_status_.committed_kv_, tablet_status_cache_))) {
LOG_WARN("failed to update user data", K(ret), "complex_addr", tablet_status_.committed_kv_);
} else if (OB_FAIL(update_user_data_from_complex_addr(aux_tablet_info_.committed_kv_, aux_tablet_info_cache_))) {
LOG_WARN("failed to update user data", K(ret), "complex_addr", aux_tablet_info_.committed_kv_);
} else if (is_major_merge_type(merge_type)) {
extra_medium_info_.last_compaction_type_ = is_major_merge(merge_type) ? compaction::ObMediumCompactionInfo::MAJOR_COMPACTION : compaction::ObMediumCompactionInfo::MEDIUM_COMPACTION;
extra_medium_info_.last_medium_scn_ = finish_medium_scn;
@ -432,7 +426,7 @@ int ObTabletMdsData::init_single_complex_addr(
{
int ret = OB_SUCCESS;
dst_addr.reset();
const mds::MdsDumpKV *ptr = nullptr;
mds::MdsDumpKV *ptr = nullptr;
if (OB_FAIL(load_mds_dump_kv(allocator, src_addr, ptr))) {
LOG_WARN("failed to load mds dump kv", K(ret), K(src_addr));
@ -453,7 +447,7 @@ int ObTabletMdsData::init_single_complex_addr(
{
int ret = OB_SUCCESS;
dst_addr.reset();
const share::ObTabletAutoincSeq *ptr = nullptr;
share::ObTabletAutoincSeq *ptr = nullptr;
share::ObTabletAutoincSeq *&dst_data = dst_addr.ptr_;
if (OB_FAIL(load_auto_inc_seq(allocator, src_addr, ptr))) {
@ -477,7 +471,7 @@ int ObTabletMdsData::init_single_complex_addr(
{
int ret = OB_SUCCESS;
dst_addr.reset();
const ObTabletDumpedMediumInfo *ptr = nullptr;
ObTabletDumpedMediumInfo *ptr = nullptr;
ObTabletDumpedMediumInfo *&dst_data = dst_addr.ptr_;
if (OB_FAIL(load_medium_info_list(allocator, src_addr, ptr))) {
@ -490,7 +484,7 @@ int ObTabletMdsData::init_single_complex_addr(
LOG_WARN("failed to init", K(ret));
} else if (dst_data->medium_info_list_.empty()) {
// dst data is empty, so no need to keep it
free_medium_info_list(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
dst_addr.addr_.set_none_addr();
} else {
@ -498,12 +492,12 @@ int ObTabletMdsData::init_single_complex_addr(
}
if (OB_FAIL(ret)) {
free_medium_info_list(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
}
// always free ptr after usage
free_medium_info_list(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
return ret;
}
@ -532,8 +526,6 @@ int ObTabletMdsData::init_by_full_memory_mds_data(
LOG_WARN("failed to init single complex addr", K(ret));
} else if (OB_FAIL(update_user_data_from_complex_addr(tablet_status_.committed_kv_, tablet_status_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", tablet_status_.committed_kv_);
} else if (OB_FAIL(update_user_data_from_complex_addr(aux_tablet_info_.committed_kv_, aux_tablet_info_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", aux_tablet_info_.committed_kv_);
} else {
extra_medium_info_ = full_memory_mds_data.medium_info_list_.extra_medium_info_;
}
@ -574,7 +566,7 @@ int ObTabletMdsData::init_single_complex_addr(
}
if (OB_FAIL(ret)) {
free_mds_dump_kv(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
}
@ -602,7 +594,7 @@ int ObTabletMdsData::init_single_complex_addr(
}
if (OB_FAIL(ret)) {
free_auto_inc_seq(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
}
@ -630,7 +622,7 @@ int ObTabletMdsData::init_single_complex_addr(
}
if (OB_FAIL(ret)) {
free_medium_info_list(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
}
@ -649,7 +641,7 @@ int ObTabletMdsData::init_single_complex_addr_and_extra_info(
{
int ret = OB_SUCCESS;
dst_addr.reset();
const ObTabletDumpedMediumInfo *ptr = nullptr;
ObTabletDumpedMediumInfo *ptr = nullptr;
ObTabletDumpedMediumInfo *&dst_data = dst_addr.ptr_;
bool empty_data_from_src_data = (!src_data.is_valid() || src_data.medium_info_list_.empty());
@ -678,10 +670,10 @@ int ObTabletMdsData::init_single_complex_addr_and_extra_info(
}
if (OB_FAIL(ret)) {
free_medium_info_list(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
} else if (dst_data->medium_info_list_.empty()) {
free_medium_info_list(allocator, dst_data);
ObTabletObjLoadHelper::free(allocator, dst_data);
dst_data = nullptr;
dst_addr.addr_.set_none_addr();
} else {
@ -704,7 +696,7 @@ int ObTabletMdsData::init_single_complex_addr_and_extra_info(
}
// always free ptr after usage
free_medium_info_list(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
return ret;
}
@ -733,8 +725,6 @@ int ObTabletMdsData::init_for_merge_with_full_mds_data(
LOG_WARN("failed to init single complex addr", K(ret));
} else if (OB_FAIL(update_user_data_from_complex_addr(tablet_status_.committed_kv_, tablet_status_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", tablet_status_.committed_kv_);
} else if (OB_FAIL(update_user_data_from_complex_addr(aux_tablet_info_.committed_kv_, aux_tablet_info_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", aux_tablet_info_.committed_kv_);
} else if (OB_FAIL(init_single_complex_addr_and_extra_info(
allocator,
other.medium_info_list_,
@ -785,8 +775,6 @@ int ObTabletMdsData::init_with_update_medium_info(
LOG_WARN("failed to init single complex addr", K(ret));
} else if (OB_FAIL(update_user_data_from_complex_addr(tablet_status_.committed_kv_, tablet_status_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", tablet_status_.committed_kv_);
} else if (OB_FAIL(update_user_data_from_complex_addr(aux_tablet_info_.committed_kv_, aux_tablet_info_cache_))) {
LOG_WARN("failed to update user data cache", K(ret), "complex_addr", aux_tablet_info_.committed_kv_);
} else {
const int64_t finish_medium_scn = other.extra_medium_info_.last_medium_scn_;
if (OB_FAIL(init_single_complex_addr(allocator, other.medium_info_list_, finish_medium_scn, medium_info_list_))) {
@ -988,7 +976,7 @@ int ObTabletMdsData::copy_medium_info_list(
int ObTabletMdsData::load_mds_dump_kv(
common::ObIAllocator &allocator,
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
const mds::MdsDumpKV *&kv)
mds::MdsDumpKV *&kv)
{
int ret = OB_SUCCESS;
kv = nullptr;
@ -1004,7 +992,7 @@ int ObTabletMdsData::load_mds_dump_kv(
} else if (complex_addr.is_memory_object()) {
const mds::MdsDumpKV *src_kv = complex_addr.ptr_;
if (src_kv->v_.user_data_.empty()) {
free_mds_dump_kv(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty user data", K(ret), K(complex_addr));
} else if (OB_FAIL(ptr->assign(*src_kv, allocator))) {
@ -1026,7 +1014,7 @@ int ObTabletMdsData::load_mds_dump_kv(
// and ptr should be set to null
const mds::MdsDumpNode &dump_node = ptr->v_;
if (dump_node.user_data_.empty()) {
free_mds_dump_kv(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty user data", K(ret), K(complex_addr));
}
@ -1050,7 +1038,7 @@ int ObTabletMdsData::load_mds_dump_kv(
int ObTabletMdsData::load_medium_info_list(
common::ObIAllocator &allocator,
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr,
const ObTabletDumpedMediumInfo *&medium_info_list)
ObTabletDumpedMediumInfo *&medium_info_list)
{
int ret = OB_SUCCESS;
medium_info_list = nullptr;
@ -1066,7 +1054,7 @@ int ObTabletMdsData::load_medium_info_list(
} else if (complex_addr.is_memory_object()) {
const ObTabletDumpedMediumInfo *src_medium_info = complex_addr.ptr_;
if (src_medium_info->medium_info_list_.empty()) {
free_medium_info_list(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty medium info", K(ret), K(complex_addr));
} else if (OB_FAIL(ptr->assign(*src_medium_info, allocator))) {
@ -1076,7 +1064,7 @@ int ObTabletMdsData::load_medium_info_list(
if (OB_FAIL(read_medium_info(allocator, complex_addr.addr_, ptr->medium_info_list_))) {
LOG_WARN("failed to read medium info", K(ret), "addr", complex_addr.addr_);
} else if (ptr->medium_info_list_.empty()) {
free_medium_info_list(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty medium info", K(ret), K(complex_addr));
} else {
@ -1104,7 +1092,7 @@ int ObTabletMdsData::load_medium_info_list(
int ObTabletMdsData::load_auto_inc_seq(
common::ObIAllocator &allocator,
const ObTabletComplexAddr<share::ObTabletAutoincSeq> &complex_addr,
const share::ObTabletAutoincSeq *&auto_inc_seq)
share::ObTabletAutoincSeq *&auto_inc_seq)
{
int ret = OB_SUCCESS;
auto_inc_seq = nullptr;
@ -1120,7 +1108,7 @@ int ObTabletMdsData::load_auto_inc_seq(
} else if (complex_addr.is_memory_object()) {
const share::ObTabletAutoincSeq *src_auto_inc_seq = complex_addr.ptr_;
if (!src_auto_inc_seq->is_valid()) {
free_auto_inc_seq(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty auto inc seq", K(ret), K(complex_addr));
} else if (OB_FAIL(ptr->assign(allocator, *src_auto_inc_seq))) {
@ -1142,7 +1130,7 @@ int ObTabletMdsData::load_auto_inc_seq(
LOG_WARN("unexpected null member", K(ret));
} else if (!auto_inc_seq_cache->is_valid()) {
// no need to copy
free_auto_inc_seq(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("empty auto inc seq", K(ret));
} else if (OB_FAIL(ptr->assign(allocator, *auto_inc_seq_cache))) {
@ -1164,34 +1152,69 @@ int ObTabletMdsData::load_auto_inc_seq(
return ret;
}
void ObTabletMdsData::free_mds_dump_kv(
int ObTabletMdsData::load_aux_tablet_info(
common::ObIAllocator &allocator,
const mds::MdsDumpKV *kv)
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
ObTabletBindingMdsUserData *&aux_tablet_info)
{
if (nullptr != kv) {
kv->mds::MdsDumpKV::~MdsDumpKV();
allocator.free(const_cast<mds::MdsDumpKV*>(kv));
}
}
int ret = OB_SUCCESS;
aux_tablet_info = nullptr;
ObTabletBindingMdsUserData *ptr = nullptr;
void ObTabletMdsData::free_auto_inc_seq(
common::ObIAllocator &allocator,
const share::ObTabletAutoincSeq *auto_inc_seq)
{
if (nullptr != auto_inc_seq) {
auto_inc_seq->share::ObTabletAutoincSeq::~ObTabletAutoincSeq();
allocator.free(const_cast<share::ObTabletAutoincSeq*>(auto_inc_seq));
if (OB_UNLIKELY(!complex_addr.is_valid())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid addr", K(ret), K(complex_addr));
} else if (complex_addr.is_none_object()) {
// do nothing
} else if (OB_FAIL(ObTabletObjLoadHelper::alloc_and_new(allocator, ptr))) {
LOG_WARN("failed to alloc and new", K(ret));
} else if (complex_addr.is_memory_object()) {
const mds::MdsDumpKV *dump_kv = complex_addr.ptr_;
const common::ObString &str = dump_kv->v_.user_data_;
int64_t pos = 0;
if (!dump_kv->is_valid() || !str.empty()) {
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("read empty aux tablet info", K(ret), K(complex_addr));
} else if (OB_FAIL(ptr->deserialize(str.ptr(), str.length(), pos))) {
LOG_WARN("failed to deserialize aux tablet info", K(ret), K(str));
}
} else if (complex_addr.is_disk_object()) {
ObTabletMemberWrapper<ObTabletBindingMdsUserData> wrapper;
ObStorageMetaHandle handle;
ObStorageMetaKey meta_key(MTL_ID(), complex_addr.addr_);
const ObTablet *tablet = nullptr; // no use here
const ObTabletBindingMdsUserData *aux_tablet_info_cache = nullptr;
if (OB_FAIL(OB_STORE_CACHE.get_storage_meta_cache().get_meta(ObStorageMetaValue::MetaType::AUX_TABLET_INFO,
meta_key, handle, tablet))) {
LOG_WARN("get meta failed", K(ret), K(meta_key));
} else if (OB_FAIL(wrapper.set_cache_handle(handle))) {
LOG_WARN("wrapper set cache handle failed", K(ret), K(meta_key), K(complex_addr));
} else if (OB_ISNULL(aux_tablet_info_cache = wrapper.get_member())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected null member", K(ret));
} else if (!aux_tablet_info_cache->is_valid()) {
// no need to copy
ObTabletObjLoadHelper::free(allocator, ptr);
ptr = nullptr;
LOG_INFO("empty aux tablet info", K(ret));
} else if (OB_FAIL(ptr->assign(*aux_tablet_info_cache))) {
LOG_WARN("failed to copy", K(ret));
}
} else {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected complex addr type", K(ret), K(complex_addr));
}
}
void ObTabletMdsData::free_medium_info_list(
common::ObIAllocator &allocator,
const ObTabletDumpedMediumInfo *medium_info_list)
{
if (nullptr != medium_info_list) {
medium_info_list->~ObTabletDumpedMediumInfo();
allocator.free(const_cast<ObTabletDumpedMediumInfo*>(medium_info_list));
if (OB_FAIL(ret)) {
if (nullptr != ptr) {
allocator.free(ptr);
}
} else {
aux_tablet_info = ptr;
}
return ret;
}
int ObTabletMdsData::read_medium_info(
@ -1501,13 +1524,6 @@ int ObTabletMdsData::build_aux_tablet_info(
node->user_data_.assign(buffer, serialize_size);
}
// set aux tablet info cache
if (OB_FAIL(ret)) {
} else if (tx_data.is_in_tx()) {
} else if (OB_FAIL(mds_data.aux_tablet_info_cache_.assign(user_data))) {
LOG_WARN("failed to set aux tablet info cache", K(ret), K(user_data));
}
if (OB_FAIL(ret) && OB_NOT_NULL(buffer)) {
allocator.free(buffer);
}

View File

@ -112,30 +112,24 @@ public:
K_(extra_medium_info),
K_(medium_info_list),
K_(auto_inc_seq),
K_(tablet_status_cache),
K_(aux_tablet_info_cache));
K_(tablet_status_cache));
public:
static int load_mds_dump_kv(
common::ObIAllocator &allocator,
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
const mds::MdsDumpKV *&kv);
mds::MdsDumpKV *&kv);
static int load_medium_info_list(
common::ObIAllocator &allocator,
const ObTabletComplexAddr<ObTabletDumpedMediumInfo> &complex_addr,
const ObTabletDumpedMediumInfo *&medium_info_list);
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(
share::ObTabletAutoincSeq *&auto_inc_seq);
static int load_aux_tablet_info(
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);
const ObTabletComplexAddr<mds::MdsDumpKV> &complex_addr,
ObTabletBindingMdsUserData *&aux_tablet_info);
static int build_tablet_status(
common::ObArenaAllocator &allocator,
const ObTabletTxMultiSourceDataUnit &tx_data,
@ -246,8 +240,7 @@ public:
ObTabletComplexAddr<ObTabletDumpedMediumInfo> medium_info_list_;
ObTabletComplexAddr<share::ObTabletAutoincSeq> auto_inc_seq_;
ObTabletCreateDeleteMdsUserData tablet_status_cache_;
ObTabletBindingMdsUserData aux_tablet_info_cache_;
ObTabletCreateDeleteMdsUserData tablet_status_cache_; // redundant data for tablet status
};
template <typename T>

View File

@ -54,7 +54,7 @@ int ObTabletMediumInfoReader::init(common::ObArenaAllocator &allocator)
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;
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), K(ls_id), K(tablet_id));
@ -76,7 +76,7 @@ int ObTabletMediumInfoReader::init(common::ObArenaAllocator &allocator)
allocator_ = &allocator;
}
ObTabletMdsData::free_medium_info_list(allocator, dumped_medium_info);
ObTabletObjLoadHelper::free(allocator, dumped_medium_info);
}
if (OB_SUCC(ret)) {

View File

@ -28,9 +28,13 @@ namespace storage
// only allow such classes to specialize template class ObTabletMemberWrapper:
// ObTabletTableStore
// ObTabletAutoincSeq
// ObTabletBindingMdsUserData
// forbidden classes: ObStorageSchema, ObMediumCompactionInfoList
template <typename T,
typename U = typename std::enable_if<std::is_same<T, ObTabletTableStore>::value || std::is_same<T, share::ObTabletAutoincSeq>::value, T>::type>
typename U = typename std::enable_if<std::is_same<T, ObTabletTableStore>::value
|| std::is_same<T, share::ObTabletAutoincSeq>::value
|| std::is_same<T, ObTabletBindingMdsUserData>::value,
T>::type>
class ObTabletMemberWrapper final
{
public:
@ -127,6 +131,19 @@ inline int ObTabletMemberWrapper<share::ObTabletAutoincSeq>::set_cache_handle(co
return ret;
}
template <>
inline int ObTabletMemberWrapper<ObTabletBindingMdsUserData>::set_cache_handle(const ObStorageMetaValue &value)
{
int ret = OB_SUCCESS;
const ObTabletBindingMdsUserData *aux_tablet_info = nullptr;
if (OB_FAIL(value.get_aux_tablet_info(aux_tablet_info))) {
STORAGE_LOG(WARN, "get aux tablet info failed", K(ret));
} else {
ptr_ = aux_tablet_info;
}
return ret;
}
template <typename T, typename U>
int ObTabletMemberWrapper<T, U>::get_member(const T *&t) const
{

View File

@ -35,6 +35,9 @@ public:
template <typename T>
static int alloc_and_new(common::ObIAllocator &allocator, T *&ptr);
template <typename T>
static void free(common::ObIAllocator &allocator, T *&ptr);
static int read_from_addr(
common::ObArenaAllocator &allocator,
const ObMetaDiskAddr &meta_addr,
@ -57,6 +60,16 @@ int ObTabletObjLoadHelper::alloc_and_new(common::ObIAllocator &allocator, T *&pt
return ret;
}
template <typename T>
void ObTabletObjLoadHelper::free(common::ObIAllocator &allocator, T *&ptr)
{
if (nullptr != ptr) {
ptr->~T();
allocator.free(ptr);
ptr = nullptr;
}
}
} // namespace storage
} // namespace oceanbase

View File

@ -42,7 +42,6 @@ ObTabletTransformArg::ObTabletTransformArg()
medium_info_list_addr_(),
auto_inc_seq_addr_(),
tablet_status_cache_(),
aux_tablet_info_cache_(),
is_row_store_(true),
ddl_kvs_(nullptr),
ddl_kv_count_(0),
@ -71,7 +70,6 @@ void ObTabletTransformArg::reset()
medium_info_list_addr_.reset();
auto_inc_seq_addr_.reset();
tablet_status_cache_.reset();
aux_tablet_info_cache_.reset();
is_row_store_ = true;
ddl_kvs_ = nullptr;
ddl_kv_count_ = 0;
@ -240,8 +238,6 @@ int ObTabletPersister::convert_tablet_to_mem_arg(
LOG_WARN("old tablet isn't valid, don't allow to degrade tablet memory", K(ret), K(tablet));
} else if (CLICK_FAIL(arg.tablet_status_cache_.assign(tablet.mds_data_.tablet_status_cache_))) {
LOG_WARN("fail to assign tablet status cache", K(ret), K(tablet));
} else if (CLICK_FAIL(arg.aux_tablet_info_cache_.assign(tablet.mds_data_.aux_tablet_info_cache_))) {
LOG_WARN("fail to assign aux tablet info cache", K(ret), K(tablet));
} else if (CLICK_FAIL(arg.tablet_meta_.assign(tablet.tablet_meta_))) {
LOG_WARN("fail to assign tablet meta", K(ret), K(tablet));
} else if (CLICK_FAIL(tablet.fetch_autoinc_seq(auto_inc_seq))) {
@ -296,8 +292,6 @@ int ObTabletPersister::convert_tablet_to_disk_arg(
if (CLICK_FAIL(arg.tablet_status_cache_.assign(tablet.mds_data_.tablet_status_cache_))) {
LOG_WARN("fail to assign tablet status cache", K(ret), K(tablet));
} else if (CLICK_FAIL(arg.aux_tablet_info_cache_.assign(tablet.mds_data_.aux_tablet_info_cache_))) {
LOG_WARN("fail to assign aux tablet info cache", K(ret), K(tablet));
} else if (CLICK_FAIL(arg.tablet_meta_.assign(tablet.tablet_meta_))) {
LOG_WARN("fail to assign tablet meta", K(ret), K(tablet));
} else if (FALSE_IT(arg.rowkey_read_info_ptr_ = tablet.rowkey_read_info_)) {
@ -499,9 +493,7 @@ int ObTabletPersister::convert_arg_to_tablet(
} else if (OB_FAIL(tablet.tablet_meta_.assign(arg.tablet_meta_))) {
LOG_WARN("fail to assign tablet meta", K(ret), K(arg.tablet_meta_));
} else if (OB_FAIL(tablet.mds_data_.tablet_status_cache_.assign(arg.tablet_status_cache_))) {
LOG_WARN("fail to assign tablet status cache", K(ret), K(arg.aux_tablet_info_cache_));
} else if (OB_FAIL(tablet.mds_data_.aux_tablet_info_cache_.assign(arg.aux_tablet_info_cache_))) {
LOG_WARN("fail to assign aux tablet info cache", K(ret), K(arg.aux_tablet_info_cache_));
LOG_WARN("fail to assign tablet status cache", K(ret), K(arg.tablet_status_cache_));
} else if (OB_FAIL(tablet.assign_memtables(arg.memtables_, arg.memtable_count_))) {
LOG_WARN("fail to assign memtables", K(ret), KP(arg.memtables_), K(arg.memtable_count_));
} else {
@ -881,7 +873,7 @@ int ObTabletPersister::load_dump_kv_and_fill_write_info(
ObMetaDiskAddr &addr)
{
int ret = OB_SUCCESS;
const mds::MdsDumpKV *kv = nullptr;
mds::MdsDumpKV *kv = nullptr;
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));
@ -894,7 +886,7 @@ int ObTabletPersister::load_dump_kv_and_fill_write_info(
}
}
ObTabletMdsData::free_mds_dump_kv(allocator, kv);
ObTabletObjLoadHelper::free(allocator, kv);
return ret;
}
@ -906,7 +898,7 @@ int ObTabletPersister::load_medium_info_list_and_write(
ObMetaDiskAddr &addr)
{
int ret = OB_SUCCESS;
const ObTabletDumpedMediumInfo *medium_info_list = nullptr;
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));
@ -918,7 +910,7 @@ int ObTabletPersister::load_medium_info_list_and_write(
}
}
ObTabletMdsData::free_medium_info_list(allocator, medium_info_list);
ObTabletObjLoadHelper::free(allocator, medium_info_list);
return ret;
}
@ -1099,7 +1091,7 @@ int ObTabletPersister::load_auto_inc_seq_and_write_info(
{
int ret = OB_SUCCESS;
auto_inc_seq = nullptr;
const share::ObTabletAutoincSeq *ptr = nullptr;
share::ObTabletAutoincSeq *ptr = nullptr;
if (OB_UNLIKELY(!complex_addr.is_valid())) {
ret = OB_INVALID_ARGUMENT;
@ -1115,7 +1107,7 @@ int ObTabletPersister::load_auto_inc_seq_and_write_info(
}
if (OB_FAIL(ret)) {
ObTabletMdsData::free_auto_inc_seq(allocator, ptr);
ObTabletObjLoadHelper::free(allocator, ptr);
}
return ret;

View File

@ -49,7 +49,6 @@ public:
K_(medium_info_list_addr),
K_(auto_inc_seq_addr),
K_(tablet_status_cache),
K_(aux_tablet_info_cache),
K_(is_row_store));
public:
const share::ObTabletAutoincSeq *auto_inc_seq_ptr_;
@ -65,7 +64,6 @@ public:
ObMetaDiskAddr medium_info_list_addr_;
ObMetaDiskAddr auto_inc_seq_addr_;
ObTabletCreateDeleteMdsUserData tablet_status_cache_;
ObTabletBindingMdsUserData aux_tablet_info_cache_;
bool is_row_store_;
ObITable **ddl_kvs_;
int64_t ddl_kv_count_;