diff --git a/fdbclient/CommitProxyInterface.h b/fdbclient/CommitProxyInterface.h index cc86294d6f..a0d396694c 100644 --- a/fdbclient/CommitProxyInterface.h +++ b/fdbclient/CommitProxyInterface.h @@ -199,7 +199,7 @@ struct GetReadVersionReply : public BasicLoadBalancedReply { Optional metadataVersion; int64_t midShardSize = 0; uint32_t queueIterations = 0; - bool rkThrottled; + bool rkThrottled = false; TransactionTagMap tagThrottleInfo; diff --git a/fdbclient/DatabaseContext.h b/fdbclient/DatabaseContext.h index bbd1d5fd6a..0ba157a04d 100644 --- a/fdbclient/DatabaseContext.h +++ b/fdbclient/DatabaseContext.h @@ -470,16 +470,16 @@ public: // GRV Cache // Database-level read version cache storing the most recent successful GRV as well as the time it was requested. - double lastTimedGrv; - Version cachedRv; - void updateCachedRV(double t, Version v); - Version getCachedRV(); - double getLastTimedGRV(); - double lastTimedRkThrottle; + double lastGrvTime; + Version cachedReadVersion; + void updateCachedReadVersion(double t, Version v); + Version getCachedReadVersion(); + double getLastGrvTime(); + double lastRkThrottleTime; // Cached RVs can be updated through commits, and using cached RVs avoids the proxies altogether // Because our checks for ratekeeper throttling requires communication with the proxies, // we want to track the last time in order to periodically contact the proxy to check for throttling - double lastProxyRequest; + double lastProxyRequestTime; int snapshotRywEnabled; diff --git a/fdbclient/NativeAPI.actor.cpp b/fdbclient/NativeAPI.actor.cpp index c896301df4..4c8947d81f 100644 --- a/fdbclient/NativeAPI.actor.cpp +++ b/fdbclient/NativeAPI.actor.cpp @@ -206,30 +206,30 @@ void DatabaseContext::removeTssMapping(StorageServerInterface const& ssi) { } } -void DatabaseContext::updateCachedRV(double t, Version v) { - if (v >= cachedRv) { - TraceEvent("CheckpointCacheUpdate") +void DatabaseContext::updateCachedReadVersion(double t, Version v) { + if (v >= cachedReadVersion) { + TraceEvent(SevDebug, "CachedReadVersionUpdate") .detail("Version", v) - .detail("CurTime", t) - .detail("LastVersion", cachedRv) - .detail("LastTime", lastTimedGrv); - cachedRv = v; + .detail("GrvStartTime", t) + .detail("LastVersion", cachedReadVersion) + .detail("LastTime", lastGrvTime); + cachedReadVersion = v; // Since the time is based on the start of the request, it's possible that we // get a newer version with an older time. // (Request started earlier, but was latest to reach the proxy) // Only update time when strictly increasing (?) - if (t > lastTimedGrv) { - lastTimedGrv = t; + if (t > lastGrvTime) { + lastGrvTime = t; } } } -Version DatabaseContext::getCachedRV() { - return cachedRv; +Version DatabaseContext::getCachedReadVersion() { + return cachedReadVersion; } -double DatabaseContext::getLastTimedGRV() { - return lastTimedGrv; +double DatabaseContext::getLastGrvTime() { + return lastGrvTime; } Reference StorageServerInfo::getInterface(DatabaseContext* cx, @@ -1036,16 +1036,18 @@ ACTOR static Future backgroundGrvUpdater(DatabaseContext* cx) { state double grvDelay = 0.001; try { loop { + if (CLIENT_KNOBS->FORCE_GRV_CACHE_OFF) + return Void(); wait(refreshTransaction(cx, &tr)); state double curTime = now(); - state double lastTime = cx->getLastTimedGRV(); - state double lastProxyTime = cx->lastProxyRequest; + state double lastTime = cx->getLastGrvTime(); + state double lastProxyTime = cx->lastProxyRequestTime; TraceEvent(SevDebug, "BackgroundGrvUpdaterBefore") .detail("CurTime", curTime) .detail("LastTime", lastTime) .detail("GrvDelay", grvDelay) - .detail("CachedRv", cx->getCachedRV()) - .detail("CachedTime", cx->getLastTimedGRV()) + .detail("CachedReadVersion", cx->getCachedReadVersion()) + .detail("CachedTime", cx->getLastGrvTime()) .detail("Gap", curTime - lastTime) .detail("Bound", CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay); if (curTime - lastTime >= (CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay) || @@ -1053,18 +1055,19 @@ ACTOR static Future backgroundGrvUpdater(DatabaseContext* cx) { try { tr.setOption(FDBTransactionOptions::SKIP_GRV_CACHE); wait(success(tr.getReadVersion())); - cx->lastProxyRequest = curTime; + cx->lastProxyRequestTime = curTime; grvDelay = (grvDelay + (now() - curTime)) / 2.0; TraceEvent(SevDebug, "BackgroundGrvUpdaterSuccess") .detail("GrvDelay", grvDelay) - .detail("CachedRv", cx->getCachedRV()) - .detail("CachedTime", cx->getLastTimedGRV()); + .detail("CachedReadVersion", cx->getCachedReadVersion()) + .detail("CachedTime", cx->getLastGrvTime()); } catch (Error& e) { TraceEvent(SevInfo, "BackgroundGrvUpdaterTxnError").error(e, true); wait(tr.onError(e)); } } else { - wait(delay(0.001 + (CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay) - (curTime - lastTime))); + wait(delay(0.001 + std::min(CLIENT_KNOBS->MAX_PROXY_CONTACT_LAG - (curTime - lastProxyTime), + (CLIENT_KNOBS->MAX_VERSION_CACHE_LAG - grvDelay) - (curTime - lastTime)))); } } } catch (Error& e) { @@ -1301,8 +1304,8 @@ DatabaseContext::DatabaseContext(ReferenceSHARD_STAT_SMOOTH_AMOUNT), @@ -5352,7 +5355,7 @@ ACTOR static Future tryCommit(Reference trState, if (CLIENT_BUGGIFY) { throw commit_unknown_result(); } - trState->cx->updateCachedRV(grvTime, v); + trState->cx->updateCachedReadVersion(grvTime, v); if (debugID.present()) TraceEvent(interval.end()).detail("CommittedVersion", v); trState->committedVersion = v; @@ -5959,10 +5962,10 @@ ACTOR Future extractReadVersion(Reference trState, state Span span(spanContext, location, { trState->spanID }); GetReadVersionReply rep = wait(f); double latency = now() - trState->startTime; - trState->cx->lastProxyRequest = trState->startTime; - trState->cx->updateCachedRV(trState->startTime, rep.version); + trState->cx->lastProxyRequestTime = trState->startTime; + trState->cx->updateCachedReadVersion(trState->startTime, rep.version); if (rep.rkThrottled && trState->options.priority != TransactionPriority::IMMEDIATE) { - trState->cx->lastTimedRkThrottle = now(); + trState->cx->lastRkThrottleTime = now(); } trState->cx->GRVLatencies.addSample(latency); if (trState->trLogInfo) @@ -6021,10 +6024,10 @@ ACTOR Future extractReadVersion(Reference trState, } bool rkThrottlingCooledDown(DatabaseContext* cx) { - if (cx->lastTimedRkThrottle == 0.0) { + if (cx->lastRkThrottleTime == 0.0) { return true; } - return (now() - cx->lastTimedRkThrottle > CLIENT_KNOBS->GRV_CACHE_RK_COOLDOWN); + return (now() - cx->lastRkThrottleTime > CLIENT_KNOBS->GRV_CACHE_RK_COOLDOWN); } Future Transaction::getReadVersion(uint32_t flags) { @@ -6037,8 +6040,8 @@ Future Transaction::getReadVersion(uint32_t flags) { if (!trState->cx->grvUpdateHandler.isValid()) { trState->cx->grvUpdateHandler = backgroundGrvUpdater(getDatabase().getPtr()); } - Version rv = trState->cx->getCachedRV(); - double lastTime = trState->cx->getLastTimedGRV(); + Version rv = trState->cx->getCachedReadVersion(); + double lastTime = trState->cx->getLastGrvTime(); double requestTime = now(); if (requestTime - lastTime <= CLIENT_KNOBS->MAX_VERSION_CACHE_LAG && rv != Version(0)) { ASSERT(!debug_checkVersionTime(rv, requestTime, "CheckStaleness")); @@ -6046,9 +6049,6 @@ Future Transaction::getReadVersion(uint32_t flags) { return readVersion; } // else go through regular GRV path } - if (CLIENT_KNOBS->FORCE_GRV_CACHE_OFF && trState->cx->grvUpdateHandler.isValid()) { - trState->cx->grvUpdateHandler.cancel(); - } ++trState->cx->transactionReadVersions; flags |= trState->options.getReadVersionFlags; switch (trState->options.priority) { diff --git a/fdbclient/ReadYourWrites.actor.cpp b/fdbclient/ReadYourWrites.actor.cpp index fd495382b2..fdc1d5c771 100644 --- a/fdbclient/ReadYourWrites.actor.cpp +++ b/fdbclient/ReadYourWrites.actor.cpp @@ -2410,12 +2410,6 @@ void ReadYourWritesTransaction::setOptionImpl(FDBTransactionOptions::Option opti validateOptionValueNotPresent(value); options.bypassUnreadable = true; break; - case FDBTransactionOptions::USE_GRV_CACHE: - validateOptionValueNotPresent(value); - options.useGrvCache = true; - case FDBTransactionOptions::SKIP_GRV_CACHE: - validateOptionValueNotPresent(value); - options.skipGrvCache = true; default: break; } diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index cd87ed2851..3e91511bf7 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -293,9 +293,9 @@ description is not currently required but encouraged.