summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2020-09-30 15:21:04 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-30 22:01:57 +0000
commitd4a95bccc5f2e6e66cb13ae40a980706112f6524 (patch)
tree000dee21f948c60de2de1bdabdd31a9ff5a649bd
parent8ce04ebebe811c2b296c51b3ddb75d0201f458b6 (diff)
downloadmongo-d4a95bccc5f2e6e66cb13ae40a980706112f6524.tar.gz
SERVER-48254: Revert "SERVER-43442 Remove blocking call from AsyncWorkScheduler host targetting"
This reverts commit 0651f3c7b63130842e85d44fec624b82a33b67a3.
-rw-r--r--src/mongo/db/free_mon/free_mon_controller_test.cpp4
-rw-r--r--src/mongo/db/s/transaction_coordinator_futures_util.cpp12
-rw-r--r--src/mongo/util/future.h9
3 files changed, 7 insertions, 18 deletions
diff --git a/src/mongo/db/free_mon/free_mon_controller_test.cpp b/src/mongo/db/free_mon/free_mon_controller_test.cpp
index b594d09f6b2..908120f42f1 100644
--- a/src/mongo/db/free_mon/free_mon_controller_test.cpp
+++ b/src/mongo/db/free_mon/free_mon_controller_test.cpp
@@ -251,7 +251,7 @@ public:
auto pf = makePromiseFuture<FreeMonRegistrationResponse>();
if (_options.doSync) {
- pf.promise.setFromStatusWith(doRegister(req));
+ pf.promise.setFrom(doRegister(req));
} else {
auto swSchedule = _threadPool->scheduleWork(
[sharedPromise = std::move(pf.promise), req, this](
@@ -297,7 +297,7 @@ public:
auto pf = makePromiseFuture<FreeMonMetricsResponse>();
if (_options.doSync) {
- pf.promise.setFromStatusWith(doMetrics(req));
+ pf.promise.setFrom(doMetrics(req));
} else {
auto swSchedule = _threadPool->scheduleWork(
[sharedPromise = std::move(pf.promise), req, this](
diff --git a/src/mongo/db/s/transaction_coordinator_futures_util.cpp b/src/mongo/db/s/transaction_coordinator_futures_util.cpp
index 3b43c5a4486..e66eecbaf88 100644
--- a/src/mongo/db/s/transaction_coordinator_futures_util.cpp
+++ b/src/mongo/db/s/transaction_coordinator_futures_util.cpp
@@ -226,7 +226,7 @@ Future<AsyncWorkScheduler::HostAndShard> AsyncWorkScheduler::_targetHostAsync(
const ShardId& shardId,
const ReadPreferenceSetting& readPref,
OperationContextFn operationContextFn) {
- return scheduleWork([this, shardId, readPref, operationContextFn](OperationContext* opCtx) {
+ return scheduleWork([shardId, readPref, operationContextFn](OperationContext* opCtx) {
operationContextFn(opCtx);
const auto shardRegistry = Grid::get(opCtx)->shardRegistry();
const auto shard = uassertStatusOK(shardRegistry->getShard(opCtx, shardId));
@@ -236,12 +236,10 @@ Future<AsyncWorkScheduler::HostAndShard> AsyncWorkScheduler::_targetHostAsync(
hangWhileTargetingRemoteHost.pauseWhileSet(opCtx);
}
- return shard->getTargeter()
- ->findHostWithMaxWait(readPref, Seconds(20))
- .thenRunOn(_executor)
- .then([this, shard](HostAndPort host) {
- return HostAndShard{host, std::move(shard)};
- });
+ // TODO (SERVER-51247): Return a SemiFuture<HostAndShard> rather than using a blocking call
+ return HostAndShard{
+ shard->getTargeter()->findHostWithMaxWait(readPref, Seconds(20)).get(opCtx),
+ std::move(shard)};
});
}
diff --git a/src/mongo/util/future.h b/src/mongo/util/future.h
index 59e1a98bc2c..39547609de4 100644
--- a/src/mongo/util/future.h
+++ b/src/mongo/util/future.h
@@ -815,15 +815,6 @@ public:
});
}
- /**
- * Same as setFrom(Future) above, but takes a SemiFuture instead of a Future.
- */
- void setFrom(SemiFuture<T>&& future) noexcept {
- setImpl([&](boost::intrusive_ptr<future_details::SharedState<T>>&& sharedState) {
- std::move(future).propagateResultTo(sharedState.get());
- });
- }
-
TEMPLATE(typename... Args)
REQUIRES(std::is_constructible_v<T, Args...> || (std::is_void_v<T> && sizeof...(Args) == 0))
void emplaceValue(Args&&... args) noexcept {