Specify option to specifically skip grv cache for the background updater when using debug knob

This commit is contained in:
Jon Fu 2021-10-08 17:25:07 -04:00
parent b770936cde
commit 2b2d059039
5 changed files with 15 additions and 1 deletions

View File

@ -951,6 +951,7 @@ ACTOR static Future<Void> backgroundGrvUpdater(DatabaseContext* cx) {
.detail("Bound", CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay);
if (curTime - lastTime >= (CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay)) {
try {
tr.setOption(FDBTransactionOptions::SKIP_GRV_CACHE);
wait(success(tr.getReadVersion()));
grvDelay = (grvDelay + (now() - curTime)) / 2.0;
TraceEvent(SevDebug, "BackgroundGrvUpdaterSuccess")
@ -4789,6 +4790,7 @@ void TransactionOptions::clear() {
priority = TransactionPriority::DEFAULT;
expensiveClearCostEstimation = false;
useGrvCache = false;
skipGrvCache = false;
}
TransactionOptions::TransactionOptions() {
@ -5567,6 +5569,11 @@ void Transaction::setOption(FDBTransactionOptions::Option option, Optional<Strin
options.useGrvCache = true;
break;
case FDBTransactionOptions::SKIP_GRV_CACHE:
validateOptionValueNotPresent(value);
options.skipGrvCache = true;
break;
default:
break;
}
@ -5783,7 +5790,7 @@ ACTOR Future<Version> getDBCachedReadVersion(DatabaseContext* cx, double request
Future<Version> Transaction::getReadVersion(uint32_t flags) {
if (!readVersion.isValid()) {
if ((CLIENT_KNOBS->DEBUG_USE_GRV_CACHE || options.useGrvCache) && cx->cachedRv > Version(0)) {
if (!options.skipGrvCache && (CLIENT_KNOBS->DEBUG_USE_GRV_CACHE || options.useGrvCache)) {
// Upon our first request to use cached RVs, start the background updater
if (!cx->grvUpdateHandler.isValid()) {
cx->grvUpdateHandler = backgroundGrvUpdater(getDatabase().getPtr());

View File

@ -154,6 +154,7 @@ struct TransactionOptions {
bool reportConflictingKeys : 1;
bool expensiveClearCostEstimation : 1;
bool useGrvCache : 1;
bool skipGrvCache : 1;
TransactionPriority priority;

View File

@ -2252,6 +2252,9 @@ void ReadYourWritesTransaction::setOptionImpl(FDBTransactionOptions::Option opti
case FDBTransactionOptions::USE_GRV_CACHE:
validateOptionValueNotPresent(value);
options.useGrvCache = true;
case FDBTransactionOptions::SKIP_GRV_CACHE:
validateOptionValueNotPresent(value);
options.skipGrvCache = true;
default:
break;
}

View File

@ -45,6 +45,7 @@ struct ReadYourWritesTransactionOptions {
int snapshotRywEnabled;
bool bypassUnreadable : 1;
bool useGrvCache : 1;
bool skipGrvCache : 1;
ReadYourWritesTransactionOptions() {}
explicit ReadYourWritesTransactionOptions(Transaction const& tr);

View File

@ -296,6 +296,8 @@ description is not currently required but encouraged.
description="Allows ``get`` operations to read from sections of keyspace that have become unreadable because of versionstamp operations. These reads will view versionstamp operations as if they were set operations that did not fill in the versionstamp." />
<Option name="use_grv_cache" code="1101"
description="Allows this transaction to use cached GRV from the database context." />
<Option name="skip_grv_cache" code="1102"
description="Specifically instruct this transaction to NOT use cached GRV." />
</Scope>
<!-- The enumeration values matter - do not change them without