summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/collection_bulk_loader_impl.cpp
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-07-07 09:48:23 -0400
committerScott Hernandez <scotthernandez@gmail.com>2016-07-07 11:42:40 -0400
commit4fcd7f8b1db3551c00ed66d80dcd90965ef2677e (patch)
tree5d97242cd9327befeca695f42b4ab4af07eeaf94 /src/mongo/db/repl/collection_bulk_loader_impl.cpp
parent85ffab42cbda31a14e9900738c6462c231dab5a0 (diff)
downloadmongo-4fcd7f8b1db3551c00ed66d80dcd90965ef2677e.tar.gz
SERVER-24938: pass all MultiIndexBlocks when inserting documents
Diffstat (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp')
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index 9cc6fa5f7f0..090dce3c461 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -89,7 +89,6 @@ Status CollectionBulkLoaderImpl::init(OperationContext* txn,
invariant(txn);
invariant(coll);
invariant(txn->getClient() == &cc());
- _callAbortOnDestructor = true;
if (secondaryIndexSpecs.size()) {
_hasSecondaryIndexes = true;
_secondaryIndexesBlock.ignoreUniqueConstraint();
@@ -115,6 +114,9 @@ Status CollectionBulkLoaderImpl::insertDocuments(const std::vector<BSONObj>::con
for (auto iter = begin; iter != end; ++iter) {
std::vector<MultiIndexBlock*> indexers{&_idIndexBlock};
+ if (_hasSecondaryIndexes) {
+ indexers.push_back(&_secondaryIndexesBlock);
+ }
MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
WriteUnitOfWork wunit(txn);
const auto status = _coll->insertDocument(txn, *iter, indexers, false);
@@ -150,9 +152,13 @@ Status CollectionBulkLoaderImpl::commit() {
return Status{ErrorCodes::UserDataInconsistent,
"Found duplicates when dups are disabled in MultiIndexBlock."};
}
- WriteUnitOfWork wunit(txn);
- _secondaryIndexesBlock.commit();
- wunit.commit();
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ WriteUnitOfWork wunit(txn);
+ _secondaryIndexesBlock.commit();
+ wunit.commit();
+ }
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
+ _txn, "CollectionBulkLoaderImpl::commit", _nss.ns());
}
// Delete dups.
@@ -178,15 +184,18 @@ Status CollectionBulkLoaderImpl::commit() {
}
// Commit _id index, without dups.
- WriteUnitOfWork wunit(txn);
- _idIndexBlock.commit();
- wunit.commit();
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ WriteUnitOfWork wunit(txn);
+ _idIndexBlock.commit();
+ wunit.commit();
+ }
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(
+ _txn, "CollectionBulkLoaderImpl::commit", _nss.ns());
// release locks.
_autoColl.reset(nullptr);
_autoDB.reset(nullptr);
_coll = nullptr;
- _callAbortOnDestructor = false;
return Status::OK();
},
TaskRunner::NextAction::kDisposeOperationContext);