35 #include "mongo/base/disallow_copying.h" 36 #include "mongo/base/status.h" 37 #include "mongo/bson/timestamp.h" 38 #include "mongo/db/repl/read_concern_level.h" 39 #include "mongo/db/repl/replication_coordinator.h" 45 class OperationContext;
92 uasserted(ErrorCodes::CommandNotSupported,
93 "This storage engine does not support prepared transactions");
157 return {ErrorCodes::CommandNotSupported,
158 "Current storage engine does not support majority readConcerns"};
227 uasserted(ErrorCodes::CommandNotSupported,
228 "This storage engine does not support prepared transactions");
260 boost::optional<Timestamp> provided = boost::none) {}
263 return ReadSource::kNone;
286 virtual void commit(boost::optional<Timestamp> commitTime) = 0;
305 template <
typename Callback>
307 class OnRollbackChange final :
public Change {
309 OnRollbackChange(Callback&& callback) : _callback(std::move(callback)) {}
313 void commit(boost::optional<Timestamp>)
final {}
327 template <
typename Callback>
329 class OnCommitChange final :
public Change {
331 OnCommitChange(Callback&& callback) : _callback(std::move(callback)) {}
333 void commit(boost::optional<Timestamp> commitTime)
final {
334 _callback(commitTime);
367 template <
typename T>
void onRollback(Callback callback)
Registers a callback to be called if the current WriteUnitOfWork rolls back.
Definition: recovery_unit.h:306
virtual void rollback()=0
T * writing(T *x)
A templated helper for writingPtr.
Definition: recovery_unit.h:368
virtual void setRollbackWritesDisabled()=0
Sets a flag that declares this RecoveryUnit will skip rolling back writes, for the duration of the cu...
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
virtual void abandonSnapshot()=0
If there is an open transaction, it is closed.
virtual bool waitUntilUnjournaledWritesDurable()
Unlike waitUntilDurable, this method takes a stable checkpoint, making durable any writes on unjourna...
Definition: recovery_unit.h:124
OperationContext Database StringData BSONObj CollectionOptions::ParseKind bool const BSONObj &idIndex Status
Definition: database_impl.cpp:956
ReadSource
The ReadSource indicates which exteral or provided timestamp to read from for future transactions...
Definition: recovery_unit.h:235
virtual ~Change()
Definition: recovery_unit.h:283
Read from the majority all-commmitted timestamp.
Definition: recovery_unit.h:239
virtual void beginUnitOfWork(OperationContext *opCtx)=0
Marks the beginning of a unit of work.
RecoveryUnit()
Definition: recovery_unit.h:391
virtual ReadSource getTimestampReadSource() const
Definition: recovery_unit.h:262
int & writingInt(int &d)
Declare write intent for an int.
Definition: recovery_unit.h:360
virtual Timestamp getCommitTimestamp()
Definition: recovery_unit.h:214
virtual Status obtainMajorityCommittedSnapshot()
Obtains a majority committed snapshot.
Definition: recovery_unit.h:156
virtual Status setTimestamp(Timestamp timestamp)
Sets a timestamp to assign to future writes in a transaction.
Definition: recovery_unit.h:199
std::shared_ptr< void > data
Definition: ephemeral_for_test_record_store_test.cpp:74
virtual SnapshotId getSnapshotId() const =0
Gets the local SnapshotId.
Read from the last applied timestamp.
Definition: recovery_unit.h:242
virtual void commit(boost::optional< Timestamp > commitTime)=0
A RecoveryUnit is responsible for ensuring that data is persisted.
Definition: recovery_unit.h:51
void onCommit(Callback callback)
Registers a callback to be called if the current WriteUnitOfWork commits.
Definition: recovery_unit.h:328
virtual void abortUnitOfWork()=0
Marks the end of a unit of work and rolls back all changes registered by calls to onRollback or regis...
virtual void commitUnitOfWork()=0
Marks the end of a unit of work and commits all changes registered by calls to onCommit or registerCh...
virtual void prepareUnitOfWork()
Transitions the active unit of work to the "prepared" state.
Definition: recovery_unit.h:91
Read from the last applied timestamp.
Definition: recovery_unit.h:245
Read from the timestamp provided to setTimestampReadSource.
Definition: recovery_unit.h:247
virtual void setIgnorePrepared(bool ignore)
Sets whether or not to ignore prepared transactions if supported by this storage engine.
Definition: recovery_unit.h:101
A Change is an action that is registerChange()'d while a WriteUnitOfWork exists.
Definition: recovery_unit.h:281
virtual void * writingPtr(void *data, size_t len)=0
Declare that the data at [x, x + len) is being written.
Do not read from a timestamp.
Definition: recovery_unit.h:237
virtual ~RecoveryUnit()
Definition: recovery_unit.h:55
virtual void clearCommitTimestamp()
Definition: recovery_unit.h:212
virtual void setPrepareTimestamp(Timestamp timestamp)
Sets a prepare timestamp for the current transaction.
Definition: recovery_unit.h:226
virtual void setCommitTimestamp(Timestamp timestamp)
Sets a timestamp that will be assigned to all future writes on this RecoveryUnit until clearCommitTim...
Definition: recovery_unit.h:210
Definition: snapshot.h:37
virtual boost::optional< Timestamp > getPointInTimeReadTimestamp() const
Returns the Timestamp being used by this recovery unit or boost::none if not reading from a point in ...
Definition: recovery_unit.h:173
virtual void preallocateSnapshot()
Informs the RecoveryUnit that a snapshot will be needed soon, if one was not already established...
Definition: recovery_unit.h:140
Collection *const OperationContext *const opCtx
Definition: collection_impl.cpp:80
virtual bool waitUntilDurable()=0
Waits until all commits that happened before this call are durable in the journal.
virtual void registerChange(Change *change)=0
The RecoveryUnit takes ownership of the change.
virtual void setOrderedCommit(bool orderedCommit)=0
MONGO_DISALLOW_COPYING(RecoveryUnit)
virtual void setTimestampReadSource(ReadSource source, boost::optional< Timestamp > provided=boost::none)
Sets which timestamp to use for read transactions.
Definition: recovery_unit.h:259