| 226 | } |
| 227 | |
| 228 | void 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 | } |
no test coverage detected