summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r--src/mongo/db/storage/recovery_unit.h8
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp2
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp5
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h1
4 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/storage/recovery_unit.h b/src/mongo/db/storage/recovery_unit.h
index fe9ed473163..5ac712b4887 100644
--- a/src/mongo/db/storage/recovery_unit.h
+++ b/src/mongo/db/storage/recovery_unit.h
@@ -85,6 +85,14 @@ public:
virtual void abandonSnapshot() = 0;
/**
+ * Informs the RecoveryUnit that a snapshot will be needed soon, if one was not already
+ * established. This specifically allows the storage engine to preallocate any required
+ * transaction resources while minimizing the critical section between generating a new
+ * timestamp and setting it using setTimestamp.
+ */
+ virtual void prepareSnapshot() {}
+
+ /**
* Informs this RecoveryUnit that all future reads through it should be from a snapshot
* marked as Majority Committed. Snapshots should still be separately acquired and newer
* committed snapshots should be used if available whenever implementations would normally
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 232ecdcdbb7..336b7d9d486 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -1675,7 +1675,7 @@ void WiredTigerRecordStore::cappedTruncateAfter(OperationContext* opCtx,
Status WiredTigerRecordStore::oplogDiskLocRegister(OperationContext* opCtx,
const Timestamp& opTime) {
- // This starts a new transaction and gives it a timestamp.
+ // This labels the current transaction with a timestamp.
// This is required for oplog visibility to work correctly, as WiredTiger uses the transaction
// list to determine where there are holes in the oplog.
return opCtx->recoveryUnit()->setTimestamp(SnapshotName(opTime));
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
index 8be67c449a5..54db183fe36 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.cpp
@@ -178,6 +178,11 @@ void WiredTigerRecoveryUnit::abandonSnapshot() {
_areWriteUnitOfWorksBanned = false;
}
+void WiredTigerRecoveryUnit::prepareSnapshot() {
+ // Begin a new transaction, if one is not already started.
+ getSession();
+}
+
void* WiredTigerRecoveryUnit::writingPtr(void* data, size_t len) {
// This API should not be used for anything other than the MMAP V1 storage engine
MONGO_UNREACHABLE;
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
index 397d17a142b..a1040952dc3 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h
@@ -70,6 +70,7 @@ public:
void registerChange(Change* change) override;
void abandonSnapshot() override;
+ void prepareSnapshot() override;
Status setReadFromMajorityCommittedSnapshot() override;
bool isReadingFromMajorityCommittedSnapshot() const override {