MCPcopy Create free account
hub / github.com/apple/foundationdb / getLatestCommitVersions

Method getLatestCommitVersions

fdbclient/NativeAPI.actor.cpp:228–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void DatabaseContext::getLatestCommitVersions(const Reference<LocationInfo>& locationInfo,
229 Version readVersion,
230 Reference<TransactionState> info,
231 VersionVector& latestCommitVersions) {
232 latestCommitVersions.clear();
233
234 if (info->debugID.present()) {
235 g_traceBatch.addEvent("TransactionDebug", info->debugID.get().first(), "NativeAPI.getLatestCommitVersions");
236 }
237
238 if (!info->readVersionObtainedFromGrvProxy) {
239 return;
240 }
241
242 if (ssVersionVectorCache.getMaxVersion() == invalidVersion) {
243 return;
244 }
245
246 if (readVersion > ssVersionVectorCache.getMaxVersion()) {
247 if (!CLIENT_KNOBS->FORCE_GRV_CACHE_OFF && !info->options.skipGrvCache && info->options.useGrvCache) {
248 return;
249 } else {
250 TraceEvent(SevError, "GetLatestCommitVersions")
251 .detail("ReadVersion", readVersion)
252 .detail("VersionVector", ssVersionVectorCache.toString());
253 ASSERT(false);
254 }
255 }
256
257 std::map<Version, std::set<Tag>> versionMap; // order the versions to be returned
258 for (int i = 0; i < locationInfo->locations()->size(); i++) {
259 bool updatedVersionMap = false;
260 Version commitVersion = invalidVersion;
261 Tag tag = invalidTag;
262 auto iter = ssidTagMapping.find(locationInfo->locations()->getId(i));
263 if (iter != ssidTagMapping.end()) {
264 tag = iter->second;
265 if (ssVersionVectorCache.hasVersion(tag)) {
266 commitVersion = ssVersionVectorCache.getVersion(tag); // latest commit version
267 if (commitVersion < readVersion) {
268 updatedVersionMap = true;
269 versionMap[commitVersion].insert(tag);
270 }
271 }
272 }
273 // commitVersion == readVersion is common, do not log.
274 if (!updatedVersionMap && commitVersion != readVersion) {
275 TraceEvent(SevDebug, "CommitVersionNotFoundForSS")
276 .detail("InSSIDMap", iter != ssidTagMapping.end() ? 1 : 0)
277 .detail("Tag", tag)
278 .detail("CommitVersion", commitVersion)
279 .detail("ReadVersion", readVersion)
280 .detail("VersionVector", ssVersionVectorCache.toString())
281 .setMaxEventLength(11000)
282 .setMaxFieldLength(10000);
283 ++transactionCommitVersionNotFoundForSS;
284 }
285 }

Calls 15

TraceEventClass · 0.85
addEventMethod · 0.80
firstMethod · 0.80
detailMethod · 0.80
locationsMethod · 0.80
hasVersionMethod · 0.80
clearMethod · 0.65
getMethod · 0.65
presentMethod · 0.45
getMaxVersionMethod · 0.45
toStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected