diff options
author | Mathias Stearn <mathias@10gen.com> | 2018-10-23 14:02:20 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2018-11-02 15:47:45 -0400 |
commit | bdfe090c66532ea921b4968a32632331c0c44310 (patch) | |
tree | d877f7cb9416ab69b804356afe00ff4c749f2e63 | |
parent | 14ff5278871d47f967cdbd00a94d1721165202c6 (diff) | |
download | mongo-bdfe090c66532ea921b4968a32632331c0c44310.tar.gz |
SERVER-37717 Fix race between Baton::notify() and Waitable::wait()
-rw-r--r-- | src/mongo/s/async_requests_sender.cpp | 10 | ||||
-rw-r--r-- | src/mongo/transport/baton_asio_linux.h | 2 |
2 files changed, 3 insertions, 9 deletions
diff --git a/src/mongo/s/async_requests_sender.cpp b/src/mongo/s/async_requests_sender.cpp index 6150346a15b..c776bdc2420 100644 --- a/src/mongo/s/async_requests_sender.cpp +++ b/src/mongo/s/async_requests_sender.cpp @@ -299,14 +299,8 @@ Status AsyncRequestsSender::RemoteData::resolveShardIdToHostAndPort( str::stream() << "Could not find shard " << shardId); } - // It shouldn't be necessary to run without interruption here, but there's a subtle race around - // exiting early while callbacks hold a reference to this type. The easiest way to work around - // it is to unconditionally block in targeting (for now). - auto findHostStatus = ars->_opCtx->runWithoutInterruption([&] { - return shard->getTargeter() - ->findHostWithMaxWait(readPref, Seconds{20}) - .getNoThrow(ars->_opCtx); - }); + auto findHostStatus = + shard->getTargeter()->findHostWithMaxWait(readPref, Seconds{20}).getNoThrow(ars->_opCtx); if (findHostStatus.isOK()) shardHostAndPort = std::move(findHostStatus.getValue()); diff --git a/src/mongo/transport/baton_asio_linux.h b/src/mongo/transport/baton_asio_linux.h index 979e1461f35..f96e73b67a3 100644 --- a/src/mongo/transport/baton_asio_linux.h +++ b/src/mongo/transport/baton_asio_linux.h @@ -218,7 +218,7 @@ public: } void notify() noexcept override { - schedule([] {}); + _efd.notify(); } /** |