[4.x] replace get_first_memtable to get_first_nonempty_memtable in ObTablet::get_rec_log_scn
This commit is contained in:
@ -42,19 +42,43 @@ int ObIMemtableMgr::get_active_memtable(ObTableHandleV2 &handle) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ObIMemtableMgr::get_first_memtable(ObTableHandleV2 &handle) const
|
int ObIMemtableMgr::get_first_nonempty_memtable(ObTableHandleV2 &handle) const
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
|
bool is_exist = false;
|
||||||
SpinRLockGuard lock_guard(lock_);
|
SpinRLockGuard lock_guard(lock_);
|
||||||
if (memtable_head_ == memtable_tail_) {
|
|
||||||
ret = OB_ENTRY_NOT_EXIST;
|
for (int64_t i = memtable_head_; OB_SUCC(ret) && i < memtable_tail_; ++i) {
|
||||||
STORAGE_LOG(DEBUG, "There is no memtable in ObIMemtableMgr.");
|
ObTableHandleV2 tmp_handle;
|
||||||
} else if (OB_FAIL(get_ith_memtable(memtable_head_, handle))) {
|
memtable::ObMemtable *mt = NULL;
|
||||||
STORAGE_LOG(WARN, "fail to get ith memtable", K(ret), K(memtable_head_));
|
if (OB_FAIL(get_ith_memtable(i, tmp_handle))) {
|
||||||
|
STORAGE_LOG(WARN, "fail to get ith memtable", KR(ret), K(i));
|
||||||
|
} else if (OB_UNLIKELY(!tmp_handle.is_valid())) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
STORAGE_LOG(WARN, "get invalid tmp table handle", KR(ret), K(i), K(tmp_handle));
|
||||||
|
} else if (OB_FAIL(tmp_handle.get_data_memtable(mt))) {
|
||||||
|
STORAGE_LOG(WARN, "failed to get_data_memtable", KR(ret), K(i), K(tmp_handle));
|
||||||
|
} else if (OB_ISNULL(mt)) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
STORAGE_LOG(WARN, "mt is NULL", KR(ret), K(i), K(tmp_handle));
|
||||||
|
} else if (mt->get_rec_scn().is_max()) {
|
||||||
|
} else if (OB_FAIL(get_ith_memtable(i, handle))) {
|
||||||
|
STORAGE_LOG(WARN, "fail to get ith memtable", KR(ret), K(i));
|
||||||
} else if (OB_UNLIKELY(!handle.is_valid())) {
|
} else if (OB_UNLIKELY(!handle.is_valid())) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
STORAGE_LOG(WARN, "get invalid table handle", K(ret), K(handle));
|
STORAGE_LOG(WARN, "get invalid table handle", KR(ret), K(i), K(handle));
|
||||||
|
} else {
|
||||||
|
is_exist = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OB_FAIL(ret)) {
|
||||||
|
} else if (!is_exist) {
|
||||||
|
ret = OB_ENTRY_NOT_EXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
virtual int get_active_memtable(ObTableHandleV2 &handle) const;
|
virtual int get_active_memtable(ObTableHandleV2 &handle) const;
|
||||||
|
|
||||||
virtual int get_first_memtable(ObTableHandleV2 &handle) const;
|
virtual int get_first_nonempty_memtable(ObTableHandleV2 &handle) const;
|
||||||
|
|
||||||
virtual int get_all_memtables(ObTableHdlArray &handle);
|
virtual int get_all_memtables(ObTableHdlArray &handle);
|
||||||
|
|
||||||
|
|||||||
@ -2758,14 +2758,14 @@ int ObTablet::get_rec_log_scn(SCN &rec_scn) {
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
rec_scn = SCN::max_scn();
|
rec_scn = SCN::max_scn();
|
||||||
ObTableHandleV2 handle;
|
ObTableHandleV2 handle;
|
||||||
memtable::ObMemtable *mt;
|
memtable::ObMemtable *mt = NULL;
|
||||||
if (IS_NOT_INIT) {
|
if (IS_NOT_INIT) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
LOG_WARN("not inited", KR(ret), K_(is_inited));
|
LOG_WARN("not inited", KR(ret), K_(is_inited));
|
||||||
} else if (OB_ISNULL(memtable_mgr_)) {
|
} else if (OB_ISNULL(memtable_mgr_)) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
LOG_WARN("memtable_mgr is NULL", KR(ret), KPC(this));
|
LOG_WARN("memtable_mgr is NULL", KR(ret), KPC(this));
|
||||||
} else if (OB_FAIL(memtable_mgr_->get_first_memtable(handle))) {
|
} else if (OB_FAIL(memtable_mgr_->get_first_nonempty_memtable(handle))) {
|
||||||
if (OB_ENTRY_NOT_EXIST == ret) {
|
if (OB_ENTRY_NOT_EXIST == ret) {
|
||||||
ret = OB_SUCCESS;
|
ret = OB_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user