diff options
Diffstat (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp')
-rw-r--r-- | src/mongo/db/repl/collection_bulk_loader_impl.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp index 8bc7a20efdc..5fdb64218b9 100644 --- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp +++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp @@ -86,31 +86,33 @@ CollectionBulkLoaderImpl::~CollectionBulkLoaderImpl() { }) } -Status CollectionBulkLoaderImpl::init(OperationContext* txn, - Collection* coll, +Status CollectionBulkLoaderImpl::init(Collection* coll, const std::vector<BSONObj>& secondaryIndexSpecs) { - invariant(txn); - invariant(coll); - invariant(txn->getClient() == &cc()); - if (secondaryIndexSpecs.size()) { - _secondaryIndexesBlock->ignoreUniqueConstraint(); - auto status = _secondaryIndexesBlock->init(secondaryIndexSpecs).getStatus(); - if (!status.isOK()) { - return status; - } - } else { - _secondaryIndexesBlock.reset(); - } - if (!_idIndexSpec.isEmpty()) { - auto status = _idIndexBlock->init(_idIndexSpec).getStatus(); - if (!status.isOK()) { - return status; - } - } else { - _idIndexBlock.reset(); - } + return _runTaskReleaseResourcesOnFailure( + [coll, &secondaryIndexSpecs, this](OperationContext* txn) -> Status { + invariant(txn); + invariant(coll); + invariant(txn->getClient() == &cc()); + if (secondaryIndexSpecs.size()) { + _secondaryIndexesBlock->ignoreUniqueConstraint(); + auto status = _secondaryIndexesBlock->init(secondaryIndexSpecs).getStatus(); + if (!status.isOK()) { + return status; + } + } else { + _secondaryIndexesBlock.reset(); + } + if (!_idIndexSpec.isEmpty()) { + auto status = _idIndexBlock->init(_idIndexSpec).getStatus(); + if (!status.isOK()) { + return status; + } + } else { + _idIndexBlock.reset(); + } - return Status::OK(); + return Status::OK(); + }); } Status CollectionBulkLoaderImpl::insertDocuments(const std::vector<BSONObj>::const_iterator begin, |