summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorRandolph Tan <randolph@10gen.com>2019-06-27 15:41:10 -0400
committerRandolph Tan <randolph@10gen.com>2019-07-17 11:43:27 -0400
commited935ffffae8dd373063da350e4cb61547e20688 (patch)
treefb277c512fddb87a44790cf34a0deaae0837dec0 /src/mongo/db
parent998640bbece98f31a92bba8c02785c818545ba84 (diff)
downloadmongo-ed935ffffae8dd373063da350e4cb61547e20688.tar.gz
SERVER-40785 Change sharding fixed and arbitrary executors from unique_ptr to shared_ptr
(cherry picked from commit d15b1f2e036e262f8ea976e04780aa366fa20ad4)
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/s/balancer/migration_manager.cpp6
-rw-r--r--src/mongo/db/s/collection_metadata_filtering_test.cpp2
-rw-r--r--src/mongo/db/s/metadata_manager_test.cpp2
-rw-r--r--src/mongo/db/s/migration_source_manager.cpp3
-rw-r--r--src/mongo/db/s/transaction_coordinator_futures_util.h5
5 files changed, 8 insertions, 10 deletions
diff --git a/src/mongo/db/s/balancer/migration_manager.cpp b/src/mongo/db/s/balancer/migration_manager.cpp
index 9c409334636..b131bbafde7 100644
--- a/src/mongo/db/s/balancer/migration_manager.cpp
+++ b/src/mongo/db/s/balancer/migration_manager.cpp
@@ -381,8 +381,7 @@ void MigrationManager::finishRecovery(OperationContext* opCtx,
}
void MigrationManager::interruptAndDisableMigrations() {
- executor::TaskExecutor* const executor =
- Grid::get(_serviceContext)->getExecutorPool()->getFixedExecutor();
+ auto executor = Grid::get(_serviceContext)->getExecutorPool()->getFixedExecutor();
stdx::lock_guard<stdx::mutex> lock(_mutex);
invariant(_state == State::kEnabled || _state == State::kRecovering);
@@ -479,8 +478,7 @@ void MigrationManager::_schedule(WithLock lock,
OperationContext* opCtx,
const HostAndPort& targetHost,
Migration migration) {
- executor::TaskExecutor* const executor =
- Grid::get(opCtx)->getExecutorPool()->getFixedExecutor();
+ auto executor = Grid::get(opCtx)->getExecutorPool()->getFixedExecutor();
const NamespaceString nss(migration.nss);
diff --git a/src/mongo/db/s/collection_metadata_filtering_test.cpp b/src/mongo/db/s/collection_metadata_filtering_test.cpp
index 6463636c22a..d125e651adc 100644
--- a/src/mongo/db/s/collection_metadata_filtering_test.cpp
+++ b/src/mongo/db/s/collection_metadata_filtering_test.cpp
@@ -44,7 +44,7 @@ class CollectionMetadataFilteringTest : public ShardServerTestFixture {
protected:
void setUp() override {
ShardServerTestFixture::setUp();
- _manager = std::make_shared<MetadataManager>(getServiceContext(), kNss, executor());
+ _manager = std::make_shared<MetadataManager>(getServiceContext(), kNss, executor().get());
}
/**
diff --git a/src/mongo/db/s/metadata_manager_test.cpp b/src/mongo/db/s/metadata_manager_test.cpp
index db701ec0a60..8563070c7cf 100644
--- a/src/mongo/db/s/metadata_manager_test.cpp
+++ b/src/mongo/db/s/metadata_manager_test.cpp
@@ -64,7 +64,7 @@ class MetadataManagerTest : public ShardServerTestFixture {
protected:
void setUp() override {
ShardServerTestFixture::setUp();
- _manager = std::make_shared<MetadataManager>(getServiceContext(), kNss, executor());
+ _manager = std::make_shared<MetadataManager>(getServiceContext(), kNss, executor().get());
}
/**
diff --git a/src/mongo/db/s/migration_source_manager.cpp b/src/mongo/db/s/migration_source_manager.cpp
index 74a3e7707fd..ab4d76a8952 100644
--- a/src/mongo/db/s/migration_source_manager.cpp
+++ b/src/mongo/db/s/migration_source_manager.cpp
@@ -108,8 +108,7 @@ void refreshRecipientRoutingTable(OperationContext* opCtx,
opCtx,
executor::RemoteCommandRequest::kNoTimeout);
- executor::TaskExecutor* const executor =
- Grid::get(opCtx)->getExecutorPool()->getFixedExecutor();
+ auto executor = Grid::get(opCtx)->getExecutorPool()->getFixedExecutor();
auto noOp = [](const executor::TaskExecutor::RemoteCommandCallbackArgs&) {};
executor->scheduleRemoteCommand(request, noOp).getStatus().ignore();
}
diff --git a/src/mongo/db/s/transaction_coordinator_futures_util.h b/src/mongo/db/s/transaction_coordinator_futures_util.h
index ee35d8e4db3..1c654d8707f 100644
--- a/src/mongo/db/s/transaction_coordinator_futures_util.h
+++ b/src/mongo/db/s/transaction_coordinator_futures_util.h
@@ -29,6 +29,7 @@
#pragma once
+#include <memory>
#include <vector>
#include "mongo/client/read_preference.h"
@@ -192,8 +193,8 @@ private:
// Service context under which this executor runs
ServiceContext* const _serviceContext;
- // Cached reference to the executor to use
- executor::TaskExecutor* const _executor;
+ // Executor for performing async tasks.
+ std::shared_ptr<executor::TaskExecutor> _executor;
// If this work scheduler was constructed through 'makeChildScheduler', points to the parent
// scheduler and contains the iterator from the parent, which needs to be removed on destruction