summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/collection_bulk_loader_impl.cpp
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-09-20 01:22:56 -0400
committerScott Hernandez <scotthernandez@gmail.com>2016-09-26 17:25:44 -0400
commit56c9b8d8cc514de6c7a9342b8f47d5e06ead0d68 (patch)
tree8cc48aa72c0e6e65f922c87b43472b6304940984 /src/mongo/db/repl/collection_bulk_loader_impl.cpp
parentcededadafa62177d34fb960eec90d6d30f25f943 (diff)
downloadmongo-56c9b8d8cc514de6c7a9342b8f47d5e06ead0d68.tar.gz
SERVER-26179: Have CollectionBulkLoader::init use runner to execute work, not within runner task.
Diffstat (limited to 'src/mongo/db/repl/collection_bulk_loader_impl.cpp')
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp48
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,