diff options
author | Judah Schvimer <judah@mongodb.com> | 2018-03-12 14:47:40 -0400 |
---|---|---|
committer | Judah Schvimer <judah@mongodb.com> | 2018-03-12 14:47:40 -0400 |
commit | b1102c617e04ff751d702435f9d4521727e579e1 (patch) | |
tree | 0878af2c87cc855f833393c4323b623e6e1b3e31 /src/mongo/db/storage | |
parent | ccaad4fb968b8a21a697c00362de5bb618bbb184 (diff) | |
download | mongo-b1102c617e04ff751d702435f9d4521727e579e1.tar.gz |
SERVER-33292 Have storage dictate where replication recovery should begin playing oplog from
Diffstat (limited to 'src/mongo/db/storage')
-rw-r--r-- | src/mongo/db/storage/kv/kv_engine.h | 9 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/kv_storage_engine.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/kv_storage_engine.h | 4 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_engine.h | 16 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 11 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h | 4 |
6 files changed, 42 insertions, 8 deletions
diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h index d02fc9e9955..4d5f65f3418 100644 --- a/src/mongo/db/storage/kv/kv_engine.h +++ b/src/mongo/db/storage/kv/kv_engine.h @@ -271,11 +271,18 @@ public: /** * See `StorageEngine::recoverToStableTimestamp` */ - virtual Status recoverToStableTimestamp() { + virtual StatusWith<Timestamp> recoverToStableTimestamp() { fassertFailed(50664); } /** + * See `StorageEngine::getRecoveryTimestamp` + */ + virtual boost::optional<Timestamp> getRecoveryTimestamp() const { + MONGO_UNREACHABLE; + } + + /** * See `StorageEngine::supportsReadConcernSnapshot` */ virtual bool supportsReadConcernSnapshot() const { diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp index b7a64f30d94..19cbded2aec 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.cpp +++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp @@ -587,10 +587,14 @@ bool KVStorageEngine::supportsRecoverToStableTimestamp() const { return _engine->supportsRecoverToStableTimestamp(); } -Status KVStorageEngine::recoverToStableTimestamp() { +StatusWith<Timestamp> KVStorageEngine::recoverToStableTimestamp() { return _engine->recoverToStableTimestamp(); } +boost::optional<Timestamp> KVStorageEngine::getRecoveryTimestamp() const { + return _engine->getRecoveryTimestamp(); +} + bool KVStorageEngine::supportsReadConcernSnapshot() const { return _engine->supportsReadConcernSnapshot(); } diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h index 96f064d2ce5..6d1f5b3a489 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.h +++ b/src/mongo/db/storage/kv/kv_storage_engine.h @@ -121,7 +121,9 @@ public: virtual bool supportsRecoverToStableTimestamp() const override; - virtual Status recoverToStableTimestamp() override; + virtual StatusWith<Timestamp> recoverToStableTimestamp() override; + + virtual boost::optional<Timestamp> getRecoveryTimestamp() const override; bool supportsReadConcernSnapshot() const final; diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index cd881198f03..c3b02246013 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -320,8 +320,9 @@ public: * used should be one provided by StorageEngine::setStableTimestamp(). * * The "local" database is exempt and should not roll back any state except for - * "local.replset.minvalid" and "local.replset.checkpointTimestamp" which must roll back to - * the last stable timestamp. + * "local.replset.minvalid" which must roll back to the last stable timestamp. + * + * If successful, returns the timestamp that the storage engine recovered to. * * fasserts if StorageEngine::supportsRecoverToStableTimestamp() would return * false. Returns a bad status if there is no stable timestamp to recover to. @@ -329,11 +330,20 @@ public: * It is illegal to call this concurrently with `setStableTimestamp` or * `setInitialDataTimestamp`. */ - virtual Status recoverToStableTimestamp() { + virtual StatusWith<Timestamp> recoverToStableTimestamp() { fassertFailed(40547); } /** + * Returns the stable timestamp that the storage engine recovered to on startup. If the + * recovery point was not stable, returns "none". + * fasserts if StorageEngine::supportsRecoverToStableTimestamp() would return false. + */ + virtual boost::optional<Timestamp> getRecoveryTimestamp() const { + MONGO_UNREACHABLE; + } + + /** * 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. */ diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index a365149462e..5f699c1ff48 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1123,7 +1123,7 @@ bool WiredTigerKVEngine::supportsRecoverToStableTimestamp() const { return true; } -Status WiredTigerKVEngine::recoverToStableTimestamp() { +StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp() { if (!supportsRecoverToStableTimestamp()) { severe() << "WiredTiger is configured to not support recover to a stable timestamp"; fassertFailed(50665); @@ -1143,6 +1143,15 @@ Status WiredTigerKVEngine::recoverToStableTimestamp() { "WT does not support recover to stable timestamp yet."); } +boost::optional<Timestamp> WiredTigerKVEngine::getRecoveryTimestamp() const { + if (!supportsRecoverToStableTimestamp()) { + severe() << "WiredTiger is configured to not support recover to a stable timestamp"; + fassertFailed(50745); + } + + return boost::none; +} + bool WiredTigerKVEngine::supportsReadConcernSnapshot() const { return true; } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 39e6c00a85a..0d25901d6fc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -176,7 +176,9 @@ public: virtual bool supportsRecoverToStableTimestamp() const override; - virtual Status recoverToStableTimestamp() override; + virtual StatusWith<Timestamp> recoverToStableTimestamp() override; + + virtual boost::optional<Timestamp> getRecoveryTimestamp() const override; bool supportsReadConcernSnapshot() const final; |