summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorMartin Bligh <mbligh@mongodb.com>2015-10-29 15:28:11 -0400
committerMartin Bligh <mbligh@mongodb.com>2015-10-30 12:35:35 -0400
commit965d98e5c5185f30edcbee810685ab0ab6810f8d (patch)
treeafb284703d310e8115925954a3a4efcba9253cc5 /src/mongo
parent2cc2d7da2be074f5a7d75c4c435a72b0303f7eaf (diff)
downloadmongo-965d98e5c5185f30edcbee810685ab0ab6810f8d.tar.gz
SERVER-21001: retry collection create on write conflict
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/commands/write_commands/batch_executor.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/mongo/db/commands/write_commands/batch_executor.cpp b/src/mongo/db/commands/write_commands/batch_executor.cpp
index 02adb946a29..251b8af52fe 100644
--- a/src/mongo/db/commands/write_commands/batch_executor.cpp
+++ b/src/mongo/db/commands/write_commands/batch_executor.cpp
@@ -960,16 +960,19 @@ bool WriteBatchExecutor::ExecInsertsState::_lockAndCheckImpl(WriteOpResult* resu
return _lockAndCheckImpl(result, false);
}
- WriteUnitOfWork wunit(txn);
- // Implicitly create if it doesn't exist
- _collection = _database->createCollection(txn, request->getTargetingNS());
- if (!_collection) {
- result->setError(
- toWriteError(Status(ErrorCodes::InternalError,
- "could not create collection " + request->getTargetingNS())));
- return false;
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ WriteUnitOfWork wunit(txn);
+ // Implicitly create if it doesn't exist
+ _collection = _database->createCollection(txn, request->getTargetingNS());
+ if (!_collection) {
+ result->setError(toWriteError(
+ Status(ErrorCodes::InternalError,
+ "could not create collection " + request->getTargetingNS())));
+ return false;
+ }
+ wunit.commit();
}
- wunit.commit();
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "createCollection", request->getTargetingNS());
}
return true;
}