[BUG] fix refresh too much time

This commit is contained in:
Handora
2023-06-05 05:15:00 +00:00
committed by ob-robot
parent b94bbba9b5
commit 3dde860f3e
2 changed files with 35 additions and 20 deletions

View File

@ -394,10 +394,18 @@ bool ObStorageTableGuard::need_to_refresh_table(ObTableStoreIterator &iter)
exit_flag = 3; exit_flag = 3;
} }
if (bool_ret && check_if_need_log()) { if (bool_ret) {
bool need_log = false;
bool need_log_error = false;
check_if_need_log_(need_log, need_log_error);
if (need_log) {
const share::ObLSID &ls_id = tablet_->get_tablet_meta().ls_id_; const share::ObLSID &ls_id = tablet_->get_tablet_meta().ls_id_;
const common::ObTabletID &tablet_id = tablet_->get_tablet_meta().tablet_id_; const common::ObTabletID &tablet_id = tablet_->get_tablet_meta().tablet_id_;
if (need_log_error) {
LOG_ERROR_RET(OB_ERR_TOO_MUCH_TIME, "refresh table too much times", K(ret), K(exit_flag), K(ls_id), K(tablet_id), KP(table));
} else {
LOG_WARN_RET(OB_ERR_TOO_MUCH_TIME, "refresh table too much times", K(ret), K(exit_flag), K(ls_id), K(tablet_id), KP(table)); LOG_WARN_RET(OB_ERR_TOO_MUCH_TIME, "refresh table too much times", K(ret), K(exit_flag), K(ls_id), K(tablet_id), KP(table));
}
if (0 == exit_flag) { if (0 == exit_flag) {
LOG_WARN("table is null or not memtable", K(ret), K(ls_id), K(tablet_id), KP(table)); LOG_WARN("table is null or not memtable", K(ret), K(ls_id), K(tablet_id), KP(table));
} else if (1 == exit_flag) { } else if (1 == exit_flag) {
@ -410,17 +418,24 @@ bool ObStorageTableGuard::need_to_refresh_table(ObTableStoreIterator &iter)
LOG_WARN("unexpect exit_flag", K(exit_flag), K(ret), K(ls_id), K(tablet_id)); LOG_WARN("unexpect exit_flag", K(exit_flag), K(ret), K(ls_id), K(tablet_id));
} }
} }
}
return bool_ret; return bool_ret;
} }
bool ObStorageTableGuard::check_if_need_log() void ObStorageTableGuard::check_if_need_log_(bool &need_log,
bool &need_log_error)
{ {
bool need_log = false; need_log = false;
need_log_error = false;
if ((++retry_count_ % GET_TS_INTERVAL) == 0) { if ((++retry_count_ % GET_TS_INTERVAL) == 0) {
const int64_t cur_ts = common::ObTimeUtility::current_time(); const int64_t cur_ts = common::ObTimeUtility::current_time();
if (0 >= last_ts_) { if (0 >= last_ts_) {
last_ts_ = cur_ts; last_ts_ = cur_ts;
} else if (cur_ts - last_ts_ >= LOG_ERROR_INTERVAL_US) {
last_ts_ = cur_ts;
need_log = true;
need_log_error = true;
} else if (cur_ts - last_ts_ >= LOG_INTERVAL_US) { } else if (cur_ts - last_ts_ >= LOG_INTERVAL_US) {
last_ts_ = cur_ts; last_ts_ = cur_ts;
need_log = true; need_log = true;
@ -428,7 +443,6 @@ bool ObStorageTableGuard::check_if_need_log()
// do nothing // do nothing
} }
} }
return need_log;
} }
} // namespace storage } // namespace storage
} // namespace oceanbase } // namespace oceanbase

View File

@ -59,11 +59,12 @@ private:
bool &bool_ret); bool &bool_ret);
int check_freeze_to_inc_write_ref(ObITable *table, bool &bool_ret, bool &for_replace_tablet_meta); int check_freeze_to_inc_write_ref(ObITable *table, bool &bool_ret, bool &for_replace_tablet_meta);
bool need_to_refresh_table(ObTableStoreIterator &iter); bool need_to_refresh_table(ObTableStoreIterator &iter);
bool check_if_need_log(); void check_if_need_log_(bool &need_log, bool &need_log_error);
private: private:
static const int64_t LOG_INTERVAL_US = 10 * 1000 * 1000; static const int64_t LOG_INTERVAL_US = 10 * 1000 * 1000; // 10s
static const int64_t LOG_ERROR_INTERVAL_US = 60 * 1000 * 1000; // 1min
static const int64_t GET_TS_INTERVAL = 10 * 1000; static const int64_t GET_TS_INTERVAL = 10 * 1000;
static const int64_t SLEEP_INTERVAL_PER_TIME = 20 * 1000; static const int64_t SLEEP_INTERVAL_PER_TIME = 20 * 1000; // 20ms
ObTablet *tablet_; ObTablet *tablet_;
ObStoreCtx &store_ctx_; ObStoreCtx &store_ctx_;