summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r--src/mongo/db/repl/replication_recovery.cpp10
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp15
-rw-r--r--src/mongo/db/repl/rollback_test_fixture.h4
-rw-r--r--src/mongo/db/repl/storage_interface.h5
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface_impl.h2
-rw-r--r--src/mongo/db/repl/storage_interface_mock.h4
7 files changed, 36 insertions, 8 deletions
diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp
index b9dbc665155..a41f8b81919 100644
--- a/src/mongo/db/repl/replication_recovery.cpp
+++ b/src/mongo/db/repl/replication_recovery.cpp
@@ -247,10 +247,9 @@ void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx,
// recovery timestamp. If the storage engine returns a timestamp, we recover from that point.
// However, if the storage engine returns "none", the storage engine does not have a stable
// checkpoint and we must recover from an unstable checkpoint instead.
- const bool supportsRecoverToStableTimestamp =
- _storageInterface->supportsRecoverToStableTimestamp(opCtx->getServiceContext());
- if (!stableTimestamp &&
- (supportsRecoverToStableTimestamp || !serverGlobalParams.enableMajorityReadConcern)) {
+ const bool supportsRecoveryTimestamp =
+ _storageInterface->supportsRecoveryTimestamp(opCtx->getServiceContext());
+ if (!stableTimestamp && supportsRecoveryTimestamp) {
stableTimestamp = _storageInterface->getRecoveryTimestamp(opCtx->getServiceContext());
}
@@ -262,8 +261,7 @@ void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx,
<< appliedThrough.toString());
if (stableTimestamp) {
- invariant(supportsRecoverToStableTimestamp ||
- !serverGlobalParams.enableMajorityReadConcern);
+ invariant(supportsRecoveryTimestamp);
_recoverFromStableTimestamp(opCtx, *stableTimestamp, appliedThrough, topOfOplog);
} else {
_recoverFromUnstableCheckpoint(opCtx, appliedThrough, topOfOplog);
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index 1a7cc5f8be8..cd5e072a513 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -78,11 +78,22 @@ public:
_supportsRecoverToStableTimestamp = supports;
}
+ bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ return _supportsRecoveryTimestamp;
+ }
+
+ void setSupportsRecoveryTimestamp(bool supports) {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ _supportsRecoveryTimestamp = supports;
+ }
+
private:
mutable stdx::mutex _mutex;
Timestamp _initialDataTimestamp = Timestamp::min();
boost::optional<Timestamp> _recoveryTimestamp = boost::none;
bool _supportsRecoverToStableTimestamp = true;
+ bool _supportsRecoveryTimestamp = true;
};
class ReplicationRecoveryTest : public ServiceContextMongoDTest {
@@ -357,9 +368,9 @@ DEATH_TEST_F(ReplicationRecoveryTest,
}
DEATH_TEST_F(ReplicationRecoveryTest,
- RecoveryInvariantsIfStableTimestampAndDoesNotSupportRTT,
+ RecoveryInvariantsIfStableTimestampAndDoesNotSupportRecoveryTimestamp,
"Invariant failure") {
- getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(false);
+ getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(false);
ReplicationRecoveryImpl recovery(getStorageInterface(), getConsistencyMarkers());
auto opCtx = getOperationContext();
diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h
index 8d31c63564f..26c568db2c4 100644
--- a/src/mongo/db/repl/rollback_test_fixture.h
+++ b/src/mongo/db/repl/rollback_test_fixture.h
@@ -137,6 +137,10 @@ public:
return true;
}
+ bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override {
+ return true;
+ }
+
void setRecoverToTimestampStatus(Status status) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
_recoverToTimestampStatus = status;
diff --git a/src/mongo/db/repl/storage_interface.h b/src/mongo/db/repl/storage_interface.h
index 5b526456752..2d9e3518dde 100644
--- a/src/mongo/db/repl/storage_interface.h
+++ b/src/mongo/db/repl/storage_interface.h
@@ -374,6 +374,11 @@ public:
virtual bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const = 0;
/**
+ * Returns whether the storage engine can provide a recovery timestamp.
+ */
+ virtual bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const = 0;
+
+ /**
* Returns the stable timestamp that the storage engine recovered to on startup. If the
* recovery point was not stable, returns "none".
*/
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 93d93a319d4..6497c9aa36e 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -1062,6 +1062,10 @@ bool StorageInterfaceImpl::supportsRecoverToStableTimestamp(ServiceContext* serv
return serviceCtx->getStorageEngine()->supportsRecoverToStableTimestamp();
}
+bool StorageInterfaceImpl::supportsRecoveryTimestamp(ServiceContext* serviceCtx) const {
+ return serviceCtx->getStorageEngine()->supportsRecoveryTimestamp();
+}
+
boost::optional<Timestamp> StorageInterfaceImpl::getRecoveryTimestamp(
ServiceContext* serviceCtx) const {
return serviceCtx->getStorageEngine()->getRecoveryTimestamp();
diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h
index 17555669b00..08e8f3b0dbf 100644
--- a/src/mongo/db/repl/storage_interface_impl.h
+++ b/src/mongo/db/repl/storage_interface_impl.h
@@ -166,6 +166,8 @@ public:
bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const override;
+ bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override;
+
boost::optional<Timestamp> getRecoveryTimestamp(ServiceContext* serviceCtx) const override;
bool supportsDocLocking(ServiceContext* serviceCtx) const override;
diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h
index 41b3d71c916..a3bf9f960ab 100644
--- a/src/mongo/db/repl/storage_interface_mock.h
+++ b/src/mongo/db/repl/storage_interface_mock.h
@@ -303,6 +303,10 @@ public:
return false;
}
+ bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override {
+ return false;
+ }
+
boost::optional<Timestamp> getRecoveryTimestamp(ServiceContext* serviceCtx) const override {
return boost::none;
}