diff options
author | Martin Bligh <mbligh@mongodb.com> | 2015-10-29 15:28:11 -0400 |
---|---|---|
committer | Martin Bligh <mbligh@mongodb.com> | 2015-10-30 12:35:35 -0400 |
commit | 965d98e5c5185f30edcbee810685ab0ab6810f8d (patch) | |
tree | afb284703d310e8115925954a3a4efcba9253cc5 /src/mongo | |
parent | 2cc2d7da2be074f5a7d75c4c435a72b0303f7eaf (diff) | |
download | mongo-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.cpp | 21 |
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; } |