Skip to content

Commit 558c5e4

Browse files
committed
cherry pick 7653 - Track when version not found in version vector.
1 parent 5891f8b commit 558c5e4

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

fdbclient/DatabaseContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ class DatabaseContext : public ReferenceCounted<DatabaseContext>, public FastAll
528528
Counter transactionsExpensiveClearCostEstCount;
529529
Counter transactionGrvFullBatches;
530530
Counter transactionGrvTimedOutBatches;
531+
Counter transactionCommitVersionNotFoundForSS;
531532

532533
ContinuousSample<double> latencies, readLatencies, commitLatencies, GRVLatencies, mutationsPerCommit,
533534
bytesPerCommit, bgLatencies, bgGranulesPerRequest;

fdbclient/NativeAPI.actor.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void DatabaseContext::getLatestCommitVersions(const Reference<LocationInfo>& loc
240240
return;
241241
}
242242

243-
if (ssVersionVectorCache.getMaxVersion() != invalidVersion && readVersion > ssVersionVectorCache.getMaxVersion()) {
243+
if (readVersion > ssVersionVectorCache.getMaxVersion()) {
244244
if (!CLIENT_KNOBS->FORCE_GRV_CACHE_OFF && !info->options.skipGrvCache && info->options.useGrvCache) {
245245
return;
246246
} else {
@@ -253,16 +253,29 @@ void DatabaseContext::getLatestCommitVersions(const Reference<LocationInfo>& loc
253253

254254
std::map<Version, std::set<Tag>> versionMap; // order the versions to be returned
255255
for (int i = 0; i < locationInfo->locations()->size(); i++) {
256-
UID uid = locationInfo->locations()->getId(i);
257-
if (ssidTagMapping.find(uid) != ssidTagMapping.end()) {
258-
Tag tag = ssidTagMapping[uid];
256+
bool updatedVersionMap = false;
257+
Version commitVersion = invalidVersion;
258+
Tag tag = invalidTag;
259+
auto iter = ssidTagMapping.find(locationInfo->locations()->getId(i));
260+
if (iter != ssidTagMapping.end()) {
261+
tag = iter->second;
259262
if (ssVersionVectorCache.hasVersion(tag)) {
260-
Version commitVersion = ssVersionVectorCache.getVersion(tag); // latest commit version
263+
commitVersion = ssVersionVectorCache.getVersion(tag); // latest commit version
261264
if (commitVersion < readVersion) {
265+
updatedVersionMap = true;
262266
versionMap[commitVersion].insert(tag);
263267
}
264268
}
265269
}
270+
if (!updatedVersionMap) {
271+
TraceEvent(SevDebug, "CommitVersionNotFoundForSS")
272+
.detail("InSSIDMap", iter != ssidTagMapping.end() ? 1 : 0)
273+
.detail("Tag", tag)
274+
.detail("CommitVersion", commitVersion)
275+
.detail("ReadVersion", readVersion)
276+
.detail("VersionVector", ssVersionVectorCache.toString());
277+
++transactionCommitVersionNotFoundForSS;
278+
}
266279
}
267280

268281
// insert the commit versions in the version vector.
@@ -1445,13 +1458,13 @@ DatabaseContext::DatabaseContext(Reference<AsyncVar<Reference<IClusterConnection
14451458
transactionsProcessBehind("ProcessBehind", cc), transactionsThrottled("Throttled", cc),
14461459
transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc),
14471460
transactionGrvFullBatches("NumGrvFullBatches", cc), transactionGrvTimedOutBatches("NumGrvTimedOutBatches", cc),
1448-
latencies(1000), readLatencies(1000), commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000),
1449-
bytesPerCommit(1000), bgLatencies(1000), bgGranulesPerRequest(1000), outstandingWatches(0), sharedStatePtr(nullptr),
1450-
lastGrvTime(0.0), cachedReadVersion(0), lastRkBatchThrottleTime(0.0), lastRkDefaultThrottleTime(0.0),
1451-
lastProxyRequestTime(0.0), transactionTracingSample(false), taskID(taskID), clientInfo(clientInfo),
1452-
clientInfoMonitor(clientInfoMonitor), coordinator(coordinator), apiVersion(apiVersion), mvCacheInsertLocation(0),
1453-
healthMetricsLastUpdated(0), detailedHealthMetricsLastUpdated(0),
1454-
smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT),
1461+
transactionCommitVersionNotFoundForSS("CommitVersionNotFoundForSS", cc), latencies(1000), readLatencies(1000),
1462+
commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), bgLatencies(1000),
1463+
bgGranulesPerRequest(1000), outstandingWatches(0), sharedStatePtr(nullptr), lastGrvTime(0.0), cachedReadVersion(0),
1464+
lastRkBatchThrottleTime(0.0), lastRkDefaultThrottleTime(0.0), lastProxyRequestTime(0.0),
1465+
transactionTracingSample(false), taskID(taskID), clientInfo(clientInfo), clientInfoMonitor(clientInfoMonitor),
1466+
coordinator(coordinator), apiVersion(apiVersion), mvCacheInsertLocation(0), healthMetricsLastUpdated(0),
1467+
detailedHealthMetricsLastUpdated(0), smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT),
14551468
specialKeySpace(std::make_unique<SpecialKeySpace>(specialKeys.begin, specialKeys.end, /* test */ false)),
14561469
connectToDatabaseEventCacheHolder(format("ConnectToDatabase/%s", dbId.toString().c_str())) {
14571470
dbId = deterministicRandom()->randomUniqueID();
@@ -1719,8 +1732,9 @@ DatabaseContext::DatabaseContext(const Error& err)
17191732
transactionsProcessBehind("ProcessBehind", cc), transactionsThrottled("Throttled", cc),
17201733
transactionsExpensiveClearCostEstCount("ExpensiveClearCostEstCount", cc),
17211734
transactionGrvFullBatches("NumGrvFullBatches", cc), transactionGrvTimedOutBatches("NumGrvTimedOutBatches", cc),
1722-
latencies(1000), readLatencies(1000), commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000),
1723-
bytesPerCommit(1000), bgLatencies(1000), bgGranulesPerRequest(1000), transactionTracingSample(false),
1735+
transactionCommitVersionNotFoundForSS("CommitVersionNotFoundForSS", cc), latencies(1000), readLatencies(1000),
1736+
commitLatencies(1000), GRVLatencies(1000), mutationsPerCommit(1000), bytesPerCommit(1000), bgLatencies(1000),
1737+
bgGranulesPerRequest(1000), transactionTracingSample(false),
17241738
smoothMidShardSize(CLIENT_KNOBS->SHARD_STAT_SMOOTH_AMOUNT),
17251739
connectToDatabaseEventCacheHolder(format("ConnectToDatabase/%s", dbId.toString().c_str())) {}
17261740

0 commit comments

Comments
 (0)