summaryrefslogtreecommitdiff
path: root/src/mongo/db/session_catalog.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-10-10 09:28:13 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2018-10-12 02:27:33 -0400
commit6ac6f0efe6e2b6452f2238beb765396f983c53cb (patch)
treeecc34bb073b4c1c43be2cdff343d7a82b1160c19 /src/mongo/db/session_catalog.cpp
parent5e27924959612f7ea922494bd098dac8e7af4e99 (diff)
downloadmongo-6ac6f0efe6e2b6452f2238beb765396f983c53cb.tar.gz
SERVER-37244 Move MongoD-specific code out of SessionCatalog
Diffstat (limited to 'src/mongo/db/session_catalog.cpp')
-rw-r--r--src/mongo/db/session_catalog.cpp58
1 files changed, 4 insertions, 54 deletions
diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp
index 5d18e890666..9f9587e1d7f 100644
--- a/src/mongo/db/session_catalog.cpp
+++ b/src/mongo/db/session_catalog.cpp
@@ -32,11 +32,7 @@
#include "mongo/db/session_catalog.h"
-#include <boost/optional.hpp>
-
-#include "mongo/db/db_raii.h"
#include "mongo/db/dbdirectclient.h"
-#include "mongo/db/kill_sessions_common.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
@@ -77,49 +73,6 @@ SessionCatalog* SessionCatalog::get(ServiceContext* service) {
return &sessionTransactionTable;
}
-boost::optional<UUID> SessionCatalog::getTransactionTableUUID(OperationContext* opCtx) {
- AutoGetCollection autoColl(opCtx, NamespaceString::kSessionTransactionsTableNamespace, MODE_IS);
-
- const auto coll = autoColl.getCollection();
- if (coll == nullptr) {
- return boost::none;
- }
-
- return coll->uuid();
-}
-
-void SessionCatalog::onStepUp(OperationContext* opCtx) {
- invalidateSessions(opCtx, boost::none);
-
- DBDirectClient client(opCtx);
-
- const size_t initialExtentSize = 0;
- const bool capped = false;
- const bool maxSize = 0;
-
- BSONObj result;
-
- if (client.createCollection(NamespaceString::kSessionTransactionsTableNamespace.ns(),
- initialExtentSize,
- capped,
- maxSize,
- &result)) {
- return;
- }
-
- const auto status = getStatusFromCommandResult(result);
-
- if (status == ErrorCodes::NamespaceExists) {
- return;
- }
-
- uassertStatusOKWithContext(status,
- str::stream()
- << "Failed to create the "
- << NamespaceString::kSessionTransactionsTableNamespace.ns()
- << " collection");
-}
-
ScopedCheckedOutSession SessionCatalog::checkOutSession(OperationContext* opCtx) {
invariant(!opCtx->lockState()->isLocked());
invariant(opCtx->getLogicalSessionId());
@@ -204,17 +157,14 @@ void SessionCatalog::invalidateSessions(OperationContext* opCtx,
void SessionCatalog::scanSessions(OperationContext* opCtx,
const SessionKiller::Matcher& matcher,
- stdx::function<void(OperationContext*, Session*)> workerFn) {
+ const ScanSessionsCallbackFn& workerFn) {
stdx::lock_guard<stdx::mutex> lg(_mutex);
LOG(2) << "Beginning scanSessions. Scanning " << _sessions.size() << " sessions.";
- for (auto it = _sessions.begin(); it != _sessions.end(); ++it) {
- // TODO SERVER-33850: Rename KillAllSessionsByPattern and
- // ScopedKillAllSessionsByPatternImpersonator to not refer to session kill.
- if (const KillAllSessionsByPattern* pattern = matcher.match(it->first)) {
- ScopedKillAllSessionsByPatternImpersonator impersonator(opCtx, *pattern);
- workerFn(opCtx, &(it->second->txnState));
+ for (auto& sessionEntry : _sessions) {
+ if (matcher.match(sessionEntry.first)) {
+ workerFn(opCtx, &sessionEntry.second->txnState);
}
}
}