fix dup table new gc method core

This commit is contained in:
Minionyh
2023-09-05 09:43:26 +00:00
committed by ob-robot
parent 4f2cb1d056
commit eb1d1ff665
2 changed files with 26 additions and 14 deletions

View File

@ -404,7 +404,7 @@ int ObLSDupTabletsMgr::init_free_tablet_pool_()
DUP_TABLE_LOG(WARN, "get free tablet set failed", K(ret));
} else {
removing_old_set_->get_common_header().set_old();
removing_old_set_->set_related_set_op_type(DupTableRelatedSetOpType::OLD_GC);
removing_old_set_->set_related_set_op_type(DupTableRelatedSetOpType::NEW_GC);
}
DUP_TABLE_LOG(INFO, "finish init tablet map", K(ret), KPC(removing_old_set_),
@ -835,14 +835,8 @@ DupTabletChangeMap *ObLSDupTabletsMgr::get_need_gc_set_(bool &new_round)
KPC(removing_old_set_), KPC(readable_set_in_gc_));
readable_set_in_gc_ = nullptr;
} else {
while (OB_NOT_NULL(readable_set_in_gc_) && !readable_set_in_gc_->need_gc_scan(gc_start_time_)
&& readable_set_in_gc_ != readable_tablets_list_.get_header()) {
readable_set_in_gc_ = readable_set_in_gc_->get_next();
}
if (readable_set_in_gc_ == readable_tablets_list_.get_header()) {
readable_set_in_gc_ = nullptr;
}
READABLE_DLIST_FOREACH_X(readable_set_in_gc_, readable_tablets_list_,
!readable_set_in_gc_->need_gc_scan(gc_start_time_));
}
}
@ -853,6 +847,12 @@ DupTabletChangeMap *ObLSDupTabletsMgr::get_need_gc_set_(bool &new_round)
}
}
if (readable_set_in_gc_ == readable_tablets_list_.get_header()) {
readable_set_in_gc_ = nullptr;
DUP_TABLE_LOG(INFO, "readable_set_in_gc_ is null ptr, no need start gc", K(readable_tablets_list_.get_size()),
KP(removing_old_set_), KP(readable_set_in_gc_), KP(readable_tablets_list_.get_header()));
}
return readable_set_in_gc_;
}
@ -2509,7 +2509,7 @@ int ObLSDupTabletsMgr::return_tablet_set_(DupTabletChangeMap *need_free_set)
} else if (need_free_set->get_common_header().is_old_set()) {
need_free_set->reuse();
need_free_set->get_common_header().set_old();
need_free_set->set_related_set_op_type(DupTableRelatedSetOpType::OLD_GC);
need_free_set->set_related_set_op_type(DupTableRelatedSetOpType::NEW_GC);
} else {
if (OB_FAIL(ret)) {
} else {
@ -2521,6 +2521,8 @@ int ObLSDupTabletsMgr::return_tablet_set_(DupTabletChangeMap *need_free_set)
}
if (need_free_set == changing_new_set_) {
changing_new_set_ = nullptr;
} else if (need_free_set == readable_set_in_gc_) {
readable_set_in_gc_ = nullptr;
}
}
}
@ -2547,9 +2549,6 @@ int ObLSDupTabletsMgr::check_and_recycle_empty_readable_set_(DupTabletChangeMap
DUP_TABLE_LOG(WARN, "remove empty readable set from list failed", K(ret), KPC(readable_set));
} else if (OB_FAIL(return_tablet_set_(readable_set))) {
DUP_TABLE_LOG(WARN, "return empty readable set failed", K(ret), KPC(readable_set));
} else if (readable_set == readable_set_in_gc_) {
// readable_set recycled, restart scan readable list
readable_set_in_gc_ = nullptr;
}
}

View File

@ -20,6 +20,11 @@
#include "ob_dup_table_base.h"
#include "ob_dup_table_ts_sync.h"
#define READABLE_DLIST_FOREACH_X(curr, dlist, extra_condition) \
for (;OB_NOT_NULL(curr) && curr != (dlist).get_header() \
&& (extra_condition); \
curr = curr->get_next())
namespace oceanbase
{
@ -404,9 +409,17 @@ public:
bool need_gc_scan(int64_t gc_start_time) {
bool bool_ret = false;
if (get_related_set_op_type() == DupTableRelatedSetOpType::INVALID) {
if (!get_common_header().is_readable_set()) {
DUP_TABLE_LOG_RET(WARN, OB_ERR_UNEXPECTED, "not readable set, not need gc",
K(gc_start_time), KPC(this));
bool_ret = false;
} else if (get_related_set_op_type() != DupTableRelatedSetOpType::INVALID) {
DUP_TABLE_LOG(INFO, "this readable set used for other operation, should skip gc", KPC(this));
bool_ret = false;
} else {
bool_ret = true;
}
if (bool_ret) {
if (last_gc_scan_ts_ <= 0
|| gc_start_time > last_gc_scan_ts_) {