diff options
author | Alex Taskov <alex.taskov@mongodb.com> | 2020-04-01 13:26:24 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-01 17:40:41 +0000 |
commit | 2a89894a26de04beadd39b5f0e0ab98b98d1d62a (patch) | |
tree | c8ddda6e05be7b002edd1bf2b24a5069655bb2be /src/mongo/db/s/migration_util.cpp | |
parent | ddae8556a14561664efc7cfc583e25456fc08c16 (diff) | |
download | mongo-2a89894a26de04beadd39b5f0e0ab98b98d1d62a.tar.gz |
SERVER-47038 Some RangeDeletion unit tests don't correctly wait for threads to join
Diffstat (limited to 'src/mongo/db/s/migration_util.cpp')
-rw-r--r-- | src/mongo/db/s/migration_util.cpp | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/mongo/db/s/migration_util.cpp b/src/mongo/db/s/migration_util.cpp index c545860f503..791f5cda079 100644 --- a/src/mongo/db/s/migration_util.cpp +++ b/src/mongo/db/s/migration_util.cpp @@ -124,26 +124,6 @@ void sendToRecipient(OperationContext* opCtx, uassertStatusOK(Shard::CommandResponse::getEffectiveStatus(response)); } -// Returns an executor to be used to run commands related to submitting tasks to the range deleter. -// The executor is initialized on the first call to this function. Uses a shared_ptr -// because a shared_ptr is required to work with ExecutorFutures. -static std::shared_ptr<ThreadPool> getMigrationUtilExecutor() { - static Mutex mutex = MONGO_MAKE_LATCH("MigrationUtilExecutor::_mutex"); - static std::shared_ptr<ThreadPool> executor; - - stdx::lock_guard<Latch> lg(mutex); - if (!executor) { - ThreadPool::Options options; - options.poolName = "MoveChunk"; - options.minThreads = 0; - options.maxThreads = 16; - executor = std::make_shared<ThreadPool>(std::move(options)); - executor->startup(); - } - - return executor; -} - /** * Runs doWork until it doesn't throw an error, the node is shutting down, the node has stepped * down, or the node has stepped down and up. @@ -207,6 +187,23 @@ void retryIdempotentWorkAsPrimaryUntilSuccessOrStepdown( } // namespace +std::shared_ptr<ThreadPool> getMigrationUtilExecutor() { + static Mutex mutex = MONGO_MAKE_LATCH("MigrationUtilExecutor::_mutex"); + static std::shared_ptr<ThreadPool> executor; + + stdx::lock_guard<Latch> lg(mutex); + if (!executor) { + ThreadPool::Options options; + options.poolName = "MoveChunk"; + options.minThreads = 0; + options.maxThreads = 16; + executor = std::make_shared<ThreadPool>(std::move(options)); + executor->startup(); + } + + return executor; +} + BSONObj makeMigrationStatusDocument(const NamespaceString& nss, const ShardId& fromShard, const ShardId& toShard, |