cache the metadataVersion for commits, so that doing setVersion with the commit version of a different transaction will
This commit is contained in:
parent
075fdef31a
commit
988add9fb5
|
@ -71,14 +71,15 @@ struct MasterProxyInterface {
|
|||
struct CommitID {
|
||||
Version version; // returns invalidVersion if transaction conflicts
|
||||
uint16_t txnBatchId;
|
||||
Optional<Value> metadataVersion;
|
||||
|
||||
template <class Ar>
|
||||
void serialize(Ar& ar) {
|
||||
serializer(ar, version, txnBatchId);
|
||||
serializer(ar, version, txnBatchId, metadataVersion);
|
||||
}
|
||||
|
||||
CommitID() : version(invalidVersion), txnBatchId(0) {}
|
||||
CommitID( Version version, uint16_t txnBatchId ) : version(version), txnBatchId(txnBatchId) {}
|
||||
CommitID( Version version, uint16_t txnBatchId, const Optional<Value>& metadataVersion ) : version(version), txnBatchId(txnBatchId), metadataVersion(metadataVersion) {}
|
||||
};
|
||||
|
||||
struct CommitTransactionRequest : TimedRequest {
|
||||
|
|
|
@ -2528,6 +2528,10 @@ ACTOR static Future<Void> tryCommit( Database cx, Reference<TransactionLogInfo>
|
|||
if (info.debugID.present())
|
||||
TraceEvent(interval.end()).detail("CommittedVersion", v);
|
||||
*pCommittedVersion = v;
|
||||
if(v > cx->metadataVersionCache[cx->mvCacheInsertLocation].first) {
|
||||
cx->mvCacheInsertLocation = (cx->mvCacheInsertLocation + 1)%cx->metadataVersionCache.size();
|
||||
cx->metadataVersionCache[cx->mvCacheInsertLocation] = std::make_pair(v, ci.metadataVersion);
|
||||
}
|
||||
|
||||
Standalone<StringRef> ret = makeString(10);
|
||||
placeVersionstamp(mutateString(ret), v, ci.txnBatchId);
|
||||
|
|
|
@ -980,7 +980,7 @@ ACTOR Future<Void> commitBatch(
|
|||
for (int t = 0; t < trs.size(); t++) {
|
||||
if (committed[t] == ConflictBatch::TransactionCommitted && (!locked || trs[t].isLockAware())) {
|
||||
ASSERT_WE_THINK(commitVersion != invalidVersion);
|
||||
trs[t].reply.send(CommitID(commitVersion, t));
|
||||
trs[t].reply.send(CommitID(commitVersion, t, metadataVersionAfter));
|
||||
}
|
||||
else if (committed[t] == ConflictBatch::TransactionTooOld) {
|
||||
trs[t].reply.sendError(transaction_too_old());
|
||||
|
|
Loading…
Reference in New Issue