summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Hernandez <scotthernandez@gmail.com>2016-07-22 12:55:46 -0400
committerScott Hernandez <scotthernandez@gmail.com>2016-07-23 14:01:04 -0400
commit8ab78f2308cd5c26e00a9c7c5051ec58db6d1275 (patch)
tree4d3f10dafff737bcebafe24e13612215e488afba /src
parentc584d851c1cce95e81198e73f48234e3199fba5f (diff)
downloadmongo-8ab78f2308cd5c26e00a9c7c5051ec58db6d1275.tar.gz
SERVER-23476: move ownership of TaskRunner out of StorageInterfaceImpl
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.cpp6
-rw-r--r--src/mongo/db/repl/collection_bulk_loader_impl.h4
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp19
-rw-r--r--src/mongo/db/repl/storage_interface_impl.h7
4 files changed, 8 insertions, 28 deletions
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.cpp b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
index b568cf02c29..2e83e4389ce 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.cpp
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.cpp
@@ -51,12 +51,12 @@ namespace mongo {
namespace repl {
CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
- TaskRunner* runner,
Collection* coll,
const BSONObj idIndexSpec,
+ std::unique_ptr<TaskRunner> runner,
std::unique_ptr<AutoGetOrCreateDb> autoDb,
std::unique_ptr<AutoGetCollection> autoColl)
- : _runner(runner),
+ : _runner(std::move(runner)),
_autoColl(std::move(autoColl)),
_autoDB(std::move(autoDb)),
_txn(txn),
@@ -67,7 +67,7 @@ CollectionBulkLoaderImpl::CollectionBulkLoaderImpl(OperationContext* txn,
_idIndexSpec(idIndexSpec) {
invariant(txn);
invariant(coll);
- invariant(runner);
+ invariant(_runner);
invariant(_autoDB);
invariant(_autoColl);
invariant(_autoDB->getDb());
diff --git a/src/mongo/db/repl/collection_bulk_loader_impl.h b/src/mongo/db/repl/collection_bulk_loader_impl.h
index 0a53f77565e..b0a4d45853b 100644
--- a/src/mongo/db/repl/collection_bulk_loader_impl.h
+++ b/src/mongo/db/repl/collection_bulk_loader_impl.h
@@ -62,9 +62,9 @@ public:
};
CollectionBulkLoaderImpl(OperationContext* txn,
- TaskRunner* runner,
Collection* coll,
const BSONObj idIndexSpec,
+ std::unique_ptr<TaskRunner> runner,
std::unique_ptr<AutoGetOrCreateDb> autoDB,
std::unique_ptr<AutoGetCollection> autoColl);
virtual ~CollectionBulkLoaderImpl();
@@ -83,7 +83,7 @@ public:
virtual BSONObj toBSON() const override;
private:
- TaskRunner* _runner;
+ std::unique_ptr<TaskRunner> _runner;
std::unique_ptr<AutoGetCollection> _autoColl;
std::unique_ptr<AutoGetOrCreateDb> _autoDB;
OperationContext* _txn = nullptr;
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 4a7d63ccd31..fc829824a91 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -245,21 +245,8 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
const BSONObj idIndexSpec,
const std::vector<BSONObj>& secondaryIndexSpecs) {
- UniqueLock lk(_runnersMutex);
- // Check to make sure we don't already have a runner.
- for (auto&& item : _runners) {
- if (item.first == nss) {
- return {ErrorCodes::IllegalOperation,
- str::stream() << "There is already an active collection cloner for: "
- << nss.ns()};
- }
- }
- // Create the runner, and schedule the collection creation.
- _runners.emplace_back(
- std::make_pair(nss, stdx::make_unique<TaskRunner>(_bulkLoaderThreads.get())));
- auto&& inserter = _runners.back();
- TaskRunner* runner = inserter.second.get();
- lk.unlock();
+ LOG(2) << "StorageInterfaceImpl::createCollectionForBulkLoading called for ns: " << nss.ns();
+ std::unique_ptr<TaskRunner> runner = stdx::make_unique<TaskRunner>(_bulkLoaderThreads.get());
// Setup cond_var for signalling when done.
std::unique_ptr<CollectionBulkLoader> loaderToReturn;
@@ -290,7 +277,7 @@ StorageInterfaceImpl::createCollectionForBulkLoading(
// Move locks into loader, so it now controls their lifetime.
auto loader = stdx::make_unique<CollectionBulkLoaderImpl>(
- txn, runner, collection, idIndexSpec, std::move(db), std::move(coll));
+ txn, collection, idIndexSpec, std::move(runner), std::move(db), std::move(coll));
invariant(collection);
auto status = loader->init(txn, collection, secondaryIndexSpecs);
if (!status.isOK()) {
diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h
index a0c50838448..ff8a59b1ecd 100644
--- a/src/mongo/db/repl/storage_interface_impl.h
+++ b/src/mongo/db/repl/storage_interface_impl.h
@@ -120,13 +120,6 @@ private:
// One thread per collection/TaskRunner
std::unique_ptr<OldThreadPool> _bulkLoaderThreads;
const NamespaceString _minValidNss;
-
- // This mutex protects _runners vector.
- stdx::mutex _runnersMutex;
-
- // Each runner services a single collection and holds on to the OperationContext (and thread)
- // until it is done with the collection (CollectionBulkLoaderImpl::commit/abort is called).
- std::vector<std::pair<const NamespaceString, std::unique_ptr<TaskRunner>>> _runners;
};
} // namespace repl