MCPcopy Create free account
hub / github.com/apple/foundationdb / getBackoff

Method getBackoff

fdbclient/NativeAPI.actor.cpp:5744–5777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5742}
5743
5744double Transaction::getBackoff(int errCode) {
5745 double returnedBackoff = backoff;
5746
5747 if (errCode == error_code_tag_throttled) {
5748 auto priorityItr = trState->cx->throttledTags.find(trState->options.priority);
5749 for (auto& tag : trState->options.tags) {
5750 if (priorityItr != trState->cx->throttledTags.end()) {
5751 auto tagItr = priorityItr->second.find(tag);
5752 if (tagItr != priorityItr->second.end()) {
5753 CODE_PROBE(true, "Returning throttle backoff");
5754 returnedBackoff = std::max(
5755 returnedBackoff,
5756 std::min(CLIENT_KNOBS->TAG_THROTTLE_RECHECK_INTERVAL, tagItr->second.throttleDuration()));
5757 if (returnedBackoff == CLIENT_KNOBS->TAG_THROTTLE_RECHECK_INTERVAL) {
5758 break;
5759 }
5760 }
5761 }
5762 }
5763 }
5764
5765 returnedBackoff *= deterministicRandom()->random01();
5766
5767 // Set backoff for next time
5768 if (errCode == error_code_commit_proxy_memory_limit_exceeded ||
5769 errCode == error_code_grv_proxy_memory_limit_exceeded) {
5770
5771 backoff = std::min(backoff * CLIENT_KNOBS->BACKOFF_GROWTH_RATE, CLIENT_KNOBS->RESOURCE_CONSTRAINED_MAX_BACKOFF);
5772 } else {
5773 backoff = std::min(backoff * CLIENT_KNOBS->BACKOFF_GROWTH_RATE, trState->options.maxBackoff);
5774 }
5775
5776 return returnedBackoff;
5777}
5778
5779TransactionOptions::TransactionOptions(Database const& cx) {
5780 reset(cx);

Callers

nothing calls this directly

Calls 5

deterministicRandomFunction · 0.85
throttleDurationMethod · 0.80
random01Method · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected