Add backoff to lookupTenantImpl for commit_proxy_memory_limit_exceeded error

This commit is contained in:
Jingyu Zhou 2023-04-19 16:55:46 -07:00
parent 3bfd353a22
commit a83295e3bd
1 changed files with 25 additions and 9 deletions

View File

@ -3444,16 +3444,32 @@ SpanContext generateSpanID(bool transactionTracingSample, SpanContext parentCont
ACTOR Future<int64_t> lookupTenantImpl(DatabaseContext* cx, TenantName tenant) {
loop {
++cx->transactionTenantLookupRequests;
choose {
when(wait(cx->onProxiesChanged())) {}
when(GetTenantIdReply rep = wait(basicLoadBalance(cx->getCommitProxies(UseProvisionalProxies::False),
&CommitProxyInterface::getTenantId,
GetTenantIdRequest(tenant, latestVersion),
TaskPriority::DefaultPromiseEndpoint))) {
++cx->transactionTenantLookupRequestsCompleted;
return rep.tenantId;
try {
double backoff = cx->getBackoff();
if (backoff > 0.0) {
wait(delay(backoff));
}
++cx->transactionTenantLookupRequests;
choose {
when(wait(cx->onProxiesChanged())) {}
when(GetTenantIdReply rep = wait(basicLoadBalance(cx->getCommitProxies(UseProvisionalProxies::False),
&CommitProxyInterface::getTenantId,
GetTenantIdRequest(tenant, latestVersion),
TaskPriority::DefaultPromiseEndpoint))) {
++cx->transactionTenantLookupRequestsCompleted;
cx->updateBackoff(success());
return rep.tenantId;
}
}
} catch (Error& e) {
if (e.code() == error_code_commit_proxy_memory_limit_exceeded) {
// Eats commit_proxy_memory_limit_exceeded error from commit proxies
cx->updateBackoff(e);
continue;
}
throw;
}
}
}