diff options
author | Benety Goh <benety@mongodb.com> | 2016-07-29 19:44:34 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2016-07-29 19:47:04 -0400 |
commit | e0bb47c1fc8e465687dccba684e6c705867a56f3 (patch) | |
tree | 230b02eb75e6a45fa50a027a4b45a83a66b24437 | |
parent | e0b51290e9046a26790c8ad2cc52118eb654a27f (diff) | |
download | mongo-e0bb47c1fc8e465687dccba684e6c705867a56f3.tar.gz |
Revert "SERVER-25084 removed unused StorageInterfaceImpl::_bulkLoaderThreads"
This reverts commit d305e618162d37ccc16cf574fcc0388a1160af93.
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 30 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.h | 5 |
2 files changed, 28 insertions, 7 deletions
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index dd75462f6f2..f2fe3bcf5e2 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -61,14 +61,13 @@ #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/replication_coordinator_global.h" #include "mongo/db/repl/rs_initialsync.h" -#include "mongo/db/repl/task_runner.h" +#include "mongo/db/server_parameters.h" #include "mongo/db/service_context.h" #include "mongo/util/assert_util.h" #include "mongo/util/concurrency/old_thread_pool.h" #include "mongo/util/destructor_guard.h" #include "mongo/util/log.h" #include "mongo/util/mongoutils/str.h" - namespace mongo { namespace repl { @@ -79,6 +78,8 @@ const char StorageInterfaceImpl::kBeginFieldName[] = "begin"; namespace { using UniqueLock = stdx::unique_lock<stdx::mutex>; +MONGO_EXPORT_STARTUP_SERVER_PARAMETER(dataReplicatorInitialSyncInserterThreads, int, 4); + const BSONObj kInitialSyncFlag(BSON(StorageInterfaceImpl::kInitialSyncFlagFieldName << true)); } // namespace @@ -92,9 +93,17 @@ StorageInterfaceImpl::~StorageInterfaceImpl() { DESTRUCTOR_GUARD(shutdown();); } -void StorageInterfaceImpl::startup(){}; +void StorageInterfaceImpl::startup() { + _bulkLoaderThreads.reset( + new OldThreadPool{dataReplicatorInitialSyncInserterThreads, "InitialSyncInserters-"}); +}; -void StorageInterfaceImpl::shutdown() {} +void StorageInterfaceImpl::shutdown() { + if (_bulkLoaderThreads) { + _bulkLoaderThreads->join(); + _bulkLoaderThreads.reset(); + } +} NamespaceString StorageInterfaceImpl::getMinValidNss() const { return _minValidNss; @@ -514,9 +523,16 @@ StatusWith<BSONObj> StorageInterfaceImpl::deleteOne(OperationContext* txn, Status StorageInterfaceImpl::isAdminDbValid(OperationContext* txn) { log() << "StorageInterfaceImpl::isAdminDbValid called."; - ScopedTransaction transaction(txn, MODE_IX); - AutoGetDb autoDB(txn, "admin", MODE_X); - return checkAdminDatabase(txn, autoDB.getDb()); + // TODO: plumb through operation context from caller, for now run on ioThread with runner. + TaskRunner runner(_bulkLoaderThreads.get()); + auto status = runner.runSynchronousTask( + [](OperationContext* txn) -> Status { + ScopedTransaction transaction(txn, MODE_IX); + AutoGetDb autoDB(txn, "admin", MODE_X); + return checkAdminDatabase(txn, autoDB.getDb()); + }, + TaskRunner::NextAction::kDisposeOperationContext); + return status; } } // namespace repl diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h index 0226c4705aa..7e45c77fae2 100644 --- a/src/mongo/db/repl/storage_interface_impl.h +++ b/src/mongo/db/repl/storage_interface_impl.h @@ -35,8 +35,11 @@ #include "mongo/base/string_data.h" #include "mongo/bson/bsonobj.h" #include "mongo/db/catalog/index_create.h" +#include "mongo/db/db_raii.h" #include "mongo/db/namespace_string.h" #include "mongo/db/repl/storage_interface.h" +#include "mongo/db/repl/task_runner.h" +#include "mongo/util/concurrency/old_thread_pool.h" namespace mongo { namespace repl { @@ -115,6 +118,8 @@ public: Status isAdminDbValid(OperationContext* txn) override; private: + // One thread per collection/TaskRunner + std::unique_ptr<OldThreadPool> _bulkLoaderThreads; const NamespaceString _minValidNss; }; |