Improve comments on runRYWTransaction*, use MAX_TENANTS_PER_CLUSTER instead of TOO_MANY knob in tenant cache.

This commit is contained in:
A.J. Beamon 2023-02-03 15:35:47 -08:00
parent 72c5abc0f5
commit 6991b62106
2 changed files with 16 additions and 3 deletions

View File

@ -35,6 +35,14 @@
#include "fdbclient/ReadYourWrites.h"
#include "flow/actorcompiler.h" // This must be the last #include.
// Runs a RYW transaction in a retry loop on the given Database.
//
// Takes a function func that accepts a Reference<ReadYourWritesTransaction> as a parameter and returns a non-Void
// Future. This function is run inside the transaction, and when the transaction is successfully committed the result of
// the function is returned.
//
// The supplied function should be idempotent. Otherwise, outcome of this function will depend on how many times the
// transaction is retried.
ACTOR template <class Function>
Future<decltype(std::declval<Function>()(Reference<ReadYourWritesTransaction>()).getValue())> runRYWTransaction(
Database cx,
@ -42,7 +50,6 @@ Future<decltype(std::declval<Function>()(Reference<ReadYourWritesTransaction>())
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
loop {
try {
// func should be idempotent; otherwise, retry will get undefined result
state decltype(std::declval<Function>()(Reference<ReadYourWritesTransaction>()).getValue()) result =
wait(func(tr));
wait(tr->commit());
@ -53,12 +60,18 @@ Future<decltype(std::declval<Function>()(Reference<ReadYourWritesTransaction>())
}
}
// Runs a RYW transaction in a retry loop on the given Database.
//
// Takes a function func that accepts a Reference<ReadYourWritesTransaction> as a parameter and returns a Void
// Future. This function is run inside the transaction.
//
// The supplied function should be idempotent. Otherwise, outcome of this function will depend on how many times the
// transaction is retried.
ACTOR template <class Function>
Future<Void> runRYWTransactionVoid(Database cx, Function func) {
state Reference<ReadYourWritesTransaction> tr(new ReadYourWritesTransaction(cx));
loop {
try {
// func should be idempotent; otherwise, retry will get undefined result
wait(func(tr));
wait(tr->commit());
return Void();

View File

@ -196,7 +196,7 @@ public:
try {
tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS);
state KeyBackedRangeResult<std::pair<TenantGroupName, int64_t>> currentQuotas =
wait(TenantMetadata::storageQuota().getRange(tr, {}, {}, CLIENT_KNOBS->TOO_MANY));
wait(TenantMetadata::storageQuota().getRange(tr, {}, {}, CLIENT_KNOBS->MAX_TENANTS_PER_CLUSTER));
// Reset the quota for all groups; this essentially sets the quota to `max` for groups where the
// quota might have been cleared (i.e., groups that will not be returned in `getRange` request above).
for (auto& [group, storage] : tenantCache->tenantStorageMap) {