summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-09-28 08:56:37 +0000
committerevergreen <evergreen@mongodb.com>2019-09-28 08:56:37 +0000
commit3e4cddb2866bcbb85195028d4d323f9300d24fb1 (patch)
treeb2f933a0008491ec5f493e85a4699331ffd1ad20
parent2e165002e4b434e5713d8b7dff8d46151edff85d (diff)
downloadmongo-3e4cddb2866bcbb85195028d4d323f9300d24fb1.tar.gz
SERVER-37837 Examine and reap sessions from the SessionsCatalog
-rw-r--r--src/mongo/db/SConscript15
-rw-r--r--src/mongo/db/commands/SConscript62
-rw-r--r--src/mongo/db/commands/logical_session_server_status_section.cpp (renamed from src/mongo/db/logical_session_server_status_section.cpp)20
-rw-r--r--src/mongo/db/commands/reap_logical_session_cache_now.cpp12
-rw-r--r--src/mongo/db/commands/refresh_logical_session_cache_now.cpp12
-rw-r--r--src/mongo/db/commands/refresh_sessions_command.cpp15
-rw-r--r--src/mongo/db/session_catalog.cpp73
-rw-r--r--src/mongo/db/session_catalog.h27
-rw-r--r--src/mongo/db/sessions_collection.cpp7
-rw-r--r--src/mongo/db/sessions_collection.h4
-rw-r--r--src/mongo/embedded/SConscript1
-rw-r--r--src/mongo/embedded/embedded.cpp13
-rw-r--r--src/mongo/embedded/logical_session_cache_factory_embedded.cpp58
-rw-r--r--src/mongo/embedded/logical_session_cache_factory_embedded.h42
14 files changed, 167 insertions, 194 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript
index bf83bcda5a3..d915f3d1a4f 100644
--- a/src/mongo/db/SConscript
+++ b/src/mongo/db/SConscript
@@ -630,12 +630,12 @@ env.Library(
env.Idlc('transactions_stats.idl')[0],
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/stats/fill_locker_info',
'$BUILD_DIR/mongo/idl/idl_parser',
'catalog/collection',
- 'catalog/database',
'catalog/database_holder',
+ 'catalog/database',
'catalog/uuid_catalog',
+ 'commands/test_commands_enabled',
'concurrency/lock_manager',
'curop_failpoint_helpers',
'curop_metrics',
@@ -645,9 +645,9 @@ env.Library(
'namespace_string',
'repl/oplog_entry',
's/sharding_api_d',
- "stats/top",
+ 'stats/fill_locker_info',
+ 'stats/top',
'views/views',
- '$BUILD_DIR/mongo/db/commands/test_commands_enabled',
],
LIBDEPS_PRIVATE=[
'commands/server_status',
@@ -1182,6 +1182,7 @@ env.Library(
'$BUILD_DIR/mongo/crypto/sha1_block',
'keys_collection_document',
'logical_clock',
+ 'logical_session_id',
],
)
@@ -1227,7 +1228,6 @@ envWithAsio.Library(
'service_liaison_mongod.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/logical_session_id',
'$BUILD_DIR/mongo/util/clock_sources',
'$BUILD_DIR/mongo/util/periodic_runner',
'query_exec',
@@ -1242,7 +1242,6 @@ env.Library(
'service_liaison_mongos.cpp',
],
LIBDEPS=[
- '$BUILD_DIR/mongo/db/logical_session_id',
'$BUILD_DIR/mongo/util/clock_sources',
'$BUILD_DIR/mongo/util/periodic_runner',
'$BUILD_DIR/mongo/s/coreshard',
@@ -1359,7 +1358,6 @@ env.Library(
source=[
'initialize_operation_session_info.cpp',
'logical_session_cache_impl.cpp',
- 'logical_session_server_status_section.cpp',
],
LIBDEPS=[
'logical_session_cache',
@@ -1371,8 +1369,7 @@ env.Library(
'kill_sessions',
],
LIBDEPS_PRIVATE=[
- '$BUILD_DIR/mongo/db/commands/server_status',
- '$BUILD_DIR/mongo/db/s/sharding_api_d',
+ 's/sharding_api_d',
]
)
diff --git a/src/mongo/db/commands/SConscript b/src/mongo/db/commands/SConscript
index fa520025305..b0717ce99c7 100644
--- a/src/mongo/db/commands/SConscript
+++ b/src/mongo/db/commands/SConscript
@@ -89,22 +89,22 @@ env.Library(
# Commands available in every process that executes commands
env.Library(
- target="core",
+ target='core',
source=[
- "copydb_common.cpp",
- "end_sessions_command.cpp",
- "fail_point_cmd.cpp",
- "find_and_modify_common.cpp",
- "generic.cpp",
- "hashcmd.cpp",
- "kill_all_sessions_by_pattern_command.cpp",
- "kill_all_sessions_command.cpp",
- "kill_sessions_command.cpp",
- "parameters.cpp",
- "refresh_logical_session_cache_now.cpp",
- "refresh_sessions_command.cpp",
- "rename_collection_common.cpp",
- "start_session_command.cpp",
+ 'copydb_common.cpp',
+ 'end_sessions_command.cpp',
+ 'fail_point_cmd.cpp',
+ 'find_and_modify_common.cpp',
+ 'generic.cpp',
+ 'hashcmd.cpp',
+ 'kill_all_sessions_by_pattern_command.cpp',
+ 'kill_all_sessions_command.cpp',
+ 'kill_sessions_command.cpp',
+ 'parameters.cpp',
+ 'refresh_logical_session_cache_now.cpp',
+ 'refresh_sessions_command.cpp',
+ 'rename_collection_common.cpp',
+ 'start_session_command.cpp',
env.Idlc('end_sessions.idl')[0],
],
LIBDEPS_PRIVATE=[
@@ -127,18 +127,19 @@ env.Library(
# Commands available in all mongodb server processes (mongod, mongos, etc.)
env.Library(
- target="servers",
+ target='servers',
source=[
- "authentication_commands.cpp",
- "conn_pool_stats.cpp",
- "conn_pool_sync.cpp",
- "connection_status.cpp",
- "generic_servers.cpp",
- "isself.cpp",
- "mr_common.cpp",
- "reap_logical_session_cache_now.cpp",
- "refresh_sessions_command_internal.cpp",
- "user_management_commands_common.cpp",
+ 'authentication_commands.cpp',
+ 'conn_pool_stats.cpp',
+ 'conn_pool_sync.cpp',
+ 'connection_status.cpp',
+ 'generic_servers.cpp',
+ 'isself.cpp',
+ 'logical_session_server_status_section.cpp',
+ 'mr_common.cpp',
+ 'reap_logical_session_cache_now.cpp',
+ 'refresh_sessions_command_internal.cpp',
+ 'user_management_commands_common.cpp',
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/client/clientdriver_minimal',
@@ -146,22 +147,23 @@ env.Library(
'$BUILD_DIR/mongo/db/auth/sasl_options',
'$BUILD_DIR/mongo/db/auth/user_document_parser',
'$BUILD_DIR/mongo/db/commands',
- '$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/db/common',
'$BUILD_DIR/mongo/db/log_process_details',
- '$BUILD_DIR/mongo/db/logical_session_cache',
'$BUILD_DIR/mongo/db/logical_session_cache_impl',
- '$BUILD_DIR/mongo/db/logical_session_id',
+ '$BUILD_DIR/mongo/db/logical_session_cache',
'$BUILD_DIR/mongo/db/logical_session_id_helpers',
+ '$BUILD_DIR/mongo/db/logical_session_id',
'$BUILD_DIR/mongo/db/repl/isself',
'$BUILD_DIR/mongo/db/repl/repl_coordinator_interface',
'$BUILD_DIR/mongo/executor/task_executor_pool',
- '$BUILD_DIR/mongo/s/sharding_legacy_api',
'$BUILD_DIR/mongo/s/coreshard',
+ '$BUILD_DIR/mongo/s/sharding_legacy_api',
'$BUILD_DIR/mongo/scripting/scripting_common',
'$BUILD_DIR/mongo/util/ntservice',
'core',
'feature_compatibility_parsers',
+ 'server_status',
+ 'test_commands_enabled',
]
)
diff --git a/src/mongo/db/logical_session_server_status_section.cpp b/src/mongo/db/commands/logical_session_server_status_section.cpp
index 86b31229058..5a57cf7e40e 100644
--- a/src/mongo/db/logical_session_server_status_section.cpp
+++ b/src/mongo/db/commands/logical_session_server_status_section.cpp
@@ -36,26 +36,24 @@
#include "mongo/db/operation_context.h"
namespace mongo {
-
namespace {
-class LogicalSessionSSS : public ServerStatusSection {
+class LogicalSessionServerStatusSection : public ServerStatusSection {
public:
- LogicalSessionSSS() : ServerStatusSection("logicalSessionRecordCache") {}
-
- virtual ~LogicalSessionSSS() {}
+ LogicalSessionServerStatusSection() : ServerStatusSection("logicalSessionRecordCache") {}
- virtual bool includeByDefault() const {
+ bool includeByDefault() const override {
return true;
}
- virtual BSONObj generateSection(OperationContext* opCtx,
- const BSONElement& configElement) const {
- auto lsCache = LogicalSessionCache::get(opCtx);
- return lsCache ? lsCache->getStats().toBSON() : BSONObj();
+ BSONObj generateSection(OperationContext* opCtx,
+ const BSONElement& configElement) const override {
+ const auto logicalSessionCache = LogicalSessionCache::get(opCtx);
+
+ return logicalSessionCache ? logicalSessionCache->getStats().toBSON() : BSONObj();
}
-} LogicalSessionSSS;
+} logicalSessionsServerStatusSection;
} // namespace
} // namespace mongo
diff --git a/src/mongo/db/commands/reap_logical_session_cache_now.cpp b/src/mongo/db/commands/reap_logical_session_cache_now.cpp
index 82a1a4913b2..5434c18ad78 100644
--- a/src/mongo/db/commands/reap_logical_session_cache_now.cpp
+++ b/src/mongo/db/commands/reap_logical_session_cache_now.cpp
@@ -38,12 +38,9 @@
#include "mongo/db/operation_context.h"
namespace mongo {
-
namespace {
class ReapLogicalSessionCacheNowCommand final : public BasicCommand {
- MONGO_DISALLOW_COPYING(ReapLogicalSessionCacheNowCommand);
-
public:
ReapLogicalSessionCacheNowCommand() : BasicCommand("reapLogicalSessionCacheNow") {}
@@ -70,10 +67,10 @@ public:
return Status::OK();
}
- virtual bool run(OperationContext* opCtx,
- const std::string& db,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) override {
+ bool run(OperationContext* opCtx,
+ const std::string& db,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) override {
auto cache = LogicalSessionCache::get(opCtx);
auto client = opCtx->getClient();
@@ -87,5 +84,4 @@ public:
MONGO_REGISTER_TEST_COMMAND(ReapLogicalSessionCacheNowCommand);
} // namespace
-
} // namespace mongo
diff --git a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
index 574d5b8ee52..7cef8f16699 100644
--- a/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
+++ b/src/mongo/db/commands/refresh_logical_session_cache_now.cpp
@@ -39,12 +39,9 @@
#include "mongo/db/operation_context.h"
namespace mongo {
-
namespace {
class RefreshLogicalSessionCacheNowCommand final : public BasicCommand {
- MONGO_DISALLOW_COPYING(RefreshLogicalSessionCacheNowCommand);
-
public:
RefreshLogicalSessionCacheNowCommand() : BasicCommand("refreshLogicalSessionCacheNow") {}
@@ -75,10 +72,10 @@ public:
return Status::OK();
}
- virtual bool run(OperationContext* opCtx,
- const std::string& db,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) override {
+ bool run(OperationContext* opCtx,
+ const std::string& db,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) override {
auto cache = LogicalSessionCache::get(opCtx);
auto client = opCtx->getClient();
@@ -94,5 +91,4 @@ public:
MONGO_REGISTER_TEST_COMMAND(RefreshLogicalSessionCacheNowCommand);
} // namespace
-
} // namespace mongo
diff --git a/src/mongo/db/commands/refresh_sessions_command.cpp b/src/mongo/db/commands/refresh_sessions_command.cpp
index dbfbe88bcf9..0804ffc2906 100644
--- a/src/mongo/db/commands/refresh_sessions_command.cpp
+++ b/src/mongo/db/commands/refresh_sessions_command.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/refresh_sessions_gen.h"
namespace mongo {
+namespace {
class RefreshSessionsCommand final : public BasicCommand {
MONGO_DISALLOW_COPYING(RefreshSessionsCommand);
@@ -51,15 +52,19 @@ public:
AllowedOnSecondary secondaryAllowed(ServiceContext*) const override {
return AllowedOnSecondary::kAlways;
}
+
bool adminOnly() const override {
return false;
}
+
bool supportsWriteConcern(const BSONObj& cmd) const override {
return false;
}
+
std::string help() const override {
return "renew a set of logical sessions";
}
+
Status checkAuthForOperation(OperationContext* opCtx,
const std::string& dbname,
const BSONObj& cmdObj) const override {
@@ -75,10 +80,10 @@ public:
}
}
- virtual bool run(OperationContext* opCtx,
- const std::string& db,
- const BSONObj& cmdObj,
- BSONObjBuilder& result) override {
+ bool run(OperationContext* opCtx,
+ const std::string& db,
+ const BSONObj& cmdObj,
+ BSONObjBuilder& result) override {
IDLParserErrorContext ctx("RefreshSessionsCmdFromClient");
auto cmd = RefreshSessionsCmdFromClient::parse(ctx, cmdObj);
auto res =
@@ -87,6 +92,8 @@ public:
return true;
}
+
} refreshSessionsCommand;
+} // namespace
} // namespace mongo
diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp
index efb93229584..4b2355ce6d2 100644
--- a/src/mongo/db/session_catalog.cpp
+++ b/src/mongo/db/session_catalog.cpp
@@ -154,6 +154,17 @@ boost::optional<UUID> SessionCatalog::getTransactionTableUUID(OperationContext*
int SessionCatalog::reapSessionsOlderThan(OperationContext* opCtx,
SessionsCollection& sessionsCollection,
Date_t possiblyExpired) {
+ const auto catalog = SessionCatalog::get(opCtx);
+ catalog->_reapInMemorySessionsOlderThan(opCtx, sessionsCollection, possiblyExpired);
+
+ // The "unsafe" check for primary below is a best-effort attempt to ensure that the on-disk
+ // state reaping code doesn't run if the node is secondary and cause log spam. It is a work
+ // around the fact that the logical sessions cache is not registered to listen for replication
+ // state changes.
+ const auto replCoord = repl::ReplicationCoordinator::get(opCtx);
+ if (!replCoord->canAcceptWritesForDatabase_UNSAFE(opCtx, NamespaceString::kConfigDb))
+ return 0;
+
// Scan for records older than the minimum lifetime and uses a sort to walk the '_id' index
DBDirectClient client(opCtx);
auto cursor =
@@ -233,6 +244,7 @@ ScopedCheckedOutSession SessionCatalog::checkOutSession(OperationContext* opCtx)
invariant(!sri->checkedOut);
sri->checkedOut = true;
+ sri->lastCheckout = Date_t::now();
return ScopedCheckedOutSession(opCtx, ScopedSession(std::move(sri)));
}
@@ -266,17 +278,6 @@ void SessionCatalog::invalidateSessions(OperationContext* opCtx,
!opCtx->getLogicalSessionId());
}
- const auto invalidateSessionFn = [&](WithLock, decltype(_txnTable)::iterator it) {
- auto& sri = it->second;
- sri->txnState.invalidate();
-
- // We cannot remove checked-out sessions from the cache, because operations expect to find
- // them there to check back in
- if (!sri->checkedOut) {
- _txnTable.erase(it);
- }
- };
-
stdx::lock_guard<stdx::mutex> lg(_mutex);
if (singleSessionDoc) {
@@ -285,12 +286,12 @@ void SessionCatalog::invalidateSessions(OperationContext* opCtx,
auto it = _txnTable.find(lsid);
if (it != _txnTable.end()) {
- invalidateSessionFn(lg, it);
+ _invalidateSession(lg, it);
}
} else {
auto it = _txnTable.begin();
while (it != _txnTable.end()) {
- invalidateSessionFn(lg, it++);
+ _invalidateSession(lg, it++);
}
}
}
@@ -312,6 +313,11 @@ void SessionCatalog::scanSessions(OperationContext* opCtx,
}
}
+size_t SessionCatalog::size() const {
+ stdx::lock_guard<stdx::mutex> lg(_mutex);
+ return _txnTable.size();
+}
+
std::shared_ptr<SessionCatalog::SessionRuntimeInfo> SessionCatalog::_getOrCreateSessionRuntimeInfo(
WithLock, OperationContext* opCtx, const LogicalSessionId& lsid) {
invariant(!opCtx->lockState()->inAWriteUnitOfWork());
@@ -337,6 +343,47 @@ void SessionCatalog::_releaseSession(const LogicalSessionId& lsid) {
sri->availableCondVar.notify_one();
}
+void SessionCatalog::_invalidateSession(WithLock, SessionRuntimeInfoMap::iterator it) {
+ auto& sri = it->second;
+ sri->txnState.invalidate();
+
+ // We cannot remove checked-out sessions from the cache, because operations expect to find them
+ // there to check back in
+ if (!sri->checkedOut) {
+ _txnTable.erase(it);
+ }
+}
+
+void SessionCatalog::_reapInMemorySessionsOlderThan(OperationContext* opCtx,
+ SessionsCollection& sessionsCollection,
+ Date_t possiblyExpired) {
+ LogicalSessionIdSet possiblyExpiredLsids;
+ {
+ stdx::unique_lock<stdx::mutex> ul(_mutex);
+ for (auto& entry : _txnTable) {
+ auto& session = entry.second;
+ if (session->lastCheckout < possiblyExpired) {
+ possiblyExpiredLsids.insert(entry.first);
+ }
+ }
+ }
+
+ // From the passed-in sessions, find the ones which are actually expired/removed
+ auto expiredSessionIds =
+ uassertStatusOK(sessionsCollection.findRemovedSessions(opCtx, possiblyExpiredLsids));
+
+ stdx::lock_guard<stdx::mutex> lg(_mutex);
+
+ // Remove the session ids from the in-memory catalog
+ for (const auto& lsid : expiredSessionIds) {
+ auto it = _txnTable.find(lsid);
+ if (it == _txnTable.end())
+ continue;
+
+ _invalidateSession(lg, it);
+ }
+}
+
OperationContextSession::OperationContextSession(OperationContext* opCtx, bool checkOutSession)
: _opCtx(opCtx) {
diff --git a/src/mongo/db/session_catalog.h b/src/mongo/db/session_catalog.h
index 4730b0c5b44..c83f785fff6 100644
--- a/src/mongo/db/session_catalog.h
+++ b/src/mongo/db/session_catalog.h
@@ -139,6 +139,11 @@ public:
const SessionKiller::Matcher& matcher,
stdx::function<void(OperationContext*, Session*)> workerFn);
+ /**
+ * Returns the total number of entries currently cached on the session catalog.
+ */
+ size_t size() const;
+
private:
struct SessionRuntimeInfo {
SessionRuntimeInfo(LogicalSessionId lsid) : txnState(std::move(lsid)) {}
@@ -148,6 +153,9 @@ private:
// check it out.
bool checkedOut{false};
+ // Keeps the last time this session was checked-out
+ Date_t lastCheckout{Date_t::now()};
+
// Signaled when the state becomes available. Uses the transaction table's mutex to protect
// the state transitions.
stdx::condition_variable availableCondVar;
@@ -157,6 +165,8 @@ private:
Session txnState;
};
+ using SessionRuntimeInfoMap = LogicalSessionIdMap<std::shared_ptr<SessionRuntimeInfo>>;
+
/**
* May release and re-acquire it zero or more times before returning. The returned
* 'SessionRuntimeInfo' is guaranteed to be linked on the catalog's _txnTable as long as the
@@ -170,8 +180,21 @@ private:
*/
void _releaseSession(const LogicalSessionId& lsid);
- stdx::mutex _mutex;
- LogicalSessionIdMap<std::shared_ptr<SessionRuntimeInfo>> _txnTable;
+ void _invalidateSession(WithLock, SessionRuntimeInfoMap::iterator it);
+
+ /**
+ * Snapshots the set of in-memory sessions currently on the catalog, checks whether they are
+ * still in use though the passed 'sessionsCollection' and if any have expired, calls
+ * 'invalidateSession' on them.
+ */
+ void _reapInMemorySessionsOlderThan(OperationContext* opCtx,
+ SessionsCollection& sessionsCollection,
+ Date_t possiblyExpired);
+
+ // Protects the state below
+ mutable stdx::mutex _mutex;
+
+ SessionRuntimeInfoMap _txnTable;
};
/**
diff --git a/src/mongo/db/sessions_collection.cpp b/src/mongo/db/sessions_collection.cpp
index 9bb47a9b911..052083fe510 100644
--- a/src/mongo/db/sessions_collection.cpp
+++ b/src/mongo/db/sessions_collection.cpp
@@ -47,9 +47,6 @@
#include "mongo/stdx/memory.h"
namespace mongo {
-
-constexpr StringData SessionsCollection::kSessionsTTLIndex;
-
namespace {
// This batch size is chosen to ensure that we don't form requests larger than the 16mb limit.
@@ -165,6 +162,10 @@ Status runBulkCmd(StringData label,
const NamespaceString SessionsCollection::kSessionsNamespaceString =
NamespaceString(NamespaceString::kConfigDb, "system.sessions");
+constexpr StringData SessionsCollection::kSessionsTTLIndex;
+
+SessionsCollection::SessionsCollection() = default;
+
SessionsCollection::~SessionsCollection() = default;
SessionsCollection::SendBatchFn SessionsCollection::makeSendFnForBatchWrite(
diff --git a/src/mongo/db/sessions_collection.h b/src/mongo/db/sessions_collection.h
index 206e37c3dfb..e6d2b74ac4a 100644
--- a/src/mongo/db/sessions_collection.h
+++ b/src/mongo/db/sessions_collection.h
@@ -35,8 +35,6 @@
namespace mongo {
-class BSONArrayBuilder;
-class BSONObjBuilder;
class DBClientBase;
class OperationContext;
@@ -100,6 +98,8 @@ public:
static BSONObj generateCollModCmd();
protected:
+ SessionsCollection();
+
/**
* Makes a send function for the given client.
*/
diff --git a/src/mongo/embedded/SConscript b/src/mongo/embedded/SConscript
index 4e8455f5cbe..d0998905281 100644
--- a/src/mongo/embedded/SConscript
+++ b/src/mongo/embedded/SConscript
@@ -70,7 +70,6 @@ env.Library(
'embedded_options.cpp',
'embedded_options_init.cpp',
'embedded_options_parser_init.cpp',
- 'logical_session_cache_factory_embedded.cpp',
'periodic_runner_embedded.cpp',
'replication_coordinator_embedded.cpp',
'service_entry_point_embedded.cpp',
diff --git a/src/mongo/embedded/embedded.cpp b/src/mongo/embedded/embedded.cpp
index 7f7ee332f0f..4dda644312d 100644
--- a/src/mongo/embedded/embedded.cpp
+++ b/src/mongo/embedded/embedded.cpp
@@ -49,16 +49,18 @@
#include "mongo/db/index_rebuilder.h"
#include "mongo/db/kill_sessions_local.h"
#include "mongo/db/logical_clock.h"
+#include "mongo/db/logical_session_cache_impl.h"
#include "mongo/db/op_observer_impl.h"
#include "mongo/db/op_observer_registry.h"
#include "mongo/db/repair_database_and_check_version.h"
#include "mongo/db/repl/storage_interface_impl.h"
+#include "mongo/db/service_liaison_mongod.h"
#include "mongo/db/session_catalog.h"
#include "mongo/db/session_killer.h"
+#include "mongo/db/sessions_collection_standalone.h"
#include "mongo/db/storage/encryption_hooks.h"
#include "mongo/db/storage/storage_engine_init.h"
#include "mongo/db/ttl.h"
-#include "mongo/embedded/logical_session_cache_factory_embedded.h"
#include "mongo/embedded/periodic_runner_embedded.h"
#include "mongo/embedded/replication_coordinator_embedded.h"
#include "mongo/embedded/service_entry_point_embedded.h"
@@ -313,8 +315,13 @@ ServiceContext* initialize(const char* yaml_config) {
}
// Set up the logical session cache
- auto sessionCache = makeLogicalSessionCacheEmbedded();
- LogicalSessionCache::set(serviceContext, std::move(sessionCache));
+ LogicalSessionCache::set(serviceContext,
+ stdx::make_unique<LogicalSessionCacheImpl>(
+ std::make_unique<ServiceLiaisonMongod>(),
+ std::make_shared<SessionsCollectionStandalone>(),
+ [](OperationContext*, SessionsCollection&, Date_t) {
+ return 0; /* No op*/
+ }));
// MessageServer::run will return when exit code closes its socket and we don't need the
// operation context anymore
diff --git a/src/mongo/embedded/logical_session_cache_factory_embedded.cpp b/src/mongo/embedded/logical_session_cache_factory_embedded.cpp
deleted file mode 100644
index e6159a3ec28..00000000000
--- a/src/mongo/embedded/logical_session_cache_factory_embedded.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-
-/**
- * Copyright (C) 2018-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.
- */
-
-#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kControl
-
-#include "mongo/platform/basic.h"
-
-#include "mongo/embedded/logical_session_cache_factory_embedded.h"
-
-#include "mongo/db/logical_session_cache_impl.h"
-#include "mongo/db/service_liaison_mongod.h"
-#include "mongo/db/sessions_collection_standalone.h"
-#include "mongo/stdx/memory.h"
-#include "mongo/util/log.h"
-
-namespace mongo {
-
-std::unique_ptr<LogicalSessionCache> makeLogicalSessionCacheEmbedded() {
- auto liaison = std::make_unique<ServiceLiaisonMongod>();
-
- auto sessionsColl = std::make_shared<SessionsCollectionStandalone>();
-
- return stdx::make_unique<LogicalSessionCacheImpl>(
- std::move(liaison),
- std::move(sessionsColl),
- [](OperationContext*, SessionsCollection&, Date_t) {
- return 0; /* No op*/
- });
-}
-
-} // namespace mongo
diff --git a/src/mongo/embedded/logical_session_cache_factory_embedded.h b/src/mongo/embedded/logical_session_cache_factory_embedded.h
deleted file mode 100644
index 69c84e18ed1..00000000000
--- a/src/mongo/embedded/logical_session_cache_factory_embedded.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/**
- * Copyright (C) 2018-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.
- */
-
-#pragma once
-
-#include <memory>
-
-#include "mongo/db/logical_session_cache.h"
-#include "mongo/db/service_liaison.h"
-
-namespace mongo {
-
-std::unique_ptr<LogicalSessionCache> makeLogicalSessionCacheEmbedded();
-
-} // namespace mongo