From 58cfddf1bdc0aca99a9dcb5666279349621fd156 Mon Sep 17 00:00:00 2001 From: Kaloian Manassiev Date: Wed, 24 Oct 2018 11:43:57 +0200 Subject: SERVER-37711 Revert commits related to lock yielding for prepared transactions on step down This change reverts the following commits: * SERVER-35870 Allow stepdown to work with prepared transactions (f96903979ac329a760e7b6f1bb5d8695d3daf2a7) * SERVER-36913 Add functionality to LockManager for repl state transitions with prepared transactions (e65ff57e108ed69c46cc0b0ccbdd675663de2469) * SERVER-35870 Allow more than one thread to block Session checkout at a time (9406af079a894bae80fbbec4703b04974bf84476) * SERVER-35870 Add functionality to prevent Session checkouts & wait for all Sessions to be checked in (c6d90316d6b694e12426274c713a4a078e004fc5) --- src/mongo/db/session_catalog.cpp | 39 --------------------------------------- 1 file changed, 39 deletions(-) (limited to 'src/mongo/db/session_catalog.cpp') diff --git a/src/mongo/db/session_catalog.cpp b/src/mongo/db/session_catalog.cpp index cc1616626de..059c6639f39 100644 --- a/src/mongo/db/session_catalog.cpp +++ b/src/mongo/db/session_catalog.cpp @@ -83,10 +83,6 @@ ScopedCheckedOutSession SessionCatalog::checkOutSession(OperationContext* opCtx) stdx::unique_lock ul(_mutex); - while (!_isSessionCheckoutAllowed()) { - opCtx->waitForConditionOrInterrupt(_checkingOutSessionsAllowedCond, ul); - } - auto sri = _getOrCreateSessionRuntimeInfo(ul, opCtx, lsid); // Wait until the session is no longer checked out @@ -95,7 +91,6 @@ ScopedCheckedOutSession SessionCatalog::checkOutSession(OperationContext* opCtx) invariant(!sri->checkedOut); sri->checkedOut = true; - ++_numCheckedOutSessions; return ScopedCheckedOutSession(opCtx, ScopedSession(std::move(sri))); } @@ -174,7 +169,6 @@ void SessionCatalog::scanSessions(OperationContext* opCtx, std::shared_ptr SessionCatalog::_getOrCreateSessionRuntimeInfo( WithLock, OperationContext* opCtx, const LogicalSessionId& lsid) { invariant(!opCtx->lockState()->inAWriteUnitOfWork()); - invariant(_isSessionCheckoutAllowed()); auto it = _sessions.find(lsid); if (it == _sessions.end()) { @@ -195,39 +189,6 @@ void SessionCatalog::_releaseSession(const LogicalSessionId& lsid) { sri->checkedOut = false; sri->availableCondVar.notify_one(); - --_numCheckedOutSessions; - if (_numCheckedOutSessions == 0) { - _allSessionsCheckedInCond.notify_all(); - } -} - -SessionCatalog::PreventCheckingOutSessionsBlock::PreventCheckingOutSessionsBlock( - SessionCatalog* sessionCatalog) - : _sessionCatalog(sessionCatalog) { - invariant(sessionCatalog); - - stdx::lock_guard lg(sessionCatalog->_mutex); - ++sessionCatalog->_preventSessionCheckoutRequests; -} - -SessionCatalog::PreventCheckingOutSessionsBlock::~PreventCheckingOutSessionsBlock() { - stdx::lock_guard lg(_sessionCatalog->_mutex); - - invariant(_sessionCatalog->_preventSessionCheckoutRequests > 0); - --_sessionCatalog->_preventSessionCheckoutRequests; - if (_sessionCatalog->_preventSessionCheckoutRequests == 0) { - _sessionCatalog->_checkingOutSessionsAllowedCond.notify_all(); - } -} - -void SessionCatalog::PreventCheckingOutSessionsBlock::waitForAllSessionsToBeCheckedIn( - OperationContext* opCtx) { - stdx::unique_lock ul(_sessionCatalog->_mutex); - - invariant(!_sessionCatalog->_isSessionCheckoutAllowed()); - while (_sessionCatalog->_numCheckedOutSessions > 0) { - opCtx->waitForConditionOrInterrupt(_sessionCatalog->_allSessionsCheckedInCond, ul); - } } OperationContextSession::OperationContextSession(OperationContext* opCtx, bool checkOutSession) -- cgit v1.2.1