[FIX] improve throttle logic
This commit is contained in:
@ -71,7 +71,8 @@ void ObStorageTableGuard::throttle_if_needed_()
|
||||
// only do throttle on active memtable
|
||||
if (OB_NOT_NULL(memtable_) && memtable_->is_active_memtable()) {
|
||||
reset();
|
||||
(void)do_throttle_(throttle_tool, share_ti_guard, module_ti_guard);
|
||||
(void)TxShareMemThrottleUtil::do_throttle<ObMemstoreAllocator>(
|
||||
for_replay_, store_ctx_.timeout_, throttle_tool, share_ti_guard, module_ti_guard);
|
||||
}
|
||||
|
||||
// if throttle is skipped due to some reasons, advance clock by call skip_throttle() and clean throttle status
|
||||
@ -88,84 +89,6 @@ void ObStorageTableGuard::throttle_if_needed_()
|
||||
}
|
||||
}
|
||||
|
||||
#define PRINT_THROTTLE_WARN \
|
||||
do { \
|
||||
const int64_t WARN_LOG_INTERVAL = 60L * 1000L * 1000L /* one minute */; \
|
||||
if (sleep_time > (WARN_LOG_INTERVAL) && TC_REACH_TIME_INTERVAL(WARN_LOG_INTERVAL)) { \
|
||||
SHARE_LOG(WARN, \
|
||||
"[Throttling] Attention!! Sleep More Than One Minute!!", \
|
||||
K(sleep_time), \
|
||||
K(left_interval), \
|
||||
K(expected_wait_time)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define PRINT_THROTTLE_STATISTIC \
|
||||
do { \
|
||||
const int64_t MEMSTORE_THROTTLE_LOG_INTERVAL = 1L * 1000L * 1000L; /*one seconds*/ \
|
||||
if (sleep_time > 0 && REACH_TIME_INTERVAL(MEMSTORE_THROTTLE_LOG_INTERVAL)) { \
|
||||
SHARE_LOG(INFO, \
|
||||
"[Throttling] (report write throttle info) Time Info", \
|
||||
"Throttle Unit Name", \
|
||||
ObMemstoreAllocator::throttle_unit_name(), \
|
||||
"Throttle Sleep Time(us)", \
|
||||
sleep_time); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
void ObStorageTableGuard::do_throttle_(TxShareThrottleTool &throttle_tool,
|
||||
ObThrottleInfoGuard &share_ti_guard,
|
||||
ObThrottleInfoGuard &module_ti_guard)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t sleep_time = 0;
|
||||
int64_t left_interval = share::ObThrottleUnit<ObTenantMdsAllocator>::DEFAULT_MAX_THROTTLE_TIME;
|
||||
|
||||
if (!for_replay_) {
|
||||
left_interval = min(left_interval, store_ctx_.timeout_ - ObClockGenerator::getClock());
|
||||
}
|
||||
|
||||
uint64_t timeout = 10000; // 10s
|
||||
common::ObWaitEventGuard wait_guard(
|
||||
common::ObWaitEventIds::MEMSTORE_MEM_PAGE_ALLOC_WAIT, timeout, 0, 0, left_interval);
|
||||
|
||||
while (throttle_tool.still_throttling<ObMemstoreAllocator>(share_ti_guard, module_ti_guard) && (left_interval > 0)) {
|
||||
int64_t expected_wait_time = 0;
|
||||
if (for_replay_ && MTL(ObTenantFreezer *)->exist_ls_freezing()) {
|
||||
// skip throttle if ls freeze exists
|
||||
break;
|
||||
} else if ((expected_wait_time =
|
||||
throttle_tool.expected_wait_time<ObMemstoreAllocator>(share_ti_guard, module_ti_guard)) <= 0) {
|
||||
if (expected_wait_time < 0) {
|
||||
LOG_ERROR("expected wait time should not smaller than 0",
|
||||
K(expected_wait_time),
|
||||
KPC(share_ti_guard.throttle_info()),
|
||||
KPC(module_ti_guard.throttle_info()),
|
||||
K(clock),
|
||||
K(left_interval));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// do sleep when expected_wait_time and left_interval are not equal to 0
|
||||
int64_t sleep_interval = min(SLEEP_INTERVAL_PER_TIME, expected_wait_time);
|
||||
::usleep(sleep_interval);
|
||||
sleep_time += sleep_interval;
|
||||
left_interval -= sleep_interval;
|
||||
|
||||
PRINT_THROTTLE_WARN;
|
||||
}
|
||||
PRINT_THROTTLE_STATISTIC;
|
||||
|
||||
if (for_replay_ && sleep_time > 0) {
|
||||
// avoid print replay_timeout
|
||||
get_replay_is_writing_throttling() = true;
|
||||
}
|
||||
}
|
||||
|
||||
#undef PRINT_THROTTLE_WARN
|
||||
#undef PRINT_THROTTLE_STATISTIC
|
||||
|
||||
int ObStorageTableGuard::refresh_and_protect_table(ObRelativeTable &relative_table)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user