summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2018-02-22 17:46:42 -0500
committerSiyuan Zhou <siyuan.zhou@mongodb.com>2018-02-26 16:40:44 -0500
commit84da063a67fee56e7e088891dc170fd8dee4147e (patch)
tree914ed07780d9926c4bc7109ab55131b426d20363 /src/mongo
parentbec56c498da245a2ea16b30c03a5f3cd240d4e26 (diff)
downloadmongo-84da063a67fee56e7e088891dc170fd8dee4147e.tar.gz
SERVER-33477 Always use upsert with _id for session update.
Transactions stash the writes so the in-memory state of transaction table is out of sync during transaction. Two threads (write and chunk migration) will not update the same session entry due to the WCE generated by storage engine.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/session.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 8b358ed1901..f1773c3a682 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -600,18 +600,8 @@ UpdateRequest Session::_makeUpdateRequest(WithLock,
return newTxnRecord.toBSON();
}();
updateRequest.setUpdates(updateBSON);
-
- if (_lastWrittenSessionRecord) {
- updateRequest.setQuery(BSON(SessionTxnRecord::kSessionIdFieldName
- << _sessionId.toBSON()
- << SessionTxnRecord::kTxnNumFieldName
- << _lastWrittenSessionRecord->getTxnNum()
- << SessionTxnRecord::kLastWriteOpTimeFieldName
- << _lastWrittenSessionRecord->getLastWriteOpTime()));
- } else {
- updateRequest.setQuery(updateBSON);
- updateRequest.setUpsert(true);
- }
+ updateRequest.setQuery(BSON(SessionTxnRecord::kSessionIdFieldName << _sessionId.toBSON()));
+ updateRequest.setUpsert(true);
return updateRequest;
}