summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-07-24 12:06:52 -0400
committerBenety Goh <benety@mongodb.com>2017-07-26 17:57:23 -0400
commit026a71c19c3f4604e8bc134e74dede28f175c063 (patch)
tree894d5aba7389fb905ae0aba8f06f39c53557a04d /src/mongo
parent84a658596bc62107539a07556b9c066af2fec683 (diff)
downloadmongo-026a71c19c3f4604e8bc134e74dede28f175c063.tar.gz
SERVER-30049 applyOperation_inlock() allows exceptions from Collection::insertDocument() to percolate to caller
This specifically addresses the case where a WriteConflictException is thrown from insertDocument(). Converting this exception into a status will not allow the write conflict retry loops in callers to work properly. (cherry picked from commit f0d41183e735546c83ff96d7d5afc11b9c94cb9f)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/oplog.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 69bc38cd3e5..43a1eba5042 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -838,7 +838,6 @@ Status applyOperation_inlock(OperationContext* txn,
// 2. If okay, commit
// 3. If not, do upsert (and commit)
// 4. If both !Ok, return status
- Status status{ErrorCodes::NotYetInitialized, ""};
// We cannot rely on a DuplicateKey error if we'repart of a larger transaction, because
// that would require the transaction to abort. So instead, use upsert in that case.
@@ -846,12 +845,8 @@ Status applyOperation_inlock(OperationContext* txn,
if (!needToDoUpsert) {
WriteUnitOfWork wuow(txn);
- try {
- OpDebug* const nullOpDebug = nullptr;
- status = collection->insertDocument(txn, o, nullOpDebug, true);
- } catch (DBException dbe) {
- status = dbe.toStatus();
- }
+ OpDebug* const nullOpDebug = nullptr;
+ auto status = collection->insertDocument(txn, o, nullOpDebug, true);
if (status.isOK()) {
wuow.commit();
} else if (status == ErrorCodes::DuplicateKey) {