skip check max_decided_scn if flushing to recycle clog
This commit is contained in:
@ -226,26 +226,23 @@ int ObCheckpointExecutor::update_clog_checkpoint()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCheckpointExecutor::advance_checkpoint_by_flush(SCN recycle_scn)
|
||||
int ObCheckpointExecutor::advance_checkpoint_by_flush(const share::SCN input_recycle_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObLSID ls_id = ls_->get_ls_id();
|
||||
const LSN clog_checkpoint_lsn = ls_->get_clog_base_lsn();
|
||||
const SCN clog_checkpoint_scn = ls_->get_clog_checkpoint_scn();
|
||||
SCN recycle_scn = input_recycle_scn;
|
||||
SCN max_decided_scn;
|
||||
|
||||
RLockGuard guard(rwlock_);
|
||||
if (update_checkpoint_enabled_) {
|
||||
// calculate recycle_scn if it is invalid(called by clog disk full situation)
|
||||
if (!recycle_scn.is_valid() &&
|
||||
OB_FAIL(calculate_recycle_scn_(clog_checkpoint_lsn, clog_checkpoint_scn, recycle_scn))) {
|
||||
if (OB_FAIL(loghandler_->get_max_decided_scn(max_decided_scn))) {
|
||||
STORAGE_LOG(WARN, "failed to get_max_decided_scn", K(ls_id));
|
||||
} else if (!recycle_scn.is_valid() && OB_FAIL(calculate_recycle_scn_(max_decided_scn, recycle_scn))) {
|
||||
STORAGE_LOG(WARN, "calculate recycle scn failed", KR(ret));
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
} else if (OB_FAIL(check_need_flush_(clog_checkpoint_scn, recycle_scn))) {
|
||||
} else if (OB_FAIL(check_need_flush_(max_decided_scn, recycle_scn))) {
|
||||
STORAGE_LOG(WARN, "no need flush");
|
||||
} else {
|
||||
STORAGE_LOG(INFO, "start flush", K(recycle_scn), K(clog_checkpoint_scn), K(ls_id));
|
||||
STORAGE_LOG(INFO, "start flush", K(recycle_scn), K(input_recycle_scn), K(ls_id));
|
||||
for (int i = 1; i < ObLogBaseType::MAX_LOG_BASE_TYPE; i++) {
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
if (OB_NOT_NULL(handlers_[i]) && OB_TMP_FAIL(handlers_[i]->flush(recycle_scn))) {
|
||||
@ -260,12 +257,13 @@ int ObCheckpointExecutor::advance_checkpoint_by_flush(SCN recycle_scn)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCheckpointExecutor::calculate_recycle_scn_(const LSN clog_checkpoint_lsn,
|
||||
const SCN clog_checkpoint_scn,
|
||||
SCN &recycle_scn)
|
||||
int ObCheckpointExecutor::calculate_recycle_scn_(const SCN max_decided_scn, SCN &recycle_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
LSN end_lsn;
|
||||
const ObLSID ls_id = ls_->get_ls_id();
|
||||
const LSN clog_checkpoint_lsn = ls_->get_clog_base_lsn();
|
||||
const SCN clog_checkpoint_scn = ls_->get_clog_checkpoint_scn();
|
||||
// locate_by_lsn_coarsely may return a recycle_scn less than checkpoint_scn
|
||||
// so if prev_recycle_scn_ <= clog_checkpoint_scn, the recycle_scn is still needed to be calculated again
|
||||
if (prev_clog_checkpoint_lsn_.is_valid() && (prev_clog_checkpoint_lsn_ == clog_checkpoint_lsn) &&
|
||||
@ -282,18 +280,22 @@ int ObCheckpointExecutor::calculate_recycle_scn_(const LSN clog_checkpoint_lsn,
|
||||
K(clog_checkpoint_lsn),
|
||||
K(recycle_scn));
|
||||
} else if (OB_FAIL(loghandler_->get_end_lsn(end_lsn))) {
|
||||
STORAGE_LOG(WARN, "get end lsn failed", K(ret), K(ls_->get_ls_id()));
|
||||
STORAGE_LOG(WARN, "get end lsn failed", K(ret), K(ls_id));
|
||||
} else {
|
||||
LSN calcu_recycle_lsn = clog_checkpoint_lsn + ((end_lsn - clog_checkpoint_lsn) * CLOG_GC_PERCENT / 100);
|
||||
if (OB_FAIL(loghandler_->locate_by_lsn_coarsely(calcu_recycle_lsn, recycle_scn))) {
|
||||
STORAGE_LOG(WARN, "locate_by_lsn_coarsely failed", K(calcu_recycle_lsn), K(recycle_scn), K(ls_->get_ls_id()));
|
||||
STORAGE_LOG(WARN, "locate_by_lsn_coarsely failed", K(calcu_recycle_lsn), K(recycle_scn), K(ls_id));
|
||||
} else {
|
||||
// recycle_scn must less than max_decided_scn
|
||||
recycle_scn = MIN(recycle_scn, max_decided_scn);
|
||||
|
||||
prev_clog_checkpoint_lsn_ = clog_checkpoint_lsn;
|
||||
prev_recycle_scn_ = recycle_scn;
|
||||
reuse_recycle_scn_times_ = 0;
|
||||
STORAGE_LOG(INFO,
|
||||
"advance checkpoint by flush to avoid clog disk full",
|
||||
K(recycle_scn),
|
||||
K(max_decided_scn),
|
||||
K(end_lsn),
|
||||
K(clog_checkpoint_lsn),
|
||||
K(calcu_recycle_lsn),
|
||||
@ -304,11 +306,11 @@ int ObCheckpointExecutor::calculate_recycle_scn_(const LSN clog_checkpoint_lsn,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObCheckpointExecutor::check_need_flush_(const SCN clog_checkpoint_scn, const SCN recycle_scn)
|
||||
int ObCheckpointExecutor::check_need_flush_(const SCN max_decided_scn, const SCN recycle_scn)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
SCN max_decided_scn;
|
||||
const ObLSID ls_id = ls_->get_ls_id();
|
||||
const SCN clog_checkpoint_scn = ls_->get_clog_checkpoint_scn();
|
||||
if (recycle_scn.is_max()) {
|
||||
// must do flush
|
||||
} else if (recycle_scn < clog_checkpoint_scn) {
|
||||
@ -318,8 +320,6 @@ int ObCheckpointExecutor::check_need_flush_(const SCN clog_checkpoint_scn, const
|
||||
K(recycle_scn),
|
||||
K(clog_checkpoint_scn),
|
||||
K(ls_id));
|
||||
} else if (OB_FAIL(loghandler_->get_max_decided_scn(max_decided_scn))) {
|
||||
STORAGE_LOG(WARN, "failed to get_max_decided_scn", K(recycle_scn), K(clog_checkpoint_scn), K(ls_id));
|
||||
} else if (recycle_scn > max_decided_scn) {
|
||||
ret = OB_EAGAIN;
|
||||
STORAGE_LOG(WARN,
|
||||
|
||||
@ -78,8 +78,7 @@ public:
|
||||
|
||||
// the service will flush and advance checkpoint
|
||||
// after flush, checkpoint_scn will be equal or greater than recycle_scn
|
||||
int advance_checkpoint_by_flush(share::SCN recycle_scn = share::SCN::invalid_scn());
|
||||
|
||||
int advance_checkpoint_by_flush(const share::SCN input_recycle_scn);
|
||||
|
||||
// for __all_virtual_checkpoint
|
||||
int get_checkpoint_info(ObIArray<ObCheckpointVTInfo> &checkpoint_array);
|
||||
@ -92,8 +91,8 @@ public:
|
||||
|
||||
int traversal_flush() const;
|
||||
private:
|
||||
int check_need_flush_(const SCN clog_checkpoint_scn, const SCN recycle_scn);
|
||||
int calculate_recycle_scn_(const palf::LSN clog_checkpoint_lsn, const SCN clog_checkpoint_snc, SCN &recycle_scn);
|
||||
int check_need_flush_(const SCN max_decided_scn, const SCN recycle_scn);
|
||||
int calculate_recycle_scn_(const SCN max_decided_scn, SCN &recycle_scn);
|
||||
|
||||
private:
|
||||
static const int64_t CLOG_GC_PERCENT = 60;
|
||||
|
||||
@ -1959,6 +1959,27 @@ int ObLS::advance_checkpoint_by_flush(SCN recycle_scn, const int64_t abs_timeout
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLS::flush_to_recycle_clog()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
int64_t read_lock = LSLOCKALL;
|
||||
int64_t write_lock = 0;
|
||||
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
} else if (OB_UNLIKELY(is_offline())) {
|
||||
ret = OB_MINOR_FREEZE_NOT_ALLOW;
|
||||
LOG_WARN("offline ls not allowed freeze", K(ret), K_(ls_meta));
|
||||
} else if (OB_FAIL(checkpoint_executor_.advance_checkpoint_by_flush(SCN::invalid_scn() /*recycle_scn*/))) {
|
||||
STORAGE_LOG(WARN, "advance_checkpoint_by_flush failed", KR(ret), K(get_ls_id()));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLS::get_ls_meta_package_and_tablet_ids(const bool check_archive,
|
||||
ObLSMetaPackage &meta_package,
|
||||
common::ObIArray<common::ObTabletID> &tablet_ids)
|
||||
@ -2142,40 +2163,6 @@ int ObLS::disable_replay_without_lock()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLS::flush_if_need(const bool need_flush)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
int64_t read_lock = LSLOCKALL;
|
||||
int64_t write_lock = 0;
|
||||
ObLSLockGuard lock_myself(this, lock_, read_lock, write_lock);
|
||||
if (IS_NOT_INIT) {
|
||||
ret = OB_NOT_INIT;
|
||||
LOG_WARN("ls is not inited", K(ret));
|
||||
} else if (OB_UNLIKELY(is_offline())) {
|
||||
ret = OB_MINOR_FREEZE_NOT_ALLOW;
|
||||
LOG_WARN("offline ls not allowed freeze", K(ret), K_(ls_meta));
|
||||
} else if (OB_FAIL(flush_if_need_(need_flush))) {
|
||||
LOG_WARN("flush if need failed", K(ret), K_(ls_meta));
|
||||
} else {
|
||||
// do nothing
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLS::flush_if_need_(const bool need_flush)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
SCN clog_checkpoint_scn = get_clog_checkpoint_scn();
|
||||
if (!need_flush) {
|
||||
STORAGE_LOG(INFO, "the ls no need flush to advance_checkpoint",
|
||||
K(get_ls_id()),
|
||||
K(need_flush));
|
||||
} else if (OB_FAIL(checkpoint_executor_.advance_checkpoint_by_flush())) {
|
||||
STORAGE_LOG(WARN, "advance_checkpoint_by_flush failed", KR(ret), K(get_ls_id()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObLS::try_update_upper_trans_version_and_gc_sstable(
|
||||
compaction::ObCompactionScheduleIterator &iter)
|
||||
|
||||
@ -383,7 +383,7 @@ public:
|
||||
const bool replay_allow_tablet_not_exist,
|
||||
ObTabletHandle &tablet_handle) const;
|
||||
|
||||
int flush_if_need(const bool need_flush);
|
||||
int flush_to_recycle_clog();
|
||||
int try_sync_reserved_snapshot(const int64_t new_reserved_snapshot, const bool update_flag);
|
||||
int check_can_replay_clog(bool &can_replay);
|
||||
int check_ls_need_online(bool &need_online);
|
||||
@ -402,7 +402,6 @@ private:
|
||||
int stop_();
|
||||
void wait_();
|
||||
int prepare_for_safe_destroy_();
|
||||
int flush_if_need_(const bool need_flush);
|
||||
int offline_(const int64_t start_ts);
|
||||
int offline_compaction_();
|
||||
int online_compaction_();
|
||||
|
||||
@ -265,7 +265,7 @@ bool ObCheckPointService::cannot_recycle_log_over_threshold_(const int64_t thres
|
||||
return cannot_recycle_log_over_threshold;
|
||||
}
|
||||
|
||||
int ObCheckPointService::flush_if_need_()
|
||||
int ObCheckPointService::flush_to_recycle_clog_()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int tmp_ret = OB_SUCCESS;
|
||||
@ -284,8 +284,8 @@ int ObCheckPointService::flush_if_need_()
|
||||
int64_t ls_cnt = 0;
|
||||
int64_t succ_ls_cnt = 0;
|
||||
for (; OB_SUCC(iter->get_next(ls)); ++ls_cnt) {
|
||||
if (OB_TMP_FAIL(ls->flush_if_need(true))) {
|
||||
STORAGE_LOG(WARN, "flush ls failed", KR(tmp_ret), KPC(ls));
|
||||
if (OB_TMP_FAIL(ls->flush_to_recycle_clog())) {
|
||||
STORAGE_LOG(WARN, "flush ls to recycle clog failed", KR(tmp_ret), KPC(ls));
|
||||
tmp_ret = OB_SUCCESS;
|
||||
} else {
|
||||
++succ_ls_cnt;
|
||||
@ -361,8 +361,8 @@ void ObCheckPointService::ObCheckClogDiskUsageTask::runTimerTask()
|
||||
}
|
||||
}
|
||||
|
||||
if (need_flush && OB_FAIL(checkpoint_service_.flush_if_need_())) {
|
||||
STORAGE_LOG(ERROR, "flush if needed failed", K(ret), K(need_flush));
|
||||
if (need_flush && OB_FAIL(checkpoint_service_.flush_to_recycle_clog_())) {
|
||||
STORAGE_LOG(ERROR, "flush to recycle clog failed", K(ret), K(need_flush));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ private:
|
||||
|
||||
bool get_disk_usage_threshold_(int64_t &threshold);
|
||||
bool cannot_recycle_log_over_threshold_(const int64_t threshold, const bool need_update_checkpoint_scn);
|
||||
int flush_if_need_();
|
||||
int flush_to_recycle_clog_();
|
||||
// reduce the risk of clog full due to checkpoint long interval
|
||||
static int64_t CHECK_CLOG_USAGE_INTERVAL;
|
||||
static int64_t CHECKPOINT_INTERVAL;
|
||||
|
||||
Reference in New Issue
Block a user