update trState ReadOption to optional

This commit is contained in:
Fuheng Zhao 2022-08-24 15:04:17 -07:00
parent 4e748d6bed
commit 7c6dbaf3cf
14 changed files with 149 additions and 159 deletions

View File

@ -230,9 +230,9 @@ void DatabaseContext::getLatestCommitVersions(const Reference<LocationInfo>& loc
VersionVector& latestCommitVersions) { VersionVector& latestCommitVersions) {
latestCommitVersions.clear(); latestCommitVersions.clear();
if (info->readOptions.debugID.present()) { if (info->readOptions.present() && info->readOptions.get().debugID.present()) {
g_traceBatch.addEvent( g_traceBatch.addEvent(
"TransactionDebug", info->readOptions.debugID.get().first(), "NativeAPI.getLatestCommitVersions"); "TransactionDebug", info->readOptions.get().debugID.get().first(), "NativeAPI.getLatestCommitVersions");
} }
if (!info->readVersionObtainedFromGrvProxy) { if (!info->readVersionObtainedFromGrvProxy) {
@ -2988,7 +2988,7 @@ Future<KeyRangeLocationInfo> getKeyLocation(Reference<TransactionState> trState,
key, key,
member, member,
trState->spanContext, trState->spanContext,
trState->readOptions.debugID, trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>(),
trState->useProvisionalProxies, trState->useProvisionalProxies,
isBackward, isBackward,
version); version);
@ -3129,7 +3129,7 @@ Future<std::vector<KeyRangeLocationInfo>> getKeyRangeLocations(Reference<Transac
reverse, reverse,
member, member,
trState->spanContext, trState->spanContext,
trState->readOptions.debugID, trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>(),
trState->useProvisionalProxies, trState->useProvisionalProxies,
version); version);
@ -3151,16 +3151,16 @@ ACTOR Future<Void> warmRange_impl(Reference<TransactionState> trState, KeyRange
state Version version = wait(fVersion); state Version version = wait(fVersion);
loop { loop {
std::vector<KeyRangeLocationInfo> locations = std::vector<KeyRangeLocationInfo> locations = wait(getKeyRangeLocations_internal(
wait(getKeyRangeLocations_internal(trState->cx, trState->cx,
trState->getTenantInfo(), trState->getTenantInfo(),
keys, keys,
CLIENT_KNOBS->WARM_RANGE_SHARD_LIMIT, CLIENT_KNOBS->WARM_RANGE_SHARD_LIMIT,
Reverse::False, Reverse::False,
trState->spanContext, trState->spanContext,
trState->readOptions.debugID, trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>(),
trState->useProvisionalProxies, trState->useProvisionalProxies,
version)); version));
totalRanges += CLIENT_KNOBS->WARM_RANGE_SHARD_LIMIT; totalRanges += CLIENT_KNOBS->WARM_RANGE_SHARD_LIMIT;
totalRequests++; totalRequests++;
if (locations.size() == 0 || totalRanges >= trState->cx->locationCacheSize || if (locations.size() == 0 || totalRanges >= trState->cx->locationCacheSize ||
@ -3318,14 +3318,16 @@ ACTOR Future<Optional<Value>> getValue(Reference<TransactionState> trState,
state uint64_t startTime; state uint64_t startTime;
state double startTimeD; state double startTimeD;
state VersionVector ssLatestCommitVersions; state VersionVector ssLatestCommitVersions;
state ReadOptions readOptions = trState->readOptions; state Optional<ReadOptions> readOptions = trState->readOptions;
trState->cx->getLatestCommitVersions(locationInfo.locations, ver, trState, ssLatestCommitVersions); trState->cx->getLatestCommitVersions(locationInfo.locations, ver, trState, ssLatestCommitVersions);
try { try {
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
getValueID = nondeterministicRandom()->randomUniqueID(); getValueID = nondeterministicRandom()->randomUniqueID();
readOptions.get().debugID = getValueID;
g_traceBatch.addAttach( g_traceBatch.addAttach(
"GetValueAttachID", trState->readOptions.debugID.get().first(), getValueID.get().first()); "GetValueAttachID", trState->readOptions.get().debugID.get().first(), getValueID.get().first());
g_traceBatch.addEvent("GetValueDebug", g_traceBatch.addEvent("GetValueDebug",
getValueID.get().first(), getValueID.get().first(),
"NativeAPI.getValue.Before"); //.detail("TaskID", g_network->getCurrentTask()); "NativeAPI.getValue.Before"); //.detail("TaskID", g_network->getCurrentTask());
@ -3334,7 +3336,7 @@ ACTOR Future<Optional<Value>> getValue(Reference<TransactionState> trState,
.detail("ReqVersion", ver) .detail("ReqVersion", ver)
.detail("Servers", describe(ssi.second->get()));*/ .detail("Servers", describe(ssi.second->get()));*/
} }
readOptions.debugID = getValueID;
++trState->cx->getValueSubmitted; ++trState->cx->getValueSubmitted;
startTime = timer_int(); startTime = timer_int();
startTimeD = now(); startTimeD = now();
@ -3434,11 +3436,15 @@ ACTOR Future<Key> getKey(Reference<TransactionState> trState,
wait(success(version)); wait(success(version));
state Optional<UID> getKeyID; state Optional<UID> getKeyID;
state Span span("NAPI:getKey"_loc, trState->spanContext); state Optional<ReadOptions> readOptions = trState->readOptions;
if (trState->readOptions.debugID.present()) {
getKeyID = nondeterministicRandom()->randomUniqueID();
g_traceBatch.addAttach("GetKeyAttachID", trState->readOptions.debugID.get().first(), getKeyID.get().first()); state Span span("NAPI:getKey"_loc, trState->spanContext);
if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
getKeyID = nondeterministicRandom()->randomUniqueID();
readOptions.get().debugID = getKeyID;
g_traceBatch.addAttach(
"GetKeyAttachID", trState->readOptions.get().debugID.get().first(), getKeyID.get().first());
g_traceBatch.addEvent( g_traceBatch.addEvent(
"GetKeyDebug", "GetKeyDebug",
getKeyID.get().first(), getKeyID.get().first(),
@ -3466,10 +3472,7 @@ ACTOR Future<Key> getKey(Reference<TransactionState> trState,
state VersionVector ssLatestCommitVersions; state VersionVector ssLatestCommitVersions;
trState->cx->getLatestCommitVersions(locationInfo.locations, version.get(), trState, ssLatestCommitVersions); trState->cx->getLatestCommitVersions(locationInfo.locations, version.get(), trState, ssLatestCommitVersions);
state ReadOptions readOptions = trState->readOptions;
readOptions.debugID = getKeyID;
state bool sendReadOption =
readOptions.debugID.present() || readOptions.type != ReadType::NORMAL || readOptions.cacheResult != true;
try { try {
if (getKeyID.present()) if (getKeyID.present())
g_traceBatch.addEvent( g_traceBatch.addEvent(
@ -3484,7 +3487,7 @@ ACTOR Future<Key> getKey(Reference<TransactionState> trState,
k, k,
version.get(), version.get(),
trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>(), trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>(),
sendReadOption ? readOptions : Optional<ReadOptions>(), readOptions,
ssLatestCommitVersions); ssLatestCommitVersions);
req.arena.dependsOn(k.arena()); req.arena.dependsOn(k.arena());
@ -3943,17 +3946,13 @@ Future<RangeResultFamily> getExactRange(Reference<TransactionState> trState,
// FIXME: buggify byte limits on internal functions that use them, instead of globally // FIXME: buggify byte limits on internal functions that use them, instead of globally
req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>(); req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>();
if (trState->readOptions.type != ReadType::NORMAL || trState->readOptions.cacheResult != true ||
trState->readOptions.debugID.present()) { req.options = trState->readOptions;
RangeReadOptions rangeOptions;
rangeOptions = trState->readOptions;
req.options = Optional<RangeReadOptions>(rangeOptions);
}
try { try {
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
g_traceBatch.addEvent("TransactionDebug", g_traceBatch.addEvent("TransactionDebug",
trState->readOptions.debugID.get().first(), trState->readOptions.get().debugID.get().first(),
"NativeAPI.getExactRange.Before"); "NativeAPI.getExactRange.Before");
/*TraceEvent("TransactionDebugGetExactRangeInfo", trState->readOptions.debugID.get()) /*TraceEvent("TransactionDebugGetExactRangeInfo", trState->readOptions.debugID.get())
.detail("ReqBeginKey", req.begin.getKey()) .detail("ReqBeginKey", req.begin.getKey())
@ -3985,9 +3984,9 @@ Future<RangeResultFamily> getExactRange(Reference<TransactionState> trState,
++trState->cx->transactionPhysicalReadsCompleted; ++trState->cx->transactionPhysicalReadsCompleted;
throw; throw;
} }
if (trState->readOptions.debugID.present()) if (trState->readOptions.present() && trState->readOptions.get().debugID.present())
g_traceBatch.addEvent("TransactionDebug", g_traceBatch.addEvent("TransactionDebug",
trState->readOptions.debugID.get().first(), trState->readOptions.get().debugID.get().first(),
"NativeAPI.getExactRange.After"); "NativeAPI.getExactRange.After");
output.arena().dependsOn(rep.arena); output.arena().dependsOn(rep.arena);
output.append(output.arena(), rep.data.begin(), rep.data.size()); output.append(output.arena(), rep.data.begin(), rep.data.size());
@ -4316,12 +4315,7 @@ Future<RangeResultFamily> getRange(Reference<TransactionState> trState,
req.arena.dependsOn(mapper.arena()); req.arena.dependsOn(mapper.arena());
setMatchIndex<GetKeyValuesFamilyRequest>(req, matchIndex); setMatchIndex<GetKeyValuesFamilyRequest>(req, matchIndex);
req.tenantInfo = useTenant ? trState->getTenantInfo() : TenantInfo(); req.tenantInfo = useTenant ? trState->getTenantInfo() : TenantInfo();
if (trState->readOptions.type != ReadType::NORMAL || trState->readOptions.cacheResult != true || req.options = trState->readOptions;
trState->readOptions.debugID.present()) {
RangeReadOptions rangeOptions;
rangeOptions = trState->readOptions;
req.options = Optional<RangeReadOptions>(rangeOptions);
}
req.version = readVersion; req.version = readVersion;
trState->cx->getLatestCommitVersions( trState->cx->getLatestCommitVersions(
@ -4361,9 +4355,10 @@ Future<RangeResultFamily> getRange(Reference<TransactionState> trState,
req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>(); req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>();
req.spanContext = span.context; req.spanContext = span.context;
try { try {
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
g_traceBatch.addEvent( g_traceBatch.addEvent("TransactionDebug",
"TransactionDebug", trState->readOptions.debugID.get().first(), "NativeAPI.getRange.Before"); trState->readOptions.get().debugID.get().first(),
"NativeAPI.getRange.Before");
/*TraceEvent("TransactionDebugGetRangeInfo", trState->readOptions.debugID.get()) /*TraceEvent("TransactionDebugGetRangeInfo", trState->readOptions.debugID.get())
.detail("ReqBeginKey", req.begin.getKey()) .detail("ReqBeginKey", req.begin.getKey())
.detail("ReqEndKey", req.end.getKey()) .detail("ReqEndKey", req.end.getKey())
@ -4403,9 +4398,9 @@ Future<RangeResultFamily> getRange(Reference<TransactionState> trState,
throw; throw;
} }
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
g_traceBatch.addEvent("TransactionDebug", g_traceBatch.addEvent("TransactionDebug",
trState->readOptions.debugID.get().first(), trState->readOptions.get().debugID.get().first(),
"NativeAPI.getRange.After"); //.detail("SizeOf", rep.data.size()); "NativeAPI.getRange.After"); //.detail("SizeOf", rep.data.size());
/*TraceEvent("TransactionDebugGetRangeDone", trState->readOptions.debugID.get()) /*TraceEvent("TransactionDebugGetRangeDone", trState->readOptions.debugID.get())
.detail("ReqBeginKey", req.begin.getKey()) .detail("ReqBeginKey", req.begin.getKey())
@ -4519,10 +4514,11 @@ Future<RangeResultFamily> getRange(Reference<TransactionState> trState,
} }
} catch (Error& e) { } catch (Error& e) {
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
g_traceBatch.addEvent( g_traceBatch.addEvent("TransactionDebug",
"TransactionDebug", trState->readOptions.debugID.get().first(), "NativeAPI.getRange.Error"); trState->readOptions.get().debugID.get().first(),
TraceEvent("TransactionDebugError", trState->readOptions.debugID.get()).error(e); "NativeAPI.getRange.Error");
TraceEvent("TransactionDebugError", trState->readOptions.get().debugID.get()).error(e);
} }
if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed || if (e.code() == error_code_wrong_shard_server || e.code() == error_code_all_alternatives_failed ||
(e.code() == error_code_transaction_too_old && readVersion == latestVersion)) { (e.code() == error_code_transaction_too_old && readVersion == latestVersion)) {
@ -4774,12 +4770,7 @@ ACTOR Future<Void> getRangeStreamFragment(Reference<TransactionState> trState,
req.spanContext = spanContext; req.spanContext = spanContext;
req.limit = reverse ? -CLIENT_KNOBS->REPLY_BYTE_LIMIT : CLIENT_KNOBS->REPLY_BYTE_LIMIT; req.limit = reverse ? -CLIENT_KNOBS->REPLY_BYTE_LIMIT : CLIENT_KNOBS->REPLY_BYTE_LIMIT;
req.limitBytes = std::numeric_limits<int>::max(); req.limitBytes = std::numeric_limits<int>::max();
if (trState->readOptions.type != ReadType::NORMAL || trState->readOptions.cacheResult != true || req.options = trState->readOptions;
trState->readOptions.debugID.present()) {
RangeReadOptions rangeOptions;
rangeOptions = trState->readOptions;
req.options = Optional<RangeReadOptions>(rangeOptions);
}
trState->cx->getLatestCommitVersions( trState->cx->getLatestCommitVersions(
locations[shard].locations, req.version, trState, req.ssLatestCommitVersions); locations[shard].locations, req.version, trState, req.ssLatestCommitVersions);
@ -4793,9 +4784,10 @@ ACTOR Future<Void> getRangeStreamFragment(Reference<TransactionState> trState,
req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>(); req.tags = trState->cx->sampleReadTags() ? trState->options.readTags : Optional<TagSet>();
try { try {
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
g_traceBatch.addEvent( g_traceBatch.addEvent("TransactionDebug",
"TransactionDebug", trState->readOptions.debugID.get().first(), "NativeAPI.RangeStream.Before"); trState->readOptions.get().debugID.get().first(),
"NativeAPI.RangeStream.Before");
} }
++trState->cx->transactionPhysicalReads; ++trState->cx->transactionPhysicalReads;
state GetKeyValuesStreamReply rep; state GetKeyValuesStreamReply rep;
@ -4889,9 +4881,9 @@ ACTOR Future<Void> getRangeStreamFragment(Reference<TransactionState> trState,
} }
rep = GetKeyValuesStreamReply(); rep = GetKeyValuesStreamReply();
} }
if (trState->readOptions.debugID.present()) if (trState->readOptions.present() && trState->readOptions.get().debugID.present())
g_traceBatch.addEvent("TransactionDebug", g_traceBatch.addEvent("TransactionDebug",
trState->readOptions.debugID.get().first(), trState->readOptions.get().debugID.get().first(),
"NativeAPI.getExactRange.After"); "NativeAPI.getExactRange.After");
RangeResult output(RangeResultRef(rep.data, rep.more), rep.arena); RangeResult output(RangeResultRef(rep.data, rep.more), rep.arena);
@ -5371,7 +5363,7 @@ Future<Void> Transaction::watch(Reference<Watch> watch) {
trState->options.readTags, trState->options.readTags,
trState->spanContext, trState->spanContext,
trState->taskID, trState->taskID,
trState->readOptions.debugID, trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>(),
trState->useProvisionalProxies); trState->useProvisionalProxies);
} }
@ -6037,16 +6029,17 @@ void Transaction::setupWatches() {
Future<Version> watchVersion = getCommittedVersion() > 0 ? getCommittedVersion() : getReadVersion(); Future<Version> watchVersion = getCommittedVersion() > 0 ? getCommittedVersion() : getReadVersion();
for (int i = 0; i < watches.size(); ++i) for (int i = 0; i < watches.size(); ++i)
watches[i]->setWatch(watchValueMap(watchVersion, watches[i]->setWatch(
trState->getTenantInfo(), watchValueMap(watchVersion,
watches[i]->key, trState->getTenantInfo(),
watches[i]->value, watches[i]->key,
trState->cx, watches[i]->value,
trState->options.readTags, trState->cx,
trState->spanContext, trState->options.readTags,
trState->taskID, trState->spanContext,
trState->readOptions.debugID, trState->taskID,
trState->useProvisionalProxies)); trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>(),
trState->useProvisionalProxies));
watches.clear(); watches.clear();
} catch (Error&) { } catch (Error&) {
@ -6167,7 +6160,7 @@ ACTOR static Future<Void> tryCommit(Reference<TransactionState> trState,
state TraceInterval interval("TransactionCommit"); state TraceInterval interval("TransactionCommit");
state double startTime = now(); state double startTime = now();
state Span span("NAPI:tryCommit"_loc, trState->spanContext); state Span span("NAPI:tryCommit"_loc, trState->spanContext);
state Optional<UID> debugID = trState->readOptions.debugID; state Optional<UID> debugID = trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>();
state TenantPrefixPrepended tenantPrefixPrepended = TenantPrefixPrepended::False; state TenantPrefixPrepended tenantPrefixPrepended = TenantPrefixPrepended::False;
if (debugID.present()) { if (debugID.present()) {
TraceEvent(interval.begin()).detail("Parent", debugID.get()); TraceEvent(interval.begin()).detail("Parent", debugID.get());
@ -6567,10 +6560,10 @@ void Transaction::setOption(FDBTransactionOptions::Option option, Optional<Strin
makeReference<TransactionLogInfo>(value.get().printable(), TransactionLogInfo::DONT_LOG); makeReference<TransactionLogInfo>(value.get().printable(), TransactionLogInfo::DONT_LOG);
trState->trLogInfo->maxFieldLength = trState->options.maxTransactionLoggingFieldLength; trState->trLogInfo->maxFieldLength = trState->options.maxTransactionLoggingFieldLength;
} }
if (trState->readOptions.debugID.present()) { if (trState->readOptions.present() && trState->readOptions.get().debugID.present()) {
TraceEvent(SevInfo, "TransactionBeingTraced") TraceEvent(SevInfo, "TransactionBeingTraced")
.detail("DebugTransactionID", trState->trLogInfo->identifier) .detail("DebugTransactionID", trState->trLogInfo->identifier)
.detail("ServerTraceID", trState->readOptions.debugID.get()); .detail("ServerTraceID", trState->readOptions.get().debugID.get());
} }
break; break;
@ -6602,10 +6595,11 @@ void Transaction::setOption(FDBTransactionOptions::Option option, Optional<Strin
case FDBTransactionOptions::SERVER_REQUEST_TRACING: case FDBTransactionOptions::SERVER_REQUEST_TRACING:
validateOptionValueNotPresent(value); validateOptionValueNotPresent(value);
debugTransaction(deterministicRandom()->randomUniqueID()); debugTransaction(deterministicRandom()->randomUniqueID());
if (trState->trLogInfo && !trState->trLogInfo->identifier.empty()) { if (trState->trLogInfo && !trState->trLogInfo->identifier.empty() && trState->readOptions.present() &&
trState->readOptions.get().debugID.present()) {
TraceEvent(SevInfo, "TransactionBeingTraced") TraceEvent(SevInfo, "TransactionBeingTraced")
.detail("DebugTransactionID", trState->trLogInfo->identifier) .detail("DebugTransactionID", trState->trLogInfo->identifier)
.detail("ServerTraceID", trState->readOptions.debugID.get()); .detail("ServerTraceID", trState->readOptions.get().debugID.get());
} }
break; break;
@ -7073,8 +7067,9 @@ Future<Version> Transaction::getReadVersion(uint32_t flags) {
Location location = "NAPI:getReadVersion"_loc; Location location = "NAPI:getReadVersion"_loc;
SpanContext spanContext = generateSpanID(trState->cx->transactionTracingSample, trState->spanContext); SpanContext spanContext = generateSpanID(trState->cx->transactionTracingSample, trState->spanContext);
auto const req = Optional<UID> versionDebugID =
DatabaseContext::VersionRequest(spanContext, trState->options.tags, trState->readOptions.debugID); trState->readOptions.present() ? trState->readOptions.get().debugID : Optional<UID>();
auto const req = DatabaseContext::VersionRequest(spanContext, trState->options.tags, versionDebugID);
batcher.stream.send(req); batcher.stream.send(req);
trState->startTime = now(); trState->startTime = now();
readVersion = extractReadVersion(trState, location, spanContext, req.reply.getFuture(), metadataVersion); readVersion = extractReadVersion(trState, location, spanContext, req.reply.getFuture(), metadataVersion);
@ -7641,14 +7636,15 @@ ACTOR Future<TenantMapEntry> blobGranuleGetTenantEntry(Transaction* self, Key ra
Optional<KeyRangeLocationInfo> cachedLocationInfo = Optional<KeyRangeLocationInfo> cachedLocationInfo =
self->trState->cx->getCachedLocation(self->getTenant().get(), rangeStartKey, Reverse::False); self->trState->cx->getCachedLocation(self->getTenant().get(), rangeStartKey, Reverse::False);
if (!cachedLocationInfo.present()) { if (!cachedLocationInfo.present()) {
KeyRangeLocationInfo l = wait(getKeyLocation_internal(self->trState->cx, KeyRangeLocationInfo l = wait(getKeyLocation_internal(
self->trState->getTenantInfo(AllowInvalidTenantID::True), self->trState->cx,
rangeStartKey, self->trState->getTenantInfo(AllowInvalidTenantID::True),
self->trState->spanContext, rangeStartKey,
self->trState->readOptions.debugID, self->trState->spanContext,
self->trState->useProvisionalProxies, self->trState->readOptions.present() ? self->trState->readOptions.get().debugID : Optional<UID>(),
Reverse::False, self->trState->useProvisionalProxies,
latestVersion)); Reverse::False,
latestVersion));
self->trState->trySetTenantId(l.tenantEntry.id); self->trState->trySetTenantId(l.tenantEntry.id);
return l.tenantEntry; return l.tenantEntry;
} else { } else {

View File

@ -1522,6 +1522,9 @@ enum class ReadType {
NORMAL, NORMAL,
HIGH, HIGH,
}; };
FDB_DECLARE_BOOLEAN_PARAM(CacheResult);
// store options for storage engine read // store options for storage engine read
// ReadType describes the usage and priority of the read // ReadType describes the usage and priority of the read
// cacheResult determines whether the storage engine cache for this read // cacheResult determines whether the storage engine cache for this read
@ -1529,30 +1532,17 @@ enum class ReadType {
// debugID helps to trace the path of the read // debugID helps to trace the path of the read
struct ReadOptions { struct ReadOptions {
ReadType type; ReadType type;
Optional<UID> debugID;
bool cacheResult; bool cacheResult;
Optional<UID> debugID;
ReadOptions() : type(ReadType::NORMAL), cacheResult(true){};
ReadOptions(ReadType type, bool cacheResult) : type(type), cacheResult(cacheResult){};
template <class Ar>
void serialize(Ar& ar) {
serializer(ar, type, cacheResult, debugID);
}
};
struct RangeReadOptions : ReadOptions {
Optional<Version> consistencyCheckStartVersion; Optional<Version> consistencyCheckStartVersion;
RangeReadOptions() : ReadOptions(){}; ReadOptions() : type(ReadType::NORMAL), cacheResult(CacheResult::True){};
RangeReadOptions& operator=(const ReadOptions& option) { ReadOptions(Optional<UID> debugID,
type = option.type; ReadType type = ReadType::NORMAL,
debugID = option.debugID; CacheResult cache = CacheResult::False,
cacheResult = option.cacheResult; Optional<Version> version = Optional<Version>())
return *this; : type(type), cacheResult(cache), debugID(debugID), consistencyCheckStartVersion(version){};
}
template <class Ar> template <class Ar>
void serialize(Ar& ar) { void serialize(Ar& ar) {

View File

@ -242,7 +242,7 @@ struct TransactionState : ReferenceCounted<TransactionState> {
Optional<Standalone<StringRef>> authToken; Optional<Standalone<StringRef>> authToken;
Reference<TransactionLogInfo> trLogInfo; Reference<TransactionLogInfo> trLogInfo;
TransactionOptions options; TransactionOptions options;
ReadOptions readOptions; Optional<ReadOptions> readOptions;
TaskPriority taskID; TaskPriority taskID;
SpanContext spanContext; SpanContext spanContext;
@ -455,7 +455,13 @@ public:
void fullReset(); void fullReset();
double getBackoff(int errCode); double getBackoff(int errCode);
void debugTransaction(UID dID) { trState->readOptions.debugID = dID; } void debugTransaction(UID dID) {
if (trState->readOptions.present()) {
trState->readOptions.get().debugID = dID;
} else {
trState->readOptions = ReadOptions(dID);
}
}
VersionVector getVersionVector() const; VersionVector getVersionVector() const;
SpanContext getSpanContext() const { return trState->spanContext; } SpanContext getSpanContext() const { return trState->spanContext; }

View File

@ -394,7 +394,7 @@ struct GetKeyValuesRequest : TimedRequest {
int limit, limitBytes; int limit, limitBytes;
Optional<TagSet> tags; Optional<TagSet> tags;
Optional<UID> debugID; Optional<UID> debugID;
Optional<RangeReadOptions> options; Optional<ReadOptions> options;
ReplyPromise<GetKeyValuesReply> reply; ReplyPromise<GetKeyValuesReply> reply;
VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known
// to this client, of all storage replicas that // to this client, of all storage replicas that
@ -452,7 +452,7 @@ struct GetMappedKeyValuesRequest : TimedRequest {
int limit, limitBytes; int limit, limitBytes;
int matchIndex; int matchIndex;
Optional<TagSet> tags; Optional<TagSet> tags;
Optional<RangeReadOptions> options; Optional<ReadOptions> options;
ReplyPromise<GetMappedKeyValuesReply> reply; ReplyPromise<GetMappedKeyValuesReply> reply;
VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known
// to this client, of all storage replicas that // to this client, of all storage replicas that
@ -518,7 +518,7 @@ struct GetKeyValuesStreamRequest {
Version version; // or latestVersion Version version; // or latestVersion
int limit, limitBytes; int limit, limitBytes;
Optional<TagSet> tags; Optional<TagSet> tags;
Optional<RangeReadOptions> options; Optional<ReadOptions> options;
ReplyPromiseStream<GetKeyValuesStreamReply> reply; ReplyPromiseStream<GetKeyValuesStreamReply> reply;
VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known VersionVector ssLatestCommitVersions; // includes the latest commit versions, as known
// to this client, of all storage replicas that // to this client, of all storage replicas that

View File

@ -73,7 +73,7 @@ struct KeyValueStoreCompressTestData final : IKeyValueStore {
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) override { Optional<ReadOptions> options = Optional<ReadOptions>()) override {
return doReadRange(store, keys, rowLimit, byteLimit, options); return doReadRange(store, keys, rowLimit, byteLimit, options);
} }
@ -102,7 +102,7 @@ private:
KeyRangeRef keys, KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) { Optional<ReadOptions> options) {
RangeResult _vs = wait(store->readRange(keys, rowLimit, byteLimit, options)); RangeResult _vs = wait(store->readRange(keys, rowLimit, byteLimit, options));
RangeResult vs = _vs; // Get rid of implicit const& from wait statement RangeResult vs = _vs; // Get rid of implicit const& from wait statement
Arena& a = vs.arena(); Arena& a = vs.arena();

View File

@ -232,7 +232,7 @@ public:
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) override { Optional<ReadOptions> options) override {
if (recovering.isError()) if (recovering.isError())
throw recovering.getError(); throw recovering.getError();
if (!recovering.isReady()) if (!recovering.isReady())
@ -943,7 +943,7 @@ private:
KeyRange keys, KeyRange keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) { Optional<ReadOptions> options) {
wait(self->recovering); wait(self->recovering);
return static_cast<IKeyValueStore*>(self)->readRange(keys, rowLimit, byteLimit, options).get(); return static_cast<IKeyValueStore*>(self)->readRange(keys, rowLimit, byteLimit, options).get();
} }

View File

@ -1951,7 +1951,7 @@ struct RocksDBKeyValueStore : IKeyValueStore {
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) override { Optional<ReadOptions> options) override {
ReadType type = ReadType::NORMAL; ReadType type = ReadType::NORMAL;
if (options.present()) { if (options.present()) {

View File

@ -1594,7 +1594,7 @@ public:
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) override; Optional<ReadOptions> options) override;
KeyValueStoreSQLite(std::string const& filename, KeyValueStoreSQLite(std::string const& filename,
UID logID, UID logID,
@ -2241,7 +2241,7 @@ Future<Optional<Value>> KeyValueStoreSQLite::readValuePrefix(KeyRef key, int max
Future<RangeResult> KeyValueStoreSQLite::readRange(KeyRangeRef keys, Future<RangeResult> KeyValueStoreSQLite::readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) { Optional<ReadOptions> options) {
++readsRequested; ++readsRequested;
auto p = new Reader::ReadRangeAction(keys, rowLimit, byteLimit); auto p = new Reader::ReadRangeAction(keys, rowLimit, byteLimit);
auto f = p->result.getFuture(); auto f = p->result.getFuture();

View File

@ -2398,7 +2398,7 @@ struct ShardedRocksDBKeyValueStore : IKeyValueStore {
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) override { Optional<ReadOptions> options = Optional<ReadOptions>()) override {
TraceEvent(SevVerbose, "ShardedRocksReadRangeBegin", this->id).detail("Range", keys); TraceEvent(SevVerbose, "ShardedRocksReadRangeBegin", this->id).detail("Range", keys);
auto shards = shardManager.getDataShardsByRange(keys); auto shards = shardManager.getDataShardsByRange(keys);

View File

@ -18,6 +18,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include "fdbclient/FDBTypes.h"
#include "fdbserver/OTELSpanContextMessage.h" #include "fdbserver/OTELSpanContextMessage.h"
#include "flow/Arena.h" #include "flow/Arena.h"
#include "fdbclient/FDBOptions.g.h" #include "fdbclient/FDBOptions.g.h"
@ -42,6 +43,8 @@
#include "flow/Trace.h" #include "flow/Trace.h"
#include "flow/actorcompiler.h" // This must be the last #include. #include "flow/actorcompiler.h" // This must be the last #include.
FDB_DEFINE_BOOLEAN_PARAM(CacheResult);
// TODO storageCache server shares quite a bit of storageServer functionality, although simplified // TODO storageCache server shares quite a bit of storageServer functionality, although simplified
// Need to look into refactoring common code out for better code readability and to avoid duplication // Need to look into refactoring common code out for better code readability and to avoid duplication
@ -1187,6 +1190,7 @@ ACTOR Future<RangeResult> tryFetchRange(Database cx,
state RangeResult output; state RangeResult output;
state KeySelectorRef begin = firstGreaterOrEqual(keys.begin); state KeySelectorRef begin = firstGreaterOrEqual(keys.begin);
state KeySelectorRef end = firstGreaterOrEqual(keys.end); state KeySelectorRef end = firstGreaterOrEqual(keys.end);
state ReadOptions options = ReadOptions(Optional<UID>(), ReadType::FETCH);
if (*isTooOld) if (*isTooOld)
throw transaction_too_old(); throw transaction_too_old();
@ -1194,8 +1198,7 @@ ACTOR Future<RangeResult> tryFetchRange(Database cx,
ASSERT(!cx->switchable); ASSERT(!cx->switchable);
tr.setVersion(version); tr.setVersion(version);
tr.trState->taskID = TaskPriority::FetchKeys; tr.trState->taskID = TaskPriority::FetchKeys;
tr.trState->readOptions.type = ReadType::FETCH; tr.trState->readOptions = options;
tr.trState->readOptions.cacheResult = false;
limits.minRows = 0; limits.minRows = 0;
try { try {

View File

@ -7798,7 +7798,7 @@ public:
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) override { Optional<ReadOptions> options) override {
debug_printf("READRANGE %s\n", printable(keys).c_str()); debug_printf("READRANGE %s\n", printable(keys).c_str());
return catchError(readRange_impl(this, keys, rowLimit, byteLimit, options)); return catchError(readRange_impl(this, keys, rowLimit, byteLimit, options));
} }
@ -7807,18 +7807,14 @@ public:
KeyRange keys, KeyRange keys,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options) { Optional<ReadOptions> options) {
state PagerEventReasons reason = PagerEventReasons::RangeRead; state PagerEventReasons reason = PagerEventReasons::RangeRead;
state VersionedBTree::BTreeCursor cur; state VersionedBTree::BTreeCursor cur;
if (options.present()) { if (options.present() && options.get().type == ReadType::FETCH) {
state ReadOptions rOptions = options.get(); reason = PagerEventReasons::FetchRange;
if (options.get().type == ReadType::FETCH) {
reason = PagerEventReasons::FetchRange;
}
wait(self->m_tree->initBTreeCursor(&cur, self->m_tree->getLastCommittedVersion(), reason, rOptions));
} else {
wait(self->m_tree->initBTreeCursor(&cur, self->m_tree->getLastCommittedVersion(), reason));
} }
wait(self->m_tree->initBTreeCursor(&cur, self->m_tree->getLastCommittedVersion(), reason, options));
state PriorityMultiLock::Lock lock; state PriorityMultiLock::Lock lock;
state Future<Void> f; state Future<Void> f;
++g_redwoodMetrics.metric.opGetRange; ++g_redwoodMetrics.metric.opGetRange;
@ -11007,7 +11003,7 @@ ACTOR Future<Void> randomRangeScans(IKeyValueStore* kvs,
bool singlePrefix, bool singlePrefix,
int rowLimit, int rowLimit,
int byteLimit, int byteLimit,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) { Optional<ReadOptions> options = Optional<ReadOptions>()) {
fmt::print("\nstoreType: {}\n", static_cast<int>(kvs->getType())); fmt::print("\nstoreType: {}\n", static_cast<int>(kvs->getType()));
fmt::print("prefixSource: {}\n", source.toString()); fmt::print("prefixSource: {}\n", source.toString());
fmt::print("suffixSize: {}\n", suffixSize); fmt::print("suffixSize: {}\n", suffixSize);

View File

@ -82,7 +82,7 @@ public:
virtual Future<RangeResult> readRange(KeyRangeRef keys, virtual Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit = 1 << 30, int rowLimit = 1 << 30,
int byteLimit = 1 << 30, int byteLimit = 1 << 30,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) = 0; Optional<ReadOptions> options = Optional<ReadOptions>()) = 0;
// Shard management APIs. // Shard management APIs.
// Adds key range to a physical shard. // Adds key range to a physical shard.

View File

@ -244,7 +244,7 @@ struct IKVSReadRangeRequest {
KeyRangeRef keys; KeyRangeRef keys;
int rowLimit; int rowLimit;
int byteLimit; int byteLimit;
Optional<RangeReadOptions> options; Optional<ReadOptions> options;
ReplyPromise<IKVSReadRangeReply> reply; ReplyPromise<IKVSReadRangeReply> reply;
template <class Ar> template <class Ar>
@ -414,7 +414,7 @@ struct RemoteIKeyValueStore : public IKeyValueStore {
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit = 1 << 30, int rowLimit = 1 << 30,
int byteLimit = 1 << 30, int byteLimit = 1 << 30,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) override { Optional<ReadOptions> options = Optional<ReadOptions>()) override {
IKVSReadRangeRequest req{ keys, rowLimit, byteLimit, options, ReplyPromise<IKVSReadRangeReply>() }; IKVSReadRangeRequest req{ keys, rowLimit, byteLimit, options, ReplyPromise<IKVSReadRangeReply>() };
return fmap([](const IKVSReadRangeReply& reply) { return reply.toRangeResult(); }, return fmap([](const IKVSReadRangeReply& reply) { return reply.toRangeResult(); },
interf.readRange.getReply(req)); interf.readRange.getReply(req));

View File

@ -399,7 +399,7 @@ struct StorageServerDisk {
// - "a", if key "a" exist // - "a", if key "a" exist
// - "b", if key "a" doesn't exist, and "b" is the next existing key in total order // - "b", if key "a" doesn't exist, and "b" is the next existing key in total order
// - allKeys.end, if keyrange [a, allKeys.end) is empty // - allKeys.end, if keyrange [a, allKeys.end) is empty
Future<Key> readNextKeyInclusive(KeyRef key, Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) { Future<Key> readNextKeyInclusive(KeyRef key, Optional<ReadOptions> options = Optional<ReadOptions>()) {
++(*kvScans); ++(*kvScans);
return readFirstKey(storage, KeyRangeRef(key, allKeys.end), options); return readFirstKey(storage, KeyRangeRef(key, allKeys.end), options);
} }
@ -416,7 +416,7 @@ struct StorageServerDisk {
Future<RangeResult> readRange(KeyRangeRef keys, Future<RangeResult> readRange(KeyRangeRef keys,
int rowLimit = 1 << 30, int rowLimit = 1 << 30,
int byteLimit = 1 << 30, int byteLimit = 1 << 30,
Optional<RangeReadOptions> options = Optional<RangeReadOptions>()) { Optional<ReadOptions> options = Optional<ReadOptions>()) {
++(*kvScans); ++(*kvScans);
return storage->readRange(keys, rowLimit, byteLimit, options); return storage->readRange(keys, rowLimit, byteLimit, options);
} }
@ -445,9 +445,7 @@ private:
IKeyValueStore* storage; IKeyValueStore* storage;
void writeMutations(const VectorRef<MutationRef>& mutations, Version debugVersion, const char* debugContext); void writeMutations(const VectorRef<MutationRef>& mutations, Version debugVersion, const char* debugContext);
ACTOR static Future<Key> readFirstKey(IKeyValueStore* storage, ACTOR static Future<Key> readFirstKey(IKeyValueStore* storage, KeyRangeRef range, Optional<ReadOptions> options) {
KeyRangeRef range,
Optional<RangeReadOptions> options) {
RangeResult r = wait(storage->readRange(range, 1, 1 << 30, options)); RangeResult r = wait(storage->readRange(range, 1, 1 << 30, options));
if (r.size()) if (r.size())
return r[0].key; return r[0].key;
@ -2495,7 +2493,7 @@ ACTOR Future<std::pair<ChangeFeedStreamReply, bool>> getChangeFeedMutations(Stor
state Version startVersion = data->version.get(); state Version startVersion = data->version.get();
// TODO: Change feed reads should probably at least set cacheResult to false, possibly set a different ReadType as // TODO: Change feed reads should probably at least set cacheResult to false, possibly set a different ReadType as
// well, perhaps high priority? // well, perhaps high priority?
state RangeReadOptions options; state ReadOptions options;
if (DEBUG_CF_TRACE) { if (DEBUG_CF_TRACE) {
TraceEvent(SevDebug, "TraceChangeFeedMutationsBegin", data->thisServerID) TraceEvent(SevDebug, "TraceChangeFeedMutationsBegin", data->thisServerID)
@ -3234,7 +3232,7 @@ ACTOR Future<GetValueReqAndResultRef> quickGetValue(StorageServer* data,
state GetValueReqAndResultRef getValue; state GetValueReqAndResultRef getValue;
state double getValueStart = g_network->timer(); state double getValueStart = g_network->timer();
getValue.key = key; getValue.key = key;
state Optional<ReadOptions> options = pOriginalReq->options.castTo<ReadOptions>(); state Optional<ReadOptions> options = pOriginalReq->options;
if (data->shards[key]->isReadable()) { if (data->shards[key]->isReadable()) {
try { try {
@ -3291,7 +3289,7 @@ ACTOR Future<GetKeyValuesReply> readRange(StorageServer* data,
int limit, int limit,
int* pLimitBytes, int* pLimitBytes,
SpanContext parentSpan, SpanContext parentSpan,
Optional<RangeReadOptions> options, Optional<ReadOptions> options,
Optional<Key> tenantPrefix) { Optional<Key> tenantPrefix) {
state GetKeyValuesReply result; state GetKeyValuesReply result;
state StorageServer::VersionedData::ViewAtVersion view = data->data().at(version); state StorageServer::VersionedData::ViewAtVersion view = data->data().at(version);
@ -3532,7 +3530,7 @@ ACTOR Future<Key> findKey(StorageServer* data,
KeyRange range, KeyRange range,
int* pOffset, int* pOffset,
SpanContext parentSpan, SpanContext parentSpan,
Optional<RangeReadOptions> options) Optional<ReadOptions> options)
// Attempts to find the key indicated by sel in the data at version, within range. // Attempts to find the key indicated by sel in the data at version, within range.
// Precondition: selectorInRange(sel, range) // Precondition: selectorInRange(sel, range)
// If it is found, offset is set to 0 and a key is returned which falls inside range. // If it is found, offset is set to 0 and a key is returned which falls inside range.
@ -3670,7 +3668,7 @@ ACTOR Future<Void> getKeyValuesQ(StorageServer* data, GetKeyValuesRequest req)
{ {
state Span span("SS:getKeyValues"_loc, req.spanContext); state Span span("SS:getKeyValues"_loc, req.spanContext);
state int64_t resultSize = 0; state int64_t resultSize = 0;
state Optional<RangeReadOptions> options = req.options; state Optional<ReadOptions> options = req.options;
if (req.tenantInfo.name.present()) { if (req.tenantInfo.name.present()) {
span.addAttribute("tenant"_sr, req.tenantInfo.name.get()); span.addAttribute("tenant"_sr, req.tenantInfo.name.get());
@ -4417,7 +4415,7 @@ ACTOR Future<Void> getMappedKeyValuesQ(StorageServer* data, GetMappedKeyValuesRe
{ {
state Span span("SS:getMappedKeyValues"_loc, req.spanContext); state Span span("SS:getMappedKeyValues"_loc, req.spanContext);
state int64_t resultSize = 0; state int64_t resultSize = 0;
state Optional<RangeReadOptions> options = req.options; state Optional<ReadOptions> options = req.options;
if (req.tenantInfo.name.present()) { if (req.tenantInfo.name.present()) {
span.addAttribute("tenant"_sr, req.tenantInfo.name.get()); span.addAttribute("tenant"_sr, req.tenantInfo.name.get());
@ -4628,7 +4626,7 @@ ACTOR Future<Void> getKeyValuesStreamQ(StorageServer* data, GetKeyValuesStreamRe
{ {
state Span span("SS:getKeyValuesStream"_loc, req.spanContext); state Span span("SS:getKeyValuesStream"_loc, req.spanContext);
state int64_t resultSize = 0; state int64_t resultSize = 0;
state Optional<RangeReadOptions> options = req.options; state Optional<ReadOptions> options = req.options;
if (req.tenantInfo.name.present()) { if (req.tenantInfo.name.present()) {
span.addAttribute("tenant"_sr, req.tenantInfo.name.get()); span.addAttribute("tenant"_sr, req.tenantInfo.name.get());
@ -4843,7 +4841,7 @@ ACTOR Future<Void> getKeyQ(StorageServer* data, GetKeyRequest req) {
span.addAttribute("tenant"_sr, req.tenantInfo.name.get()); span.addAttribute("tenant"_sr, req.tenantInfo.name.get());
} }
state int64_t resultSize = 0; state int64_t resultSize = 0;
state RangeReadOptions options; state ReadOptions options;
if (req.options.present()) { if (req.options.present()) {
options = req.options.get(); options = req.options.get();
} }
@ -4878,7 +4876,7 @@ ACTOR Future<Void> getKeyQ(StorageServer* data, GetKeyRequest req) {
searchRange, searchRange,
&offset, &offset,
req.spanContext, req.spanContext,
req.options.present() ? options : Optional<RangeReadOptions>())); req.options.present() ? options : Optional<ReadOptions>()));
data->checkChangeCounter(changeCounter, data->checkChangeCounter(changeCounter,
KeyRangeRef(std::min<KeyRef>(req.sel.getKey(), absoluteKey), KeyRangeRef(std::min<KeyRef>(req.sel.getKey(), absoluteKey),
@ -4973,7 +4971,7 @@ void getQueuingMetrics(StorageServer* self, StorageQueuingMetricsRequest const&
ACTOR Future<Void> doEagerReads(StorageServer* data, UpdateEagerReadInfo* eager) { ACTOR Future<Void> doEagerReads(StorageServer* data, UpdateEagerReadInfo* eager) {
eager->finishKeyBegin(); eager->finishKeyBegin();
state RangeReadOptions options; state ReadOptions options;
options.type = ReadType::EAGER; options.type = ReadType::EAGER;
if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) { if (SERVER_KNOBS->ENABLE_CLEAR_RANGE_EAGER_READS) {
std::vector<Future<Key>> keyEnd(eager->keyBegin.size()); std::vector<Future<Key>> keyEnd(eager->keyBegin.size());
@ -6347,6 +6345,12 @@ ACTOR Future<Void> fetchKeys(StorageServer* data, AddingShard* shard) {
state int debug_nextRetryToLog = 1; state int debug_nextRetryToLog = 1;
state Error lastError; state Error lastError;
// TODO: update to FETCH once the priority multi lock is used.
// leaving the readtype off for now to prevent data fetches stall under heavy load
// it is used to inform the storage that the rangeRead is for Fetch
// state ReadOptions options = ReadOptions(Optional<UID>(), ReadType::FETCH);
state ReadOptions options = ReadOptions(Optional<UID>(), ReadType::NORMAL);
// FIXME: The client cache does not notice when servers are added to a team. To read from a local storage server // FIXME: The client cache does not notice when servers are added to a team. To read from a local storage server
// we must refresh the cache manually. // we must refresh the cache manually.
data->cx->invalidateCache(Key(), keys); data->cx->invalidateCache(Key(), keys);
@ -6401,12 +6405,7 @@ ACTOR Future<Void> fetchKeys(StorageServer* data, AddingShard* shard) {
shard->updates.pop_front(); shard->updates.pop_front();
tr.setVersion(fetchVersion); tr.setVersion(fetchVersion);
tr.trState->taskID = TaskPriority::FetchKeys; tr.trState->taskID = TaskPriority::FetchKeys;
// TODO: update to FETCH once the priority multi lock is used. tr.trState->readOptions = options;
// leaving the readtype off for now to prevent data fetches stall under heavy load
// it is used to inform the storage that the rangeRead is for Fetch
// tr.trState->readOptions.type = ReadType::FETCH;
tr.trState->readOptions.type = ReadType::NORMAL;
tr.trState->readOptions.cacheResult = false;
state PromiseStream<RangeResult> results; state PromiseStream<RangeResult> results;
state Future<Void> hold = SERVER_KNOBS->FETCH_USING_STREAMING state Future<Void> hold = SERVER_KNOBS->FETCH_USING_STREAMING
? tr.getRangeStream(results, keys, GetRangeLimits(), Snapshot::True) ? tr.getRangeStream(results, keys, GetRangeLimits(), Snapshot::True)