fix gc wait archive bug

This commit is contained in:
taoshuning
2023-06-26 07:42:34 +00:00
committed by ob-robot
parent 3302355412
commit 1155218ed2
3 changed files with 17 additions and 10 deletions

View File

@ -145,6 +145,8 @@ int ObArchivePersistMgr::get_ls_archive_progress(const ObLSID &id, LSN &lsn, SCN
ObLSArchivePersistInfo info;
bool is_madatory = false;
int64_t unused_speed = 0;
ignore = false;
force = false;
ObArchiveRoundState state;
{
RLockGuard guard(state_rwlock_);
@ -156,8 +158,8 @@ int ObArchivePersistMgr::get_ls_archive_progress(const ObLSID &id, LSN &lsn, SCN
if (OB_UNLIKELY(! id.is_valid())) {
ret = OB_INVALID_ARGUMENT;
ARCHIVE_LOG(WARN, "invalid argument", K(ret), K(id));
} else if (! state.is_beginning() && ! state.is_doing()) {
// archive not in beginning or doing state, just ignore it
} else if (! state_in_archive_(state)) {
// archive not in beginning or doing or suspend state, just ignore it
ignore = true;
} else if (OB_FAIL(map_.get(id, value))) {
if (OB_ENTRY_NOT_EXIST == ret) {
@ -193,6 +195,8 @@ int ObArchivePersistMgr::get_ls_archive_speed(const ObLSID &id, int64_t &speed,
ObLSArchivePersistInfo info;
bool is_madatory = false;
ArchiveKey key;
ignore = false;
force = false;
ObArchiveRoundState state;
{
RLockGuard guard(state_rwlock_);
@ -205,8 +209,8 @@ int ObArchivePersistMgr::get_ls_archive_speed(const ObLSID &id, int64_t &speed,
if (OB_UNLIKELY(! id.is_valid())) {
ret = OB_INVALID_ARGUMENT;
ARCHIVE_LOG(WARN, "invalid argument", K(ret), K(id));
} else if (! state.is_beginning() && ! state.is_doing()) {
// archive not in beginning or doing state, just ignore it
} else if (! state_in_archive_(state)) {
// archive not in beginning or doing or suspend state, just ignore it
ignore = true;
} else if (OB_FAIL(map_.get(id, value))) {
if (OB_ENTRY_NOT_EXIST == ret) {
@ -547,6 +551,11 @@ int ObArchivePersistMgr::clear_stale_ls_()
return ret;
}
bool ObArchivePersistMgr::state_in_archive_(const share::ObArchiveRoundState &state) const
{
return state.is_beginning() || state.is_doing() || state.is_suspending() || state.is_suspend();
}
int ObArchivePersistMgr::load_ls_archive_progress_(const ObLSID &id,
const ArchiveKey &key,
ObLSArchivePersistInfo &info,

View File

@ -147,6 +147,7 @@ private:
// 3. 清理本server已经不存在日志流归档进度记录
int clear_stale_ls_();
bool state_in_archive_(const share::ObArchiveRoundState &state) const;
int load_ls_archive_progress_(const ObLSID &id,
const ArchiveKey &key,
ObLSArchivePersistInfo &info,

View File

@ -594,8 +594,8 @@ void ObGCHandler::try_check_and_set_wait_gc_(ObGarbageCollector::LSStatus &ls_st
{
int ret = OB_SUCCESS;
ObArchiveService *archive_service = MTL(ObArchiveService*);
bool force_wait = true;
bool ignore = true;
bool force_wait = false;
bool ignore = false;
SCN scn = SCN::min_scn();
LSN lsn;
SCN readable_scn = SCN::min_scn();
@ -630,15 +630,12 @@ void ObGCHandler::try_check_and_set_wait_gc_(ObGarbageCollector::LSStatus &ls_st
}
ls_status = ObGarbageCollector::LSStatus::LS_NEED_DELETE_ENTRY;
CLOG_LOG(INFO, "try_check_and_set_wait_gc_ success", K(ls_id), K(gc_state), K(offline_scn), K(scn));
} else if (scn == offline_scn) {
} else if (scn >= offline_scn) {
if (OB_FAIL(ls_->set_gc_state(LSGCState::WAIT_GC))) {
CLOG_LOG(WARN, "set_gc_state failed", K(ls_id), K(gc_state), K(ret));
}
ls_status = ObGarbageCollector::LSStatus::LS_NEED_DELETE_ENTRY;
CLOG_LOG(INFO, "try_check_and_set_wait_gc_ success", K(ls_id), K(gc_state), K(offline_scn), K(scn));
} else if (scn > offline_scn) {
ret = OB_ERR_UNEXPECTED;
CLOG_LOG(ERROR, "ls_archive_progress larger than offline scn", K(ls_id), K(gc_state), K(offline_scn), K(scn));
} else {
CLOG_LOG(INFO, "try_check_and_set_wait_gc_ wait archive", K(ls_id), K(gc_state), K(offline_scn), K(scn));
}