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/initial_syncer.cpp8
-rw-r--r--src/mongo/db/repl/initial_syncer_test.cpp6
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp5
-rw-r--r--src/mongo/db/repl/replication_recovery.cpp10
-rw-r--r--src/mongo/db/repl/replication_recovery_test.cpp2
-rw-r--r--src/mongo/db/repl/rollback_impl.cpp4
-rw-r--r--src/mongo/db/repl/rollback_impl_test.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface.h7
-rw-r--r--src/mongo/db/repl/storage_interface_impl.cpp12
-rw-r--r--src/mongo/db/repl/storage_interface_impl.h6
-rw-r--r--src/mongo/db/repl/storage_interface_mock.cpp4
-rw-r--r--src/mongo/db/repl/storage_interface_mock.h6
12 files changed, 35 insertions, 39 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp
index 2ba93cd4bbe..94997d45293 100644
--- a/src/mongo/db/repl/initial_syncer.cpp
+++ b/src/mongo/db/repl/initial_syncer.cpp
@@ -395,10 +395,10 @@ void InitialSyncer::_setUp_inlock(OperationContext* opCtx, std::uint32_t initial
// 'opCtx' is passed through from startup().
_replicationProcess->getConsistencyMarkers()->setInitialSyncFlag(opCtx);
- auto storageEngine = opCtx->getServiceContext()->getGlobalStorageEngine();
- _storage->setInitialDataTimestamp(storageEngine,
+ auto serviceCtx = opCtx->getServiceContext();
+ _storage->setInitialDataTimestamp(serviceCtx,
SnapshotName(Timestamp::kAllowUnstableCheckpointsSentinel));
- _storage->setStableTimestamp(storageEngine, SnapshotName::min());
+ _storage->setStableTimestamp(serviceCtx, SnapshotName::min());
LOG(1) << "Creating oplogBuffer.";
_oplogBuffer = _dataReplicatorExternalState->makeInitialSyncOplogBuffer(opCtx);
@@ -421,7 +421,7 @@ void InitialSyncer::_tearDown_inlock(OperationContext* opCtx,
return;
}
- _storage->setInitialDataTimestamp(opCtx->getServiceContext()->getGlobalStorageEngine(),
+ _storage->setInitialDataTimestamp(opCtx->getServiceContext(),
SnapshotName(lastApplied.getValue().opTime.getTimestamp()));
_replicationProcess->getConsistencyMarkers()->clearInitialSyncFlag(opCtx);
_opts.setMyLastOptime(lastApplied.getValue().opTime);
diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp
index dbc94f0095e..29acdf41793 100644
--- a/src/mongo/db/repl/initial_syncer_test.cpp
+++ b/src/mongo/db/repl/initial_syncer_test.cpp
@@ -627,9 +627,9 @@ TEST_F(InitialSyncerTest, StartupSetsInitialDataTimestampAndStableTimestampOnSuc
auto opCtx = makeOpCtx();
// Set initial data timestamp forward first.
- auto storageEngine = opCtx.get()->getServiceContext()->getGlobalStorageEngine();
- _storageInterface->setInitialDataTimestamp(storageEngine, SnapshotName(Timestamp(5, 5)));
- _storageInterface->setStableTimestamp(storageEngine, SnapshotName(Timestamp(6, 6)));
+ auto serviceCtx = opCtx.get()->getServiceContext();
+ _storageInterface->setInitialDataTimestamp(serviceCtx, SnapshotName(Timestamp(5, 5)));
+ _storageInterface->setStableTimestamp(serviceCtx, SnapshotName(Timestamp(6, 6)));
ASSERT_OK(initialSyncer->startup(opCtx.get(), maxAttempts));
ASSERT_TRUE(initialSyncer->isActive());
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 9b6e53ef76f..35bb765f8f5 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2326,7 +2326,7 @@ Status ReplicationCoordinatorImpl::processReplSetInitiate(OperationContext* opCt
// Sets the initial data timestamp on the storage engine so it can assign a timestamp
// to data on disk. We do this after writing the "initiating set" oplog entry.
auto initialDataTS = SnapshotName(lastAppliedOpTime.getTimestamp().asULL());
- _storage->setInitialDataTimestamp(getServiceContext()->getGlobalStorageEngine(), initialDataTS);
+ _storage->setInitialDataTimestamp(getServiceContext(), initialDataTS);
_finishReplSetInitiate(newConfig, myIndex.getValue());
@@ -3016,8 +3016,7 @@ void ReplicationCoordinatorImpl::_setStableTimestampForStorage_inlock() {
if (stableTimestamp) {
LOG(2) << "Setting replication's stable timestamp to " << stableTimestamp.value();
- auto storageEngine = getServiceContext()->getGlobalStorageEngine();
- _storage->setStableTimestamp(storageEngine, SnapshotName(stableTimestamp.get()));
+ _storage->setStableTimestamp(getServiceContext(), SnapshotName(stableTimestamp.get()));
_cleanupStableTimestampCandidates(&_stableTimestampCandidates, stableTimestamp.get());
}
diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp
index 8042674d358..7a7597642eb 100644
--- a/src/mongo/db/repl/replication_recovery.cpp
+++ b/src/mongo/db/repl/replication_recovery.cpp
@@ -92,9 +92,8 @@ void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx) try {
if (!checkpointTimestamp.isNull()) {
// If we have a checkpoint timestamp, we set the initial data timestamp now so that
// the operations we apply below can be given the proper timestamps.
- _storageInterface->setInitialDataTimestamp(
- opCtx->getServiceContext()->getGlobalStorageEngine(),
- SnapshotName(checkpointTimestamp));
+ _storageInterface->setInitialDataTimestamp(opCtx->getServiceContext(),
+ SnapshotName(checkpointTimestamp));
}
// If we don't have a checkpoint timestamp, then we are either not running a storage engine
@@ -105,9 +104,8 @@ void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx) try {
// oplog.
ON_BLOCK_EXIT([&] {
if (checkpointTimestamp.isNull() && topOfOplog) {
- _storageInterface->setInitialDataTimestamp(
- opCtx->getServiceContext()->getGlobalStorageEngine(),
- SnapshotName(topOfOplog->getTimestamp()));
+ _storageInterface->setInitialDataTimestamp(opCtx->getServiceContext(),
+ SnapshotName(topOfOplog->getTimestamp()));
}
});
diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp
index 5bf77b76fd0..79300eebf16 100644
--- a/src/mongo/db/repl/replication_recovery_test.cpp
+++ b/src/mongo/db/repl/replication_recovery_test.cpp
@@ -54,7 +54,7 @@ const NamespaceString testNs("a.a");
class StorageInterfaceRecovery : public StorageInterfaceImpl {
public:
- void setInitialDataTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override {
+ void setInitialDataTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override {
stdx::lock_guard<stdx::mutex> lock(_mutex);
_initialDataTimestamp = snapshotName;
}
diff --git a/src/mongo/db/repl/rollback_impl.cpp b/src/mongo/db/repl/rollback_impl.cpp
index 8e55421101b..0d8de17e588 100644
--- a/src/mongo/db/repl/rollback_impl.cpp
+++ b/src/mongo/db/repl/rollback_impl.cpp
@@ -115,10 +115,10 @@ Status RollbackImpl::runRollback(OperationContext* opCtx) {
}
// Recover to the stable timestamp while holding the global exclusive lock.
- auto storageEngine = opCtx->getServiceContext()->getGlobalStorageEngine();
+ auto serviceCtx = opCtx->getServiceContext();
{
Lock::GlobalWrite globalWrite(opCtx);
- status = _storageInterface->recoverToStableTimestamp(storageEngine);
+ status = _storageInterface->recoverToStableTimestamp(serviceCtx);
if (!status.isOK()) {
return status;
}
diff --git a/src/mongo/db/repl/rollback_impl_test.cpp b/src/mongo/db/repl/rollback_impl_test.cpp
index 0c5aa79d773..07db1736d3b 100644
--- a/src/mongo/db/repl/rollback_impl_test.cpp
+++ b/src/mongo/db/repl/rollback_impl_test.cpp
@@ -47,7 +47,7 @@ NamespaceString nss("local.oplog.rs");
class StorageInterfaceRollback : public StorageInterfaceImpl {
public:
- void setStableTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override {
+ void setStableTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override {
stdx::lock_guard<stdx::mutex> lock(_mutex);
_stableTimestamp = Timestamp(snapshotName.asU64());
}
@@ -56,7 +56,7 @@ public:
* If '_recoverToTimestampStatus' is non-empty, returns it. If '_recoverToTimestampStatus' is
* empty, updates '_currTimestamp' to be equal to '_stableTimestamp' and returns an OK status.
*/
- Status recoverToStableTimestamp(StorageEngine* storageEngine) override {
+ Status recoverToStableTimestamp(ServiceContext* serviceCtx) override {
stdx::lock_guard<stdx::mutex> lock(_mutex);
if (_recoverToTimestampStatus) {
return _recoverToTimestampStatus.get();
diff --git a/src/mongo/db/repl/storage_interface.h b/src/mongo/db/repl/storage_interface.h
index 8e37194b7a7..764bdcadad3 100644
--- a/src/mongo/db/repl/storage_interface.h
+++ b/src/mongo/db/repl/storage_interface.h
@@ -280,14 +280,13 @@ public:
* Sets the highest timestamp at which the storage engine is allowed to take a checkpoint.
* This timestamp can never decrease, and thus should be a timestamp that can never roll back.
*/
- virtual void setStableTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) = 0;
+ virtual void setStableTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) = 0;
/**
* Tells the storage engine the timestamp of the data at startup. This is necessary because
* timestamps are not persisted in the storage layer.
*/
- virtual void setInitialDataTimestamp(StorageEngine* storageEngine,
- SnapshotName snapshotName) = 0;
+ virtual void setInitialDataTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) = 0;
/**
* Reverts the state of all database data to the last stable timestamp.
@@ -298,7 +297,7 @@ public:
*
* The 'stable' timestamp is set by calling StorageInterface::setStableTimestamp.
*/
- virtual Status recoverToStableTimestamp(StorageEngine* storageEngine) = 0;
+ virtual Status recoverToStableTimestamp(ServiceContext* serviceCtx) = 0;
};
} // namespace repl
diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp
index 1c5fe3f719f..d6c66ad51d9 100644
--- a/src/mongo/db/repl/storage_interface_impl.cpp
+++ b/src/mongo/db/repl/storage_interface_impl.cpp
@@ -894,18 +894,18 @@ StatusWith<StorageInterface::CollectionCount> StorageInterfaceImpl::getCollectio
return collection->numRecords(opCtx);
}
-void StorageInterfaceImpl::setStableTimestamp(StorageEngine* storageEngine,
+void StorageInterfaceImpl::setStableTimestamp(ServiceContext* serviceCtx,
SnapshotName snapshotName) {
- storageEngine->setStableTimestamp(snapshotName);
+ serviceCtx->getGlobalStorageEngine()->setStableTimestamp(snapshotName);
}
-void StorageInterfaceImpl::setInitialDataTimestamp(StorageEngine* storageEngine,
+void StorageInterfaceImpl::setInitialDataTimestamp(ServiceContext* serviceCtx,
SnapshotName snapshotName) {
- storageEngine->setInitialDataTimestamp(snapshotName);
+ serviceCtx->getGlobalStorageEngine()->setInitialDataTimestamp(snapshotName);
}
-Status StorageInterfaceImpl::recoverToStableTimestamp(StorageEngine* storageEngine) {
- return storageEngine->recoverToStableTimestamp();
+Status StorageInterfaceImpl::recoverToStableTimestamp(ServiceContext* serviceCtx) {
+ return serviceCtx->getGlobalStorageEngine()->recoverToStableTimestamp();
}
Status StorageInterfaceImpl::isAdminDbValid(OperationContext* opCtx) {
diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h
index 49062980b69..1b48fe6c87d 100644
--- a/src/mongo/db/repl/storage_interface_impl.h
+++ b/src/mongo/db/repl/storage_interface_impl.h
@@ -134,11 +134,11 @@ public:
StatusWith<StorageInterface::CollectionCount> getCollectionCount(
OperationContext* opCtx, const NamespaceString& nss) override;
- void setStableTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override;
+ void setStableTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override;
- void setInitialDataTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override;
+ void setInitialDataTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override;
- Status recoverToStableTimestamp(StorageEngine* storageEngine) override;
+ Status recoverToStableTimestamp(ServiceContext* serviceCtx) override;
/**
* Checks that the "admin" database contains a supported version of the auth data schema.
diff --git a/src/mongo/db/repl/storage_interface_mock.cpp b/src/mongo/db/repl/storage_interface_mock.cpp
index 8cb9570ad20..aee45106f92 100644
--- a/src/mongo/db/repl/storage_interface_mock.cpp
+++ b/src/mongo/db/repl/storage_interface_mock.cpp
@@ -68,13 +68,13 @@ Status StorageInterfaceMock::incrementRollbackID(OperationContext* opCtx) {
return Status::OK();
}
-void StorageInterfaceMock::setStableTimestamp(StorageEngine* storageEngine,
+void StorageInterfaceMock::setStableTimestamp(ServiceContext* serviceCtx,
SnapshotName snapshotName) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
_stableTimestamp = snapshotName;
}
-void StorageInterfaceMock::setInitialDataTimestamp(StorageEngine* storageEngine,
+void StorageInterfaceMock::setInitialDataTimestamp(ServiceContext* serviceCtx,
SnapshotName snapshotName) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
_initialDataTimestamp = snapshotName;
diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h
index 35f813e2f63..a9b33a8b5c3 100644
--- a/src/mongo/db/repl/storage_interface_mock.h
+++ b/src/mongo/db/repl/storage_interface_mock.h
@@ -244,15 +244,15 @@ public:
return 0;
}
- void setStableTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override;
+ void setStableTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override;
- void setInitialDataTimestamp(StorageEngine* storageEngine, SnapshotName snapshotName) override;
+ void setInitialDataTimestamp(ServiceContext* serviceCtx, SnapshotName snapshotName) override;
SnapshotName getStableTimestamp() const;
SnapshotName getInitialDataTimestamp() const;
- Status recoverToStableTimestamp(StorageEngine* storageEngine) override {
+ Status recoverToStableTimestamp(ServiceContext* serviceCtx) override {
return Status{ErrorCodes::IllegalOperation, "recoverToStableTimestamp not implemented."};
}