summaryrefslogtreecommitdiff
path: root/src/mongo/db/session.cpp
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2017-08-31 16:44:55 -0400
committerRandolph Tan <randolph@10gen.com>2017-09-15 10:59:29 -0400
commitf89bcc57d5526c02e4be67ab2cbb3f5470ee3aa0 (patch)
tree554a2db48e0665e5b1f909d093eba8239f7b596a /src/mongo/db/session.cpp
parent1d4dd376cee7833959496af5aede4de6c23e39ed (diff)
downloadmongo-f89bcc57d5526c02e4be67ab2cbb3f5470ee3aa0.tar.gz
SERVER-30895 Implement infrastructure for retrieving session states from the source shard during migration
Diffstat (limited to 'src/mongo/db/session.cpp')
-rw-r--r--src/mongo/db/session.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/mongo/db/session.cpp b/src/mongo/db/session.cpp
index 2c217fb7d70..e58b2a5406d 100644
--- a/src/mongo/db/session.cpp
+++ b/src/mongo/db/session.cpp
@@ -60,10 +60,20 @@ void updateSessionEntry(OperationContext* opCtx, const UpdateRequest& updateRequ
<< " collection has been manually deleted.",
autoColl.getCollection());
- const auto updateResult = update(opCtx, autoColl.getDb(), updateRequest);
+ try {
+ const auto updateResult = update(opCtx, autoColl.getDb(), updateRequest);
- if (!updateResult.numDocsModified && updateResult.upserted.isEmpty()) {
- throw WriteConflictException();
+ if (!updateResult.numDocsModified && updateResult.upserted.isEmpty()) {
+ throw WriteConflictException();
+ }
+ } catch (const DBException& excep) {
+ if (excep.code() == ErrorCodes::DuplicateKey) {
+ // Duplicate key means that another thread already created the session this is trying
+ // to upsert. Throw WriteCoflict to make it retry and check the current state again.
+ throw WriteConflictException();
+ }
+
+ throw;
}
}