summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/recovery_unit.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage/recovery_unit.h')
-rw-r--r--src/mongo/db/storage/recovery_unit.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h
index a67d1f090f5..04101ad66dc 100644
--- a/src/mongo/db/storage/recovery_unit.h
+++ b/src/mongo/db/storage/recovery_unit.h
@@ -129,9 +129,12 @@ public:
* Marks the beginning of a unit of work. Each call must be matched with exactly one call to
* either commitUnitOfWork or abortUnitOfWork.
*
+ * When called with readOnly=true, no unit of work is started. Calling commitUnitOfWork or
+ * abortUnitOfWork will invariant.
+ *
* Should be called through WriteUnitOfWork rather than directly.
*/
- virtual void beginUnitOfWork(OperationContext* opCtx) = 0;
+ void beginUnitOfWork(bool readOnly);
/**
* Marks the end of a unit of work and commits all changes registered by calls to onCommit or
@@ -139,10 +142,7 @@ public:
*
* Should be called through WriteUnitOfWork rather than directly.
*/
- void commitUnitOfWork() {
- doCommitUnitOfWork();
- assignNextSnapshotId();
- }
+ void commitUnitOfWork();
/**
* Marks the end of a unit of work and rolls back all changes registered by calls to onRollback
@@ -151,10 +151,14 @@ public:
*
* Should be called through WriteUnitOfWork rather than directly.
*/
- void abortUnitOfWork() {
- doAbortUnitOfWork();
- assignNextSnapshotId();
- }
+ void abortUnitOfWork();
+
+ /**
+ * Cleans up any state set for this unit of work.
+ *
+ * Should be called through WriteUnitOfWork rather than directly.
+ */
+ void endReadOnlyUnitOfWork();
/**
* Transitions the active unit of work to the "prepared" state. Must be called after
@@ -803,6 +807,7 @@ private:
// Sets the snapshot associated with this RecoveryUnit to a new globally unique id number.
void assignNextSnapshotId();
+ virtual void doBeginUnitOfWork() = 0;
virtual void doAbandonSnapshot() = 0;
virtual void doCommitUnitOfWork() = 0;
virtual void doAbortUnitOfWork() = 0;
@@ -816,6 +821,7 @@ private:
std::unique_ptr<Change> _changeForCatalogVisibility;
State _state = State::kInactive;
uint64_t _mySnapshotId;
+ bool _readOnly = false;
};
/**