From d1ba78a5a83b58275aed657d71b58a57847e7027 Mon Sep 17 00:00:00 2001 From: Maria van Keulen Date: Sun, 18 Feb 2018 20:02:26 -0500 Subject: SERVER-32636 Close outgoing connections to earlier binVersion servers --- src/mongo/db/commands/feature_compatibility_version.cpp | 13 ++++++++----- src/mongo/executor/SConscript | 1 + src/mongo/executor/network_interface_asio_auth.cpp | 11 +++++++++++ 3 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src/mongo') diff --git a/src/mongo/db/commands/feature_compatibility_version.cpp b/src/mongo/db/commands/feature_compatibility_version.cpp index c0edc6a028e..b64a072dc4b 100644 --- a/src/mongo/db/commands/feature_compatibility_version.cpp +++ b/src/mongo/db/commands/feature_compatibility_version.cpp @@ -43,6 +43,7 @@ #include "mongo/db/storage/storage_engine.h" #include "mongo/db/wire_version.h" #include "mongo/db/write_concern_options.h" +#include "mongo/executor/egress_tag_closer_manager.h" #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/transport/service_entry_point.h" #include "mongo/util/log.h" @@ -268,19 +269,21 @@ void FeatureCompatibilityVersion::onInsertOrUpdate(OperationContext* opCtx, cons log() << "setting featureCompatibilityVersion to " << toString(newVersion); } - // On commit, update the server parameters, and close any incoming connections with a wire - // version that is below the minimum. + // On commit, update the server parameters, and close any connections with a wire version that + // is below the minimum. opCtx->recoveryUnit()->onCommit([opCtx, newVersion]() { serverGlobalParams.featureCompatibility.setVersion(newVersion); updateMinWireVersion(); - // Close all incoming connections from internal clients with binary versions lower than - // ours. It would be desirable to close all outgoing connections to servers with lower - // binary version, but it is not currently possible. if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo36) { + // Close all incoming connections from internal clients with binary versions lower than + // ours. opCtx->getServiceContext()->getServiceEntryPoint()->endAllSessions( transport::Session::kLatestVersionInternalClientKeepOpen | transport::Session::kExternalClientKeepOpen); + // Close all outgoing connections to servers with binary versions lower than ours. + executor::EgressTagCloserManager::get(opCtx->getServiceContext()) + .dropConnections(transport::Session::kKeepOpen); } }); } diff --git a/src/mongo/executor/SConscript b/src/mongo/executor/SConscript index bea86e323cd..561155ec335 100644 --- a/src/mongo/executor/SConscript +++ b/src/mongo/executor/SConscript @@ -179,6 +179,7 @@ env.Library( 'async_stream', 'async_timer_asio', 'connection_pool_executor', + 'egress_tag_closer_manager', 'network_interface', 'task_executor_interface', ]) diff --git a/src/mongo/executor/network_interface_asio_auth.cpp b/src/mongo/executor/network_interface_asio_auth.cpp index 3ed78167d0a..88d9aeae29e 100644 --- a/src/mongo/executor/network_interface_asio_auth.cpp +++ b/src/mongo/executor/network_interface_asio_auth.cpp @@ -116,6 +116,17 @@ void NetworkInterfaceASIO::_runIsMaster(AsyncOp* op) { return _completeOperation(op, validateStatus); } + auto egressTagManager = _options.connectionPoolOptions.egressTagCloserManager; + if (egressTagManager) { + // Tag outgoing connection so it can be kept open on FCV upgrade if it is not to a + // server with a lower binary version. + if (protocolSet.getValue().version.maxWireVersion >= + WireSpec::instance().outgoing.maxWireVersion) { + egressTagManager->mutateTags( + op->command().target(), + [](transport::Session::TagMask tags) { return transport::Session::kKeepOpen; }); + } + } // Some unit and integration tests do not set up an egress tag manager. op->connection().setServerProtocols(protocolSet.getValue().protocolSet); -- cgit v1.2.1