summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Milkie <milkie@10gen.com>2015-01-22 16:14:52 -0500
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-01-23 12:01:09 -0500
commit6fa02fef6668a84147224363c3818ad96c3ea8dc (patch)
treeff6b978440fcbd8d70e48c22b9360a5a4002faf1
parentf8267b26894866eb9dc527445c7632a912d7816d (diff)
downloadmongo-6fa02fef6668a84147224363c3818ad96c3ea8dc.tar.gz
SERVER-17003 Check command status for WriteConflictException on secondaries and rethrow
(cherry picked from commit d96cd52a4818329f8e7199707a4574c04ba7ba58)
-rw-r--r--src/mongo/db/repl/oplog.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index dfb724dbdaa..7ad766bfd6b 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -737,16 +737,21 @@ namespace {
bool done = false;
while (!done) {
BufBuilder bb;
- BSONObjBuilder ob;
+ BSONObjBuilder runCommandResult;
// Applying commands in repl is done under Global W-lock, so it is safe to not
// perform the current DB checks after reacquiring the lock.
invariant(txn->lockState()->isW());
- _runCommands(txn, ns, o, bb, ob, true, 0);
+ _runCommands(txn, ns, o, bb, runCommandResult, true, 0);
// _runCommands takes care of adjusting opcounters for command counting.
- Status status = Command::getStatusFromCommandResult(ob.done());
+ Status status = Command::getStatusFromCommandResult(runCommandResult.done());
switch (status.code()) {
+ case ErrorCodes::WriteConflict: {
+ // Need to throw this up to a higher level where it will be caught and the
+ // operation retried.
+ throw WriteConflictException();
+ }
case ErrorCodes::BackgroundOperationInProgressForDatabase: {
Lock::TempRelease release(txn->lockState());