replace ObProtectedMemtableMgrHandle::has_memtable to ObTablet::has_memtable

This commit is contained in:
obdev 2024-02-07 11:19:15 +00:00 committed by ob-robot
parent 7f369f3383
commit e6433a4d06
7 changed files with 34 additions and 28 deletions

View File

@ -526,11 +526,11 @@ int ObBasicTabletMergeCtx::swap_tablet()
return ret;
}
bool ObBasicTabletMergeCtx::need_swap_tablet(const ObTablet &tablet,
bool ObBasicTabletMergeCtx::need_swap_tablet(ObProtectedMemtableMgrHandle &memtable_mgr_handle,
const int64_t row_count,
const int64_t macro_count)
{
bool bret = tablet.has_memtable()
bool bret = memtable_mgr_handle.has_memtable()
&& (row_count >= LARGE_VOLUME_DATA_ROW_COUNT_THREASHOLD
|| macro_count >= LARGE_VOLUME_DATA_MACRO_COUNT_THREASHOLD);
#ifdef ERRSIM
@ -1031,6 +1031,7 @@ int ObBasicTabletMergeCtx::swap_tablet(ObGetMergeTablesResult &get_merge_table_r
LOG_WARN("ha status is not allowed major", KR(ret), KPC(this));
} else {
ObTablesHandleArray &tables_handle = get_merge_table_result.handle_;
ObProtectedMemtableMgrHandle *protected_handle = NULL;
int64_t row_count = 0;
int64_t macro_count = 0;
const ObSSTable *sstable = nullptr;
@ -1039,7 +1040,9 @@ int ObBasicTabletMergeCtx::swap_tablet(ObGetMergeTablesResult &get_merge_table_r
row_count += sstable->get_row_count();
macro_count += sstable->get_data_macro_block_count();
} // end of for
if (need_swap_tablet(*get_tablet(), row_count, macro_count)) {
if (OB_FAIL(get_tablet()->get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(get_tablet()));
} else if (need_swap_tablet(*protected_handle, row_count, macro_count)) {
tables_handle.reset(); // clear tables array
if (OB_FAIL(swap_tablet())) {
LOG_WARN("failed to get alloc tablet handle", KR(ret));

View File

@ -204,7 +204,7 @@ public:
int update_storage_schema_by_memtable(
const ObStorageSchema &schema_on_tablet,
const ObTablesHandleArray &merge_tables_handle);
static bool need_swap_tablet(const ObTablet &tablet, const int64_t row_count, const int64_t macro_count);
static bool need_swap_tablet(ObProtectedMemtableMgrHandle &memtable_mgr_handle, const int64_t row_count, const int64_t macro_count);
VIRTUAL_TO_STRING_KV(K_(static_param), K_(static_desc), K_(parallel_merge_ctx), K_(tablet_handle),
K_(info_collector), KP_(merge_dag));
protected:

View File

@ -1022,6 +1022,7 @@ int ObTenantTabletScheduler::fill_minor_compaction_param(
compaction_param.add_time_ = create_time;
compaction_param.sstable_cnt_ = total_sstable_cnt;
compaction_param.parallel_dag_cnt_ = parallel_dag_cnt;
ObProtectedMemtableMgrHandle *protected_handle = NULL;
ObITable *table = nullptr;
int64_t row_count = 0;
@ -1041,8 +1042,12 @@ int ObTenantTabletScheduler::fill_minor_compaction_param(
}
if (OB_SUCC(ret)) {
compaction_param.estimate_concurrent_count(MINOR_MERGE);
param.need_swap_tablet_flag_ = ObBasicTabletMergeCtx::need_swap_tablet(*tablet_handle.get_obj(), row_count, macro_count);
if (OB_FAIL(tablet_handle.get_obj()->get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(tablet_handle.get_obj()));
} else {
compaction_param.estimate_concurrent_count(MINOR_MERGE);
param.need_swap_tablet_flag_ = ObBasicTabletMergeCtx::need_swap_tablet(*protected_handle, row_count, macro_count);
}
}
return ret;
}

View File

@ -794,7 +794,10 @@ int ObFreezer::tablet_freeze_with_rewrite_meta(const ObTabletID &tablet_id)
} else if (OB_FAIL(protected_handle->set_is_tablet_freeze_for_active_memtable(frozen_memtable_handle))) {
if (ret == OB_ENTRY_NOT_EXIST) {
ret = OB_SUCCESS;
if (!tablet->has_memtable()) {
ObProtectedMemtableMgrHandle *protected_handle = NULL;
if (OB_FAIL(tablet->get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(tablet));
} else if (!protected_handle->has_memtable()) {
// We need trigger a dag to rewrite the snapshot version of tablet
// meta for the major merge and medium merge. While the implementation
// need pay much attentio.

View File

@ -360,8 +360,6 @@ int ObTabletPointerMap::load_and_hook_meta_obj(
} else {
if (OB_FAIL(meta_pointer->hook_obj(t, guard))) {
STORAGE_LOG(WARN, "fail to hook object", K(ret), KP(meta_pointer));
} else if (OB_FAIL(guard.get_obj()->assign_pointer_handle(ptr_hdl))) {
STORAGE_LOG(WARN, "fail to assign pointer handle", K(ret));
}
}
} // write lock end
@ -411,6 +409,8 @@ int ObTabletPointerMap::load_meta_obj(
}
} else if (OB_FAIL(meta_pointer->read_from_disk(true/*is_full_load*/, arena_allocator, buf, buf_len, load_addr))) {
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
} else if (OB_FAIL(t->assign_pointer_handle(tmp_ptr_hdl))) {
STORAGE_LOG(WARN, "fail to assign pointer handle", K(ret), K(tmp_ptr_hdl));
} else {
t->tablet_addr_ = load_addr;
if (OB_FAIL(meta_pointer->deserialize(allocator, buf, buf_len, t))) {
@ -456,6 +456,8 @@ int ObTabletPointerMap::load_meta_obj(
}
} else if (OB_FAIL(meta_pointer->read_from_disk(false/*is_full_load*/, arena_allocator, buf, buf_len, load_addr))) {
STORAGE_LOG(WARN, "fail to read from disk", K(ret), KPC(meta_pointer));
} else if (OB_FAIL(t->assign_pointer_handle(tmp_ptr_hdl))) {
STORAGE_LOG(WARN, "fail to assign pointer handle", K(ret), K(tmp_ptr_hdl));
} else {
t->tablet_addr_ = load_addr;
if (OB_FAIL(meta_pointer->deserialize(buf, buf_len, t))) {
@ -551,8 +553,6 @@ int ObTabletPointerMap::get_meta_obj_with_external_memory(
}
} else if (OB_FAIL(t->deserialize_post_work(allocator))) {
STORAGE_LOG(WARN, "fail to deserialize post work", K(ret), KP(t));
} else if (OB_FAIL(t->assign_pointer_handle(ptr_hdl))) {
STORAGE_LOG(WARN, "fail to assign pointer handle", K(ret), KP(t));
} else {
ObTenantMetaMemMgr *t3m = MTL(ObTenantMetaMemMgr*);
guard.set_obj(t, &allocator, t3m);

View File

@ -5699,6 +5699,7 @@ int ObTablet::set_memtable_clog_checkpoint_scn(
ObTableHandleV2 handle;
memtable::ObMemtable *memtable = nullptr;
ObProtectedMemtableMgrHandle *protected_handle = NULL;
if (OB_UNLIKELY(!is_inited_)) {
ret = OB_NOT_INIT;
LOG_WARN("not inited", K(ret), K_(is_inited));
@ -5707,7 +5708,9 @@ int ObTablet::set_memtable_clog_checkpoint_scn(
} else if (tablet_meta->clog_checkpoint_scn_ <= tablet_meta_.clog_checkpoint_scn_) {
// do nothing
} else if (is_ls_inner_tablet()) {
if (OB_UNLIKELY(has_memtable())) {
if (OB_FAIL(get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(this));
} else if (OB_UNLIKELY(protected_handle->has_memtable())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("ls inner tablet should not have memtable", K(ret), KPC(tablet_meta));
}
@ -5965,7 +5968,10 @@ int ObTablet::pull_memtables_without_ddl()
int ret = OB_SUCCESS;
ObTableHandleArray memtable_handles;
if (!has_memtable()) {
ObProtectedMemtableMgrHandle *protected_handle = NULL;
if (OB_FAIL(get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(this));
} else if (!protected_handle->has_memtable()) {
LOG_TRACE("no memtable in memtable mgr", K(ret));
} else if (OB_FAIL(get_all_memtables(memtable_handles))) {
LOG_WARN("failed to get all memtable", K(ret), KPC(this));
@ -6059,7 +6065,10 @@ int ObTablet::update_memtables()
int ret = OB_SUCCESS;
ObTableHandleArray inc_memtables;
if (!has_memtable()) {
ObProtectedMemtableMgrHandle *protected_handle = NULL;
if (OB_FAIL(get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(ret), KPC(this));
} else if (!protected_handle->has_memtable()) {
LOG_INFO("no memtable in memtable mgr", K(ret), "ls_id", tablet_meta_.ls_id_, "tablet_id", tablet_meta_.tablet_id_);
} else if (OB_FAIL(get_all_memtables(inc_memtables))) {
LOG_WARN("failed to get all memtable", K(ret), KPC(this));
@ -7286,19 +7295,6 @@ int ObTablet::set_frozen_for_all_memtables()
return ret;
}
bool ObTablet::has_memtable() const
{
bool ret = false;
int tmp_ret = OB_SUCCESS;
ObProtectedMemtableMgrHandle *protected_handle = NULL;
if (OB_TMP_FAIL(get_protected_memtable_mgr_handle(protected_handle))) {
LOG_WARN("failed to get_protected_memtable_mgr_handle", K(tmp_ret), KPC(this));
} else {
ret = protected_handle->has_memtable();
}
return ret;
}
int ObTablet::get_all_memtables(ObTableHdlArray &handle) const
{
int ret = OB_SUCCESS;

View File

@ -372,7 +372,6 @@ public:
int update_upper_trans_version(ObLS &ls, bool &is_updated);
// memtable operation
bool has_memtable() const;
int get_all_memtables(ObTableHdlArray &handle) const;
int get_boundary_memtable(ObTableHandleV2 &handle) const;
int get_protected_memtable_mgr_handle(ObProtectedMemtableMgrHandle *&handle) const;