summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp10
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.h2
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp13
3 files changed, 20 insertions, 5 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index 2e83e4389ce..cf31132e024 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -53,10 +53,12 @@ namespace repl {
CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
Collection* coll,
const BSONObj idIndexSpec,
+ std::unique_ptr<OldThreadPool> threadPool,
std::unique_ptr<TaskRunner> runner,
std::unique_ptr<AutoGetOrCreateDb> autoDb,
std::unique_ptr<AutoGetCollection> autoColl)
- : _runner(std::move(runner)),
+ : _threadPool(std::move(threadPool)),
+ _runner(std::move(runner)),
_autoColl(std::move(autoColl)),
_autoDB(std::move(autoDb)),
_txn(txn),
@@ -75,7 +77,11 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
}
CollectionBulkLoaderImpl::~CollectionBulkLoaderImpl() {
- DESTRUCTOR_GUARD(_runner->cancel();)
+ DESTRUCTOR_GUARD({
+ _runner->cancel();
+ _runner->join();
+ _threadPool->join();
+ })
}
Status CollectionBulkLoaderImpl::init(OperationContext* txn,
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.h b/src/mongo/db/repl/collection_bulk_loader_impl.h
index b0a4d45853b..1fa6033a104 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.h
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.h
@@ -64,6 +64,7 @@ public:
CollectionBulkLoaderImpl(OperationContext* txn,
Collection* coll,
const BSONObj idIndexSpec,
+ std::unique_ptr<OldThreadPool> threadPool,
std::unique_ptr<TaskRunner> runner,
std::unique_ptr<AutoGetOrCreateDb> autoDB,
std::unique_ptr<AutoGetCollection> autoColl);
@@ -83,6 +84,7 @@ public:
virtual BSONObj toBSON() const override;
private:
+ std::unique_ptr<OldThreadPool> _threadPool;
std::unique_ptr<TaskRunner> _runner;
std::unique_ptr<AutoGetCollection> _autoColl;
std::unique_ptr<AutoGetOrCreateDb> _autoDB;
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index fc829824a91..e7d410b978e 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -246,7 +246,9 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
const std::vector<BSONObj>& secondaryIndexSpecs) {
LOG(2) << "StorageInterfaceImpl::createCollectionForBulkLoading called for ns: " << nss.ns();
- std::unique_ptr<TaskRunner> runner = stdx::make_unique<TaskRunner>(_bulkLoaderThreads.get());
+ auto threadPool =
+ stdx::make_unique<OldThreadPool>(1, str::stream() << "InitialSyncInserters-" << nss.ns());
+ std::unique_ptr<TaskRunner> runner = stdx::make_unique<TaskRunner>(threadPool.get());
// Setup cond_var for signalling when done.
std::unique_ptr<CollectionBulkLoader> loaderToReturn;
@@ -276,8 +278,13 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
coll = stdx::make_unique<AutoGetCollection>(txn, nss, MODE_IX);
// Move locks into loader, so it now controls their lifetime.
- auto loader = stdx::make_unique<CollectionBulkLoaderImpl>(
- txn, collection, idIndexSpec, std::move(runner), std::move(db), std::move(coll));
+ auto loader = stdx::make_unique<CollectionBulkLoaderImpl>(txn,
+ collection,
+ idIndexSpec,
+ std::move(threadPool),
+ std::move(runner),
+ std::move(db),
+ std::move(coll));
invariant(collection);
auto status = loader->init(txn, collection, secondaryIndexSpecs);
if (!status.isOK()) {