summaryrefslogtreecommitdiff
path: root/src/mongo/transport
diff options
context:
space:
mode:
authorDaniel Morilha <daniel.morilha@mongodb.com>2022-02-22 21:00:34 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-22 21:32:16 +0000
commit762a643913be8de814c69cdf37322b2b803170c7 (patch)
tree481dafcc6eaea616d4b17c625608a5fe8b395fea /src/mongo/transport
parentc65aa01ff0a99d6bcbe44a4fef44a33e918d939d (diff)
downloadmongo-762a643913be8de814c69cdf37322b2b803170c7.tar.gz
SERVER-63674 Create a FeatureFlag for ServiceEntryPointImpl::shutdownAndWait
Diffstat (limited to 'src/mongo/transport')
-rw-r--r--src/mongo/transport/SConscript1
-rw-r--r--src/mongo/transport/service_entry_point_impl.cpp27
-rw-r--r--src/mongo/transport/service_entry_point_impl.idl38
3 files changed, 59 insertions, 7 deletions
diff --git a/src/mongo/transport/SConscript b/src/mongo/transport/SConscript
index 2b31f351150..02ff0750d99 100644
--- a/src/mongo/transport/SConscript
+++ b/src/mongo/transport/SConscript
@@ -115,6 +115,7 @@ env.Library(
target='service_entry_point',
source=[
'service_entry_point_impl.cpp',
+ 'service_entry_point_impl.idl',
'service_state_machine.cpp',
],
LIBDEPS=[
diff --git a/src/mongo/transport/service_entry_point_impl.cpp b/src/mongo/transport/service_entry_point_impl.cpp
index 1821eae0cfe..20703e97721 100644
--- a/src/mongo/transport/service_entry_point_impl.cpp
+++ b/src/mongo/transport/service_entry_point_impl.cpp
@@ -29,8 +29,6 @@
#define MONGO_LOGV2_DEFAULT_COMPONENT ::mongo::logv2::LogComponent::kNetwork
-#include "mongo/platform/basic.h"
-
#include "mongo/transport/service_entry_point_impl.h"
#include <fmt/format.h>
@@ -40,6 +38,7 @@
#include "mongo/db/service_context.h"
#include "mongo/logv2/log.h"
#include "mongo/transport/hello_metrics.h"
+#include "mongo/transport/service_entry_point_impl_gen.h"
#include "mongo/transport/service_executor.h"
#include "mongo/transport/service_executor_gen.h"
#include "mongo/transport/service_state_machine.h"
@@ -214,6 +213,8 @@ void ServiceEntryPointImpl::startSession(transport::SessionHandle session) {
_currentConnections.store(connectionCount);
}
+ _sessionsCV.notify_one();
+
if (!quiet) {
LOGV2(22944,
"Connection ended",
@@ -222,8 +223,6 @@ void ServiceEntryPointImpl::startSession(transport::SessionHandle session) {
"connectionId"_attr = session->id(),
"connectionCount"_attr = connectionCount);
}
-
- _sessionsCV.notify_one();
});
auto seCtx = transport::ServiceExecutorContext{};
@@ -245,13 +244,24 @@ void ServiceEntryPointImpl::endAllSessions(transport::Session::TagMask tags) {
bool ServiceEntryPointImpl::shutdown(Milliseconds timeout) {
#if __has_feature(address_sanitizer) || __has_feature(thread_sanitizer)
+ static constexpr bool kSanitizerBuild = true;
+#else
+ static constexpr bool kSanitizerBuild = false;
+#endif
+
// When running under address sanitizer, we get false positive leaks due to disorder around
// the lifecycle of a connection and request. When we are running under ASAN, we try a lot
// harder to dry up the server from active connections before going on to really shut down.
- return shutdownAndWait(timeout);
-#else
+ // In non-sanitizer builds, a feature flag can enable a true shutdown anyway. We use the
+ // flag to identify these shutdown problems in testing.
+ if (kSanitizerBuild || transport::gJoinIngressSessionsOnShutdown) {
+ const auto result = shutdownAndWait(timeout);
+ if (transport::gJoinIngressSessionsOnShutdown)
+ invariant(result, "Shutdown did not complete within {}ms"_format(timeout.count()));
+ return result;
+ }
+
return true;
-#endif
}
bool ServiceEntryPointImpl::shutdownAndWait(Milliseconds timeout) {
@@ -265,6 +275,9 @@ bool ServiceEntryPointImpl::shutdownAndWait(Milliseconds timeout) {
// drained all active operations within the deadline, just keep going with shutdown: the OS will
// do it for us when the process terminates.
_terminateAll(lk);
+
+ LOGV2(6367401, "Shutting down service entry point and waiting for sessions to join");
+
auto result = _waitForNoSessions(lk, deadline);
lk.unlock();
diff --git a/src/mongo/transport/service_entry_point_impl.idl b/src/mongo/transport/service_entry_point_impl.idl
new file mode 100644
index 00000000000..193bde4f076
--- /dev/null
+++ b/src/mongo/transport/service_entry_point_impl.idl
@@ -0,0 +1,38 @@
+# Copyright (C) 2022-present MongoDB, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the Server Side Public License, version 1,
+# as published by MongoDB, Inc.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# Server Side Public License for more details.
+#
+# You should have received a copy of the Server Side Public License
+# along with this program. If not, see
+# <http://www.mongodb.com/licensing/server-side-public-license>.
+#
+# As a special exception, the copyright holders give permission to link the
+# code of portions of this program with the OpenSSL library under certain
+# conditions as described in each individual source file and distribute
+# linked combinations including the program with the OpenSSL library. You
+# must comply with the Server Side Public License in all respects for
+# all of the code used other than as permitted herein. If you modify file(s)
+# with this exception, you may extend this exception to your version of the
+# file(s), but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version. If you delete this
+# exception statement from all source files in the program, then also delete
+# it in the license file.
+#
+
+global:
+ cpp_namespace: "mongo::transport"
+
+server_parameters:
+ joinIngressSessionsOnShutdown:
+ description: Allow server to perform a graceful shutdown for ingress sessions.
+ set_at: startup
+ cpp_varname: gJoinIngressSessionsOnShutdown
+ cpp_vartype: bool
+ default: false