diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-06-06 14:28:22 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-06-08 13:54:55 -0400 |
commit | c0273c0a89e73ecfd7848fd4906a8e3c2d5886b9 (patch) | |
tree | 85c45cd7d61b0bf8fa443b69e5d1755506352e9d /src/mongo/db/session.h | |
parent | c5152ff1761014ee1eaf8339e8ca6c80f59c5027 (diff) | |
download | mongo-c0273c0a89e73ecfd7848fd4906a8e3c2d5886b9.tar.gz |
SERVER-35217 Do not kill associated client cursors when transaction ends
Diffstat (limited to 'src/mongo/db/session.h')
-rw-r--r-- | src/mongo/db/session.h | 51 |
1 files changed, 7 insertions, 44 deletions
diff --git a/src/mongo/db/session.h b/src/mongo/db/session.h index 9ca248a2c08..e6e2a9984f2 100644 --- a/src/mongo/db/session.h +++ b/src/mongo/db/session.h @@ -64,12 +64,6 @@ class Session { MONGO_DISALLOW_COPYING(Session); public: - struct TransactionState { - static const OperationContext::Decoration<TransactionState> get; - - bool requiresIXReadUpgrade = false; - }; - /** * Holds state for a snapshot read or multi-statement transaction in between network operations. */ @@ -127,8 +121,6 @@ public: }; using CommittedStatementTimestampMap = stdx::unordered_map<StmtId, repl::OpTime>; - using CursorKillFunction = - std::function<size_t(OperationContext*, LogicalSessionId, TxnNumber)>; using CursorExistsFunction = std::function<bool(LogicalSessionId, TxnNumber)>; static const BSONObj kDeadEndSentinel; @@ -275,14 +267,6 @@ public: */ void unstashTransactionResources(OperationContext* opCtx, const std::string& cmdName); - /** - * Registers a function that will be used to kill client cursors on transaction commit or abort. - * TODO SERVER-34395: Move cursor kill function into Session instead of registering. - */ - static void registerCursorKillFunction(CursorKillFunction cursorKillFunc) { - _cursorKillFunction = cursorKillFunc; - } - // TODO SERVER-34113: Remove the "cursor exists" mechanism from both Session and CursorManager // once snapshot reads outside of multi-statement transcactions are no longer supported. static void registerCursorExistsFunction(CursorExistsFunction cursorExistsFunc) { @@ -298,13 +282,13 @@ public: /** * Aborts the transaction outside the transaction, releasing transaction resources. */ - void abortArbitraryTransaction(OperationContext* opCtx, bool shouldKillClientCursors); + void abortArbitraryTransaction(); /** * Same as abortArbitraryTransaction, except only executes if _transactionExpireDate indicates * that the transaction has expired. */ - void abortArbitraryTransactionIfExpired(OperationContext* opCtx); + void abortArbitraryTransactionIfExpired(); /* * Aborts the transaction inside the transaction, releasing transaction resources. @@ -313,11 +297,6 @@ public: */ void abortActiveTransaction(OperationContext* opCtx); - /** - * Kills any open client cursors associated with the current transaction. - */ - void killTransactionCursors(OperationContext* opCtx); - bool getAutocommit() const { return _autocommit; } @@ -405,23 +384,16 @@ public: const repl::OplogEntry& entry); private: - // Holds function to be used to kill client cursors. - static CursorKillFunction _cursorKillFunction; // Holds function which determines whether the CursorManager has client cursor references for a // given transaction. static CursorExistsFunction _cursorExistsFunction; void _beginOrContinueTxn(WithLock, - OperationContext* opCtx, TxnNumber txnNumber, boost::optional<bool> autocommit, - boost::optional<bool> startTransaction, - bool* canKillCursors); + boost::optional<bool> startTransaction); - void _beginOrContinueTxnOnMigration(WithLock, - OperationContext* opCtx, - TxnNumber txnNumber, - bool* canKillCursors); + void _beginOrContinueTxnOnMigration(WithLock, TxnNumber txnNumber); // Checks if there is a conflicting operation on the current Session void _checkValid(WithLock) const; @@ -430,10 +402,7 @@ private: // we don't start a txn that is too old. void _checkTxnValid(WithLock, TxnNumber txnNumber) const; - void _setActiveTxn(WithLock, - OperationContext* opCtx, - TxnNumber txnNumber, - bool* canKillCursors); + void _setActiveTxn(WithLock, TxnNumber txnNumber); void _checkIsActiveTransaction(WithLock, TxnNumber txnNumber, bool checkAbort) const; @@ -457,12 +426,10 @@ private: std::vector<StmtId> stmtIdsWritten, const repl::OpTime& lastStmtIdWriteTs); - void _abortArbitraryTransaction(WithLock, OperationContext* opCtx, bool* canKillCursors); + void _abortArbitraryTransaction(WithLock); // Releases stashed transaction resources to abort the transaction. - // 'canKillCursors' is an output parameter, which when set to true indicates that transaction - // client cursors may be killed. - void _abortTransaction(WithLock, OperationContext* opCtx, bool* canKillCursors); + void _abortTransaction(WithLock); // Committing a transaction first changes its state to "Committing" and writes to the oplog, // then it changes the state to "Committed". @@ -478,10 +445,6 @@ private: // 3) Migration. Should be able to skip committing transactions. void _commitTransaction(stdx::unique_lock<stdx::mutex> lk, OperationContext* opCtx); - void _killTransactionCursors(OperationContext* opCtx, - LogicalSessionId lsid, - TxnNumber txnNumber); - const LogicalSessionId _sessionId; // Protects the member variables below. |