remove memtables from data_checkpoit when remove tablet
This commit is contained in:
@ -537,6 +537,8 @@ int ObLSTabletService::remove_tablets(const common::ObIArray<common::ObTabletID>
|
||||
} else {
|
||||
LOG_WARN("failed to get tablet", K(ret), K(key));
|
||||
}
|
||||
} else if (OB_FAIL(tablet_handle.get_obj()->remove_memtables_from_data_checkpoint())) {
|
||||
LOG_WARN("failed to remove memtables from data_checkpoint", K(ret), K(key));
|
||||
} else if (OB_FAIL(tablet_handle.get_obj()->get_meta_disk_addr(tablet_addr))) {
|
||||
LOG_WARN("failed to get tablet addr", K(ret), K(key));
|
||||
} else if (!tablet_addr.is_disked()) {
|
||||
|
@ -294,7 +294,7 @@ public:
|
||||
{ // do nothing
|
||||
return OB_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
virtual int remove_memtables_from_data_checkpoint() { return OB_SUCCESS; }
|
||||
DECLARE_VIRTUAL_TO_STRING;
|
||||
protected:
|
||||
static int64_t get_memtable_idx(const int64_t pos) { return pos & (MAX_MEMSTORE_CNT - 1); }
|
||||
|
@ -3350,6 +3350,21 @@ int ObTablet::clear_memtables_on_table_store() // be careful to call this func
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int ObTablet::remove_memtables_from_data_checkpoint()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObIMemtableMgr *memtable_mgr = nullptr;
|
||||
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (OB_FAIL(get_memtable_mgr(memtable_mgr))) {
|
||||
LOG_WARN("failed to get memtable mgr", K(ret));
|
||||
} else if (OB_FAIL(memtable_mgr->remove_memtables_from_data_checkpoint())){
|
||||
LOG_WARN("failed to rmeove memtables from data_checkpoint", K(ret));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
} // namespace storage
|
||||
} // namespace oceanbase
|
||||
|
@ -388,6 +388,7 @@ public:
|
||||
int set_memtable_clog_checkpoint_scn(
|
||||
const ObMigrationTabletParam *tablet_meta);
|
||||
int clear_memtables_on_table_store(); // be careful to call this func, will destroy memtables array on table_store
|
||||
int remove_memtables_from_data_checkpoint();
|
||||
TO_STRING_KV(KP(this), K_(wash_score), K_(ref_cnt), K_(tablet_meta), K_(table_store), K_(storage_schema),
|
||||
K_(medium_info_list));
|
||||
private:
|
||||
|
@ -168,7 +168,7 @@ int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
||||
const uint32_t logstream_freeze_clock = freezer_->get_freeze_clock();
|
||||
memtable::ObMemtable *active_memtable = nullptr;
|
||||
uint32_t memtable_freeze_clock = UINT32_MAX;
|
||||
const share::ObLSID ls_id = ls_->get_ls_id();
|
||||
share::ObLSID ls_id;
|
||||
SCN new_clog_checkpoint_scn;
|
||||
if (has_memtable && OB_NOT_NULL(active_memtable = get_active_memtable_())) {
|
||||
memtable_freeze_clock = active_memtable->get_freeze_clock();
|
||||
@ -177,6 +177,10 @@ int ObTabletMemtableMgr::create_memtable(const SCN clog_checkpoint_scn,
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (OB_ISNULL(ls_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("ls is null", K(ret));
|
||||
} else if (FALSE_IT(ls_id = ls_->get_ls_id())) {
|
||||
} else if (logstream_freeze_clock == memtable_freeze_clock) {
|
||||
// new memtable has already existed
|
||||
ret = OB_ENTRY_EXIST;
|
||||
@ -514,14 +518,17 @@ int ObTabletMemtableMgr::get_memtable_for_replay(SCN replay_scn,
|
||||
ObTableHandleV2 &handle)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObLSID ls_id = ls_->get_ls_id();
|
||||
ObMemtable *memtable = nullptr;
|
||||
handle.reset();
|
||||
|
||||
if (OB_UNLIKELY(!is_inited_)) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("not inited", K(ret), K_(is_inited));
|
||||
} else if (OB_ISNULL(ls_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "ls is null", K(ret));
|
||||
} else {
|
||||
const share::ObLSID &ls_id = ls_->get_ls_id();
|
||||
MemMgrRLockGuard lock_guard(lock_);
|
||||
int64_t i = 0;
|
||||
for (i = memtable_tail_ - 1; OB_SUCC(ret) && i >= memtable_head_; --i) {
|
||||
@ -609,12 +616,15 @@ int ObTabletMemtableMgr::release_head_memtable_(memtable::ObIMemtable *imemtable
|
||||
{
|
||||
UNUSED(force);
|
||||
int ret = OB_SUCCESS;
|
||||
const share::ObLSID ls_id = ls_->get_ls_id();
|
||||
memtable::ObMemtable *memtable = static_cast<memtable::ObMemtable *>(imemtable);
|
||||
|
||||
if (OB_UNLIKELY(get_memtable_count_() <= 0)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
} else if (OB_ISNULL(ls_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "ls is null", K(ret));
|
||||
} else {
|
||||
const share::ObLSID &ls_id = ls_->get_ls_id();
|
||||
const int64_t idx = get_memtable_idx(memtable_head_);
|
||||
if (nullptr != tables_[idx] && memtable == tables_[idx]) {
|
||||
LOG_INFO("release head memtable", K(ret), K(ls_id), KPC(memtable));
|
||||
@ -638,6 +648,35 @@ int ObTabletMemtableMgr::release_head_memtable_(memtable::ObIMemtable *imemtable
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMemtableMgr::remove_memtables_from_data_checkpoint()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
MemMgrWLockGuard lock_guard(lock_);
|
||||
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
STORAGE_LOG(WARN, "not inited", K(ret));
|
||||
} else if (OB_ISNULL(ls_)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "ls is null", K(ret));
|
||||
} else {
|
||||
const share::ObLSID &ls_id = ls_->get_ls_id();
|
||||
for (int64_t i = memtable_head_; OB_SUCC(ret) && i < memtable_tail_; ++i) {
|
||||
// memtable that cannot be released will block memtables behind it
|
||||
ObMemtable *memtable = static_cast<memtable::ObMemtable *>(tables_[get_memtable_idx(i)]);
|
||||
if (OB_ISNULL(memtable)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
STORAGE_LOG(WARN, "memtable is nullptr", K(ret), K(ls_id), KP(memtable), K(i));
|
||||
} else {
|
||||
STORAGE_LOG(INFO, "remove memtable from data_checkpoint", K(ls_id), K(i), K(*memtable));
|
||||
memtable->remove_from_data_checkpoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObTabletMemtableMgr::get_first_frozen_memtable(ObTableHandleV2 &handle) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
@ -103,6 +103,7 @@ public:
|
||||
const lib::Worker::CompatMode compat_mode,
|
||||
logservice::ObLogHandler *log_handler) override;
|
||||
virtual int reset_storage_recorder() override;
|
||||
virtual int remove_memtables_from_data_checkpoint() override;
|
||||
DECLARE_VIRTUAL_TO_STRING;
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user