[FIX] do throttle after creating tx ctx or rollback to savepoint in replay situation
This commit is contained in:
@ -96,16 +96,9 @@ void *ObTenantTxDataAllocator::alloc(const bool enable_throttle, const int64_t a
|
||||
bool is_throttled = false;
|
||||
(void)throttle_tool_->alloc_resource<ObTenantTxDataAllocator>(
|
||||
storage::TX_DATA_SLICE_SIZE, abs_expire_time, is_throttled);
|
||||
|
||||
if (OB_UNLIKELY(is_throttled)) {
|
||||
if (MTL(ObTenantFreezer *)->exist_ls_freezing()) {
|
||||
(void)throttle_tool_->skip_throttle<ObTenantTxDataAllocator>(storage::TX_DATA_SLICE_SIZE);
|
||||
} else {
|
||||
uint64_t timeout = 10000; // 10s
|
||||
int64_t left_interval = abs_expire_time - ObClockGenerator::getClock();
|
||||
common::ObWaitEventGuard wait_guard(
|
||||
common::ObWaitEventIds::MEMSTORE_MEM_PAGE_ALLOC_WAIT, timeout, 0, 0, left_interval);
|
||||
(void)throttle_tool_->do_throttle<ObTenantTxDataAllocator>(abs_expire_time);
|
||||
}
|
||||
share::tx_data_throttled_alloc() += storage::TX_DATA_SLICE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,5 +107,45 @@ void *ObTenantTxDataAllocator::alloc(const bool enable_throttle, const int64_t a
|
||||
return res;
|
||||
}
|
||||
|
||||
ObTxDataThrottleGuard::ObTxDataThrottleGuard(const bool for_replay, const int64_t abs_expire_time)
|
||||
: for_replay_(for_replay), abs_expire_time_(abs_expire_time)
|
||||
{
|
||||
throttle_tool_ = &(MTL(ObSharedMemAllocMgr *)->share_resource_throttle_tool());
|
||||
}
|
||||
|
||||
ObTxDataThrottleGuard::~ObTxDataThrottleGuard()
|
||||
{
|
||||
ObThrottleInfoGuard share_ti_guard;
|
||||
ObThrottleInfoGuard module_ti_guard;
|
||||
|
||||
if (OB_ISNULL(throttle_tool_)) {
|
||||
MDS_LOG_RET(ERROR, OB_ERR_UNEXPECTED, "throttle tool is unexpected nullptr", KP(throttle_tool_));
|
||||
} else if (throttle_tool_->is_throttling<ObTenantTxDataAllocator>(share_ti_guard, module_ti_guard)) {
|
||||
if (MTL(ObTenantFreezer *)->exist_ls_freezing()) {
|
||||
(void)throttle_tool_->skip_throttle<ObTenantTxDataAllocator>(
|
||||
share::tx_data_throttled_alloc(), share_ti_guard, module_ti_guard);
|
||||
|
||||
if (module_ti_guard.is_valid()) {
|
||||
module_ti_guard.throttle_info()->reset();
|
||||
}
|
||||
} else {
|
||||
uint64_t timeout = 10000; // 10s
|
||||
int64_t left_interval = abs_expire_time_ - ObClockGenerator::getClock();
|
||||
common::ObWaitEventGuard wait_guard(
|
||||
common::ObWaitEventIds::MEMSTORE_MEM_PAGE_ALLOC_WAIT, timeout, 0, 0, left_interval);
|
||||
(void)throttle_tool_->do_throttle<ObTenantTxDataAllocator>(abs_expire_time_);
|
||||
|
||||
if (for_replay_) {
|
||||
get_replay_is_writing_throttling() = true;
|
||||
}
|
||||
}
|
||||
|
||||
// reset tx data throttled alloc size
|
||||
share::tx_data_throttled_alloc() = 0;
|
||||
} else {
|
||||
// do not need throttle, exit directly
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace share
|
||||
} // namespace oceanbase
|
Reference in New Issue
Block a user