summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2018-05-25 08:17:09 -0400
committerEric Milkie <milkie@10gen.com>2018-05-29 13:59:46 -0400
commit327d3efeda9837bad91e8920a8b35e9bb31c7598 (patch)
tree006a95458dbe929f97d15d0b25d1acbd709c9839
parent77edc98788e5ca37b933c180e405309c39ce2d77 (diff)
downloadmongo-327d3efeda9837bad91e8920a8b35e9bb31c7598.tar.gz
SERVER-34919 do not retry vector insert on write conflict exception, for read concern snapshot
(cherry picked from commit 3312ff09502ceb92d93f65f92d4e823df993a927)
-rw-r--r--src/mongo/db/ops/write_ops_exec.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/ops/write_ops_exec.cpp b/src/mongo/db/ops/write_ops_exec.cpp
index f5e325861ba..2ca80f617a2 100644
--- a/src/mongo/db/ops/write_ops_exec.cpp
+++ b/src/mongo/db/ops/write_ops_exec.cpp
@@ -422,10 +422,16 @@ bool insertBatchAndHandleErrors(OperationContext* opCtx,
return true;
}
} catch (const DBException&) {
- collection.reset();
- // Ignore this failure and behave as-if we never tried to do the combined batch insert.
- // The loop below will handle reporting any non-transient errors.
+ // If we cannot abandon the current snapshot, we give up and rethrow the exception.
+ // No WCE retrying is attempted. This code path is intended for snapshot read concern.
+ if (opCtx->lockState()->inAWriteUnitOfWork()) {
+ throw;
+ }
+
+ // Otherwise, ignore this failure and behave as-if we never tried to do the combined batch
+ // insert. The loop below will handle reporting any non-transient errors.
+ collection.reset();
}
// Try to insert the batch one-at-a-time. This path is executed both for singular batches, and