diff options
author | Judah Schvimer <judah@mongodb.com> | 2018-06-07 11:54:35 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2018-06-07 11:54:35 -0400 |
commit | da63637defad5975040f8eac0e98c86c8d8e2533 (patch) | |
tree | e4ebf901a2fef4b8367e1adec35cd9113d5d9640 /src/mongo/db/session.h | |
parent | 6a66e646c41071c5bf0e28d885a758e05f353536 (diff) | |
download | mongo-da63637defad5975040f8eac0e98c86c8d8e2533.tar.gz |
SERVER-34824 Make prepareTransaction command write a prepare oplog entry and use its optime as the prepare timestamp
Diffstat (limited to 'src/mongo/db/session.h')
-rw-r--r-- | src/mongo/db/session.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/mongo/db/session.h b/src/mongo/db/session.h index 793d5dec814..c2d29abd55e 100644 --- a/src/mongo/db/session.h +++ b/src/mongo/db/session.h @@ -107,6 +107,25 @@ public: WriteUnitOfWork::RecoveryUnitState _ruState; }; + /** + * An RAII object that stashes `TxnResouces` from the `opCtx` onto the stack. At destruction + * it unstashes the `TxnResources` back onto the `opCtx`. + */ + class SideTransactionBlock { + public: + SideTransactionBlock(OperationContext* opCtx); + ~SideTransactionBlock(); + + // Rule of 5: because we have a class-defined destructor, we need to explictly specify + // the move operator and move assignment operator. + SideTransactionBlock(SideTransactionBlock&&) = default; + SideTransactionBlock& operator=(SideTransactionBlock&&) = default; + + private: + boost::optional<Session::TxnResources> _txnResources; + OperationContext* _opCtx; + }; + using CommittedStatementTimestampMap = stdx::unordered_map<StmtId, repl::OpTime>; using CursorKillFunction = std::function<size_t(OperationContext*, LogicalSessionId, TxnNumber)>; @@ -305,7 +324,8 @@ public: /** * Returns whether we are in a multi-document transaction, which means we have an active - * transaction which has autoCommit:false and has not been committed or aborted. + * transaction which has autoCommit:false and has not been committed or aborted. It is possible + * that the current transaction is stashed onto the stack via a `SideTransactionBlock`. */ bool inMultiDocumentTransaction() const { stdx::lock_guard<stdx::mutex> lk(_mutex); |