summaryrefslogtreecommitdiff
path: root/src/mongo/db/session.h
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2018-03-26 17:26:50 -0400
committerDianna Hohensee <dianna.hohensee@10gen.com>2018-04-13 10:58:19 -0400
commit4f0c2f4047bdafe7a5d952a9671bf436a763c4d5 (patch)
treee202c0b4f8598f669df77efa1a44ee94a2ec0dc3 /src/mongo/db/session.h
parent10bcc73a75ac857c290c3af6a3f89a45c4867043 (diff)
downloadmongo-4f0c2f4047bdafe7a5d952a9671bf436a763c4d5.tar.gz
SERVER-33295 Periodic task to check for and kill expired transactions.
(Adding a new int server parameter 'transactionLifetimeLimitSeconds'.)
Diffstat (limited to 'src/mongo/db/session.h')
-rw-r--r--src/mongo/db/session.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/mongo/db/session.h b/src/mongo/db/session.h
index 568a91a055f..5404ff4bc77 100644
--- a/src/mongo/db/session.h
+++ b/src/mongo/db/session.h
@@ -39,11 +39,14 @@
#include "mongo/db/repl/read_concern_args.h"
#include "mongo/db/session_txn_record_gen.h"
#include "mongo/db/storage/recovery_unit.h"
+#include "mongo/platform/atomic_word.h"
#include "mongo/stdx/unordered_map.h"
#include "mongo/util/concurrency/with_lock.h"
namespace mongo {
+extern AtomicInt32 transactionLifetimeLimitSeconds;
+
class OperationContext;
class UpdateRequest;
@@ -246,6 +249,12 @@ public:
*/
void abortArbitraryTransaction();
+ /**
+ * Same as abortArbitraryTransaction, except only executes if _transactionExpireDate indicates
+ * that the transaction has expired.
+ */
+ void abortArbitraryTransactionIfExpired();
+
/*
* Aborts the transaction inside the transaction, releasing transaction resources.
* We're inside the transaction when we have the Session checked out and 'opCtx' owns the
@@ -370,6 +379,8 @@ private:
std::vector<StmtId> stmtIdsWritten,
const repl::OpTime& lastStmtIdWriteTs);
+ void _abortArbitraryTransaction(WithLock);
+
// Releases stashed transaction resources to abort the transaction.
void _abortTransaction(WithLock);
@@ -439,6 +450,13 @@ private:
// Set in _beginOrContinueTxn and applies to the activeTxn on the session.
bool _autocommit{true};
+
+ // Set when a snapshot read / transaction begins. Alleviates cache pressure by limiting how long
+ // a snapshot will remain open and available. Checked in combination with _txnState to determine
+ // whether the transaction should be aborted.
+ // This is unset until a transaction begins on the session, and then reset only when new
+ // transactions begin.
+ boost::optional<Date_t> _transactionExpireDate;
};
} // namespace mongo