diff options
author | Judah Schvimer <judah@mongodb.com> | 2017-07-20 13:28:41 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2017-07-20 13:28:41 -0400 |
commit | 82e6c00b64707a190c13940adf7d0397b2af9cd5 (patch) | |
tree | ac4e267805c06dee7ddf34cc09b392e7a0c7d1ee /src | |
parent | bfc52fd48fa6fe36761ca2b2bd791ed906b56358 (diff) | |
download | mongo-82e6c00b64707a190c13940adf7d0397b2af9cd5.tar.gz |
SERVER-30184 Add functions to storage interface for rollback to
checkpoint
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/storage_interface.h | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 9 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.h | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_mock.h | 9 |
4 files changed, 33 insertions, 1 deletions
diff --git a/src/mongo/db/repl/storage_interface.h b/src/mongo/db/repl/storage_interface.h index ce3059e9e81..d996b099f2f 100644 --- a/src/mongo/db/repl/storage_interface.h +++ b/src/mongo/db/repl/storage_interface.h @@ -275,6 +275,18 @@ public: */ virtual StatusWith<CollectionCount> getCollectionCount(OperationContext* opCtx, const NamespaceString& nss) = 0; + + /** + * 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(OperationContext* opCtx, 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(OperationContext* opCtx, SnapshotName snapshotName) = 0; }; } // namespace repl diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 672a2eb16ea..832b9707722 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -894,6 +894,15 @@ StatusWith<StorageInterface::CollectionCount> StorageInterfaceImpl::getCollectio return collection->numRecords(opCtx); } +void StorageInterfaceImpl::setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) { + opCtx->getServiceContext()->getGlobalStorageEngine()->setStableTimestamp(snapshotName); +} + +void StorageInterfaceImpl::setInitialDataTimestamp(OperationContext* opCtx, + SnapshotName snapshotName) { + opCtx->getServiceContext()->getGlobalStorageEngine()->setInitialDataTimestamp(snapshotName); +} + Status StorageInterfaceImpl::isAdminDbValid(OperationContext* opCtx) { AutoGetDb autoDB(opCtx, "admin", MODE_X); auto adminDb = autoDB.getDb(); diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h index c121806e640..56968146f2b 100644 --- a/src/mongo/db/repl/storage_interface_impl.h +++ b/src/mongo/db/repl/storage_interface_impl.h @@ -134,6 +134,10 @@ public: StatusWith<StorageInterface::CollectionCount> getCollectionCount( OperationContext* opCtx, const NamespaceString& nss) override; + void setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override; + + void setInitialDataTimestamp(OperationContext* opCtx, SnapshotName snapshotName) 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.h b/src/mongo/db/repl/storage_interface_mock.h index 5b9ee48dc43..f443dc95e7e 100644 --- a/src/mongo/db/repl/storage_interface_mock.h +++ b/src/mongo/db/repl/storage_interface_mock.h @@ -244,11 +244,18 @@ public: return 0; } + void setStableTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override { + return; + } + + void setInitialDataTimestamp(OperationContext* opCtx, SnapshotName snapshotName) override { + return; + } + Status isAdminDbValid(OperationContext* opCtx) override { return isAdminDbValidFn(opCtx); }; - // Testing functions. CreateCollectionForBulkFn createCollectionForBulkFn = [](const NamespaceString& nss, |