diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-01-04 12:02:53 -0500 |
---|---|---|
committer | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-01-04 12:02:53 -0500 |
commit | e4fe8b89a9ce01a3571114e9c51a4cdd725fbe1d (patch) | |
tree | 95225bc94c71e2f9439fd47cd3110fbc58f5a959 /src | |
parent | f11fb53bfd42ee53857d263407d9e555b9a1140a (diff) | |
download | mongo-e4fe8b89a9ce01a3571114e9c51a4cdd725fbe1d.tar.gz |
Revert "SERVER-38527 Merge supportsRecoverToStableTimestamp into supportsRecoveryTimestamp"
This reverts commit 804617152c5b4f89c8d54c83bdea90cb2c8541b4.
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/repl/bgsync.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_consistency_markers_impl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_recovery_test.cpp | 25 | ||||
-rw-r--r-- | src/mongo/db/repl/rollback_test_fixture.h | 4 | ||||
-rw-r--r-- | src/mongo/db/repl/rs_rollback.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface.h | 9 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_impl.h | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_mock.h | 4 | ||||
-rw-r--r-- | src/mongo/db/storage/kv/kv_engine.h | 7 | ||||
-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 | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/storage_engine.h | 21 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h | 2 |
16 files changed, 81 insertions, 25 deletions
diff --git a/src/mongo/db/repl/bgsync.cpp b/src/mongo/db/repl/bgsync.cpp index e7096360656..56b548f5a12 100644 --- a/src/mongo/db/repl/bgsync.cpp +++ b/src/mongo/db/repl/bgsync.cpp @@ -629,7 +629,7 @@ void BackgroundSync::_runRollback(OperationContext* opCtx, storageInterface->waitForAllEarlierOplogWritesToBeVisible(opCtx); auto storageEngine = opCtx->getServiceContext()->getStorageEngine(); - if (!forceRollbackViaRefetch.load() && storageEngine->supportsRecoveryTimestamp()) { + if (!forceRollbackViaRefetch.load() && storageEngine->supportsRecoverToStableTimestamp()) { log() << "Rollback using 'recoverToStableTimestamp' method."; _runRollbackViaRecoverToCheckpoint( opCtx, source, &localOplog, storageInterface, getConnection); diff --git a/src/mongo/db/repl/replication_consistency_markers_impl.cpp b/src/mongo/db/repl/replication_consistency_markers_impl.cpp index bb0c7bd2f39..eee665bf67d 100644 --- a/src/mongo/db/repl/replication_consistency_markers_impl.cpp +++ b/src/mongo/db/repl/replication_consistency_markers_impl.cpp @@ -198,7 +198,7 @@ void ReplicationConsistencyMarkersImpl::setMinValid(OperationContext* opCtx, // This method is only used with storage engines that do not support recover to stable // timestamp. As a result, their timestamps do not matter. - invariant(!opCtx->getServiceContext()->getStorageEngine()->supportsRecoveryTimestamp()); + invariant(!opCtx->getServiceContext()->getStorageEngine()->supportsRecoverToStableTimestamp()); update.timestamp = Timestamp(); _updateMinValidDocument(opCtx, update); diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 8fa72491552..c66445f02d2 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -770,7 +770,7 @@ void ReplicationCoordinatorImpl::_startDataReplication(OperationContext* opCtx, void ReplicationCoordinatorImpl::startup(OperationContext* opCtx) { if (!isReplEnabled()) { if (ReplSettings::shouldRecoverFromOplogAsStandalone()) { - if (!_storage->supportsRecoveryTimestamp(opCtx->getServiceContext())) { + if (!_storage->supportsRecoverToStableTimestamp(opCtx->getServiceContext())) { severe() << "Cannot use 'recoverFromOplogAsStandalone' with a storage engine that " "does not support recover to stable timestamp."; fassertFailedNoTrace(50805); diff --git a/src/mongo/db/repl/replication_recovery_test.cpp b/src/mongo/db/repl/replication_recovery_test.cpp index 039f1d5b1b5..d9d2a46f494 100644 --- a/src/mongo/db/repl/replication_recovery_test.cpp +++ b/src/mongo/db/repl/replication_recovery_test.cpp @@ -72,6 +72,16 @@ public: _recoveryTimestamp = recoveryTimestamp; } + bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const override { + stdx::lock_guard<stdx::mutex> lock(_mutex); + return _supportsRecoverToStableTimestamp; + } + + void setSupportsRecoverToStableTimestamp(bool supports) { + stdx::lock_guard<stdx::mutex> lock(_mutex); + _supportsRecoverToStableTimestamp = supports; + } + bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override { stdx::lock_guard<stdx::mutex> lock(_mutex); return _supportsRecoveryTimestamp; @@ -97,6 +107,7 @@ private: Timestamp _initialDataTimestamp = Timestamp::min(); boost::optional<Timestamp> _recoveryTimestamp = boost::none; Timestamp _pointInTimeReadTimestamp = {}; + bool _supportsRecoverToStableTimestamp = true; bool _supportsRecoveryTimestamp = true; }; @@ -543,14 +554,14 @@ void ReplicationRecoveryTest::testRecoveryAppliesDocumentsWhenAppliedThroughIsBe } TEST_F(ReplicationRecoveryTest, RecoveryAppliesDocumentsWhenAppliedThroughIsBehind) { - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); bool hasStableTimestamp = false; bool hasStableCheckpoint = false; testRecoveryAppliesDocumentsWhenAppliedThroughIsBehind(hasStableTimestamp, hasStableCheckpoint); } TEST_F(ReplicationRecoveryTest, RecoveryAppliesDocumentsWhenAppliedThroughIsBehindNoRTT) { - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(false); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(false); bool hasStableTimestamp = false; bool hasStableCheckpoint = false; testRecoveryAppliesDocumentsWhenAppliedThroughIsBehind(hasStableTimestamp, hasStableCheckpoint); @@ -886,7 +897,7 @@ TEST_F(ReplicationRecoveryTest, PrepareTransactionOplogEntryCorrectlyUpdatesConf const auto appliedThrough = OpTime(Timestamp(1, 1), 1); getStorageInterfaceRecovery()->setPointInTimeReadTimestamp(Timestamp(1, 0)); - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); getStorageInterfaceRecovery()->setRecoveryTimestamp(appliedThrough.getTimestamp()); getConsistencyMarkers()->setAppliedThrough(opCtx, appliedThrough); _setUpOplog(opCtx, getStorageInterface(), {1}); @@ -934,7 +945,7 @@ TEST_F(ReplicationRecoveryTest, AbortTransactionOplogEntryCorrectlyUpdatesConfig auto opCtx = getOperationContext(); const auto appliedThrough = OpTime(Timestamp(1, 1), 1); - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); getStorageInterfaceRecovery()->setRecoveryTimestamp(appliedThrough.getTimestamp()); getConsistencyMarkers()->setAppliedThrough(opCtx, appliedThrough); _setUpOplog(opCtx, getStorageInterface(), {1}); @@ -997,7 +1008,7 @@ DEATH_TEST_F(ReplicationRecoveryTest, auto opCtx = getOperationContext(); const auto appliedThrough = OpTime(Timestamp(1, 1), 1); - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); getStorageInterfaceRecovery()->setRecoveryTimestamp(appliedThrough.getTimestamp()); getConsistencyMarkers()->setAppliedThrough(opCtx, appliedThrough); _setUpOplog(opCtx, getStorageInterface(), {1}); @@ -1031,7 +1042,7 @@ TEST_F(ReplicationRecoveryTest, CommitTransactionOplogEntryCorrectlyUpdatesConfi auto opCtx = getOperationContext(); const auto appliedThrough = OpTime(Timestamp(1, 1), 1); - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); getStorageInterfaceRecovery()->setRecoveryTimestamp(appliedThrough.getTimestamp()); getConsistencyMarkers()->setAppliedThrough(opCtx, appliedThrough); _setUpOplog(opCtx, getStorageInterface(), {1}); @@ -1108,7 +1119,7 @@ TEST_F(ReplicationRecoveryTest, // when updating the transactions table during startup recovery when the table already reflects // the committed transaction. const auto appliedThrough = OpTime(Timestamp(2, 2), 1); - getStorageInterfaceRecovery()->setSupportsRecoveryTimestamp(true); + getStorageInterfaceRecovery()->setSupportsRecoverToStableTimestamp(true); getStorageInterfaceRecovery()->setRecoveryTimestamp(appliedThrough.getTimestamp()); getConsistencyMarkers()->setAppliedThrough(opCtx, appliedThrough); _setUpOplog(opCtx, getStorageInterface(), {1}); diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h index a68590760df..958f102a5c2 100644 --- a/src/mongo/db/repl/rollback_test_fixture.h +++ b/src/mongo/db/repl/rollback_test_fixture.h @@ -135,6 +135,10 @@ public: } } + bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const override { + return true; + } + bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override { return true; } diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index f380cbc5db7..cc060b1f82c 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -616,7 +616,7 @@ void checkRbidAndUpdateMinValid(OperationContext* opCtx, // This method is only used with storage engines that do not support recover to stable // timestamp. As a result, the timestamp on the 'appliedThrough' update does not matter. - invariant(!opCtx->getServiceContext()->getStorageEngine()->supportsRecoveryTimestamp()); + invariant(!opCtx->getServiceContext()->getStorageEngine()->supportsRecoverToStableTimestamp()); replicationProcess->getConsistencyMarkers()->clearAppliedThrough(opCtx, {}); replicationProcess->getConsistencyMarkers()->setMinValid(opCtx, minValid); diff --git a/src/mongo/db/repl/storage_interface.h b/src/mongo/db/repl/storage_interface.h index fc092e4c0d3..3e3b47cd098 100644 --- a/src/mongo/db/repl/storage_interface.h +++ b/src/mongo/db/repl/storage_interface.h @@ -371,6 +371,11 @@ public: virtual StatusWith<Timestamp> recoverToStableTimestamp(OperationContext* opCtx) = 0; /** + * Returns whether the storage engine supports "recover to stable timestamp". + */ + virtual bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const = 0; + + /** * Returns whether the storage engine can provide a recovery timestamp. */ virtual bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const = 0; @@ -429,7 +434,7 @@ public: * * Returns `Timestamp::min()` if no stable recovery timestamp has yet been established. * Replication recoverable rollback may not succeed before establishment, and restart will - * require resync. Returns boost::none if `supportsRecoveryTimestamp` returns false. + * require resync. Returns boost::none if `supportsRecoverToStableTimestamp` returns false. */ virtual boost::optional<Timestamp> getLastStableRecoveryTimestamp( ServiceContext* serviceCtx) const = 0; @@ -439,7 +444,7 @@ public: * * Returns a timestamp that is guaranteed to be persisted on disk in a checkpoint. Returns * `Timestamp::min()` if no stable checkpoint has been taken. Returns boost::none if - * `supportsRecoveryTimestamp` returns false or if this is not a persisted data engine. + * `supportsRecoverToStableTimestamp` returns false or if this is not a persisted data engine. * * TODO: delete this in v4.4 (SERVER-36194). */ diff --git a/src/mongo/db/repl/storage_interface_impl.cpp b/src/mongo/db/repl/storage_interface_impl.cpp index 6d6a991bd10..6c4c1adbc57 100644 --- a/src/mongo/db/repl/storage_interface_impl.cpp +++ b/src/mongo/db/repl/storage_interface_impl.cpp @@ -1084,6 +1084,10 @@ StatusWith<Timestamp> StorageInterfaceImpl::recoverToStableTimestamp(OperationCo return opCtx->getServiceContext()->getStorageEngine()->recoverToStableTimestamp(opCtx); } +bool StorageInterfaceImpl::supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const { + return serviceCtx->getStorageEngine()->supportsRecoverToStableTimestamp(); +} + bool StorageInterfaceImpl::supportsRecoveryTimestamp(ServiceContext* serviceCtx) const { return serviceCtx->getStorageEngine()->supportsRecoveryTimestamp(); } @@ -1181,7 +1185,7 @@ void StorageInterfaceImpl::oplogDiskLocRegister(OperationContext* opCtx, boost::optional<Timestamp> StorageInterfaceImpl::getLastStableRecoveryTimestamp( ServiceContext* serviceCtx) const { - if (!supportsRecoveryTimestamp(serviceCtx)) { + if (!supportsRecoverToStableTimestamp(serviceCtx)) { return boost::none; } diff --git a/src/mongo/db/repl/storage_interface_impl.h b/src/mongo/db/repl/storage_interface_impl.h index d0c1a4d754d..a722b053d48 100644 --- a/src/mongo/db/repl/storage_interface_impl.h +++ b/src/mongo/db/repl/storage_interface_impl.h @@ -165,6 +165,8 @@ public: StatusWith<Timestamp> recoverToStableTimestamp(OperationContext* opCtx) override; + bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const override; + bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override; boost::optional<Timestamp> getRecoveryTimestamp(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 33629624588..5189a4303ff 100644 --- a/src/mongo/db/repl/storage_interface_mock.h +++ b/src/mongo/db/repl/storage_interface_mock.h @@ -301,6 +301,10 @@ public: return Status{ErrorCodes::IllegalOperation, "recoverToStableTimestamp not implemented."}; } + bool supportsRecoverToStableTimestamp(ServiceContext* serviceCtx) const override { + return false; + } + bool supportsRecoveryTimestamp(ServiceContext* serviceCtx) const override { return false; } diff --git a/src/mongo/db/storage/kv/kv_engine.h b/src/mongo/db/storage/kv/kv_engine.h index f9312164b2e..126a28af5ee 100644 --- a/src/mongo/db/storage/kv/kv_engine.h +++ b/src/mongo/db/storage/kv/kv_engine.h @@ -342,6 +342,13 @@ public: virtual void setCachePressureForTest(int pressure) {} /** + * See `StorageEngine::supportsRecoverToStableTimestamp` + */ + virtual bool supportsRecoverToStableTimestamp() const { + return false; + } + + /** * See `StorageEngine::supportsRecoveryTimestamp` */ virtual bool supportsRecoveryTimestamp() const { diff --git a/src/mongo/db/storage/kv/kv_storage_engine.cpp b/src/mongo/db/storage/kv/kv_storage_engine.cpp index cd021812ee2..130bf563fe2 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.cpp +++ b/src/mongo/db/storage/kv/kv_storage_engine.cpp @@ -705,6 +705,10 @@ void KVStorageEngine::setCachePressureForTest(int pressure) { return _engine->setCachePressureForTest(pressure); } +bool KVStorageEngine::supportsRecoverToStableTimestamp() const { + return _engine->supportsRecoverToStableTimestamp(); +} + bool KVStorageEngine::supportsRecoveryTimestamp() const { return _engine->supportsRecoveryTimestamp(); } @@ -752,7 +756,7 @@ bool KVStorageEngine::supportsReadConcernMajority() const { } bool KVStorageEngine::supportsPendingDrops() const { - return enableKVPendingDrops && supportsRecoveryTimestamp(); + return enableKVPendingDrops && supportsRecoverToStableTimestamp(); } void KVStorageEngine::clearDropPendingState() { diff --git a/src/mongo/db/storage/kv/kv_storage_engine.h b/src/mongo/db/storage/kv/kv_storage_engine.h index df80e48746f..a200c10106b 100644 --- a/src/mongo/db/storage/kv/kv_storage_engine.h +++ b/src/mongo/db/storage/kv/kv_storage_engine.h @@ -161,6 +161,8 @@ public: virtual void setCachePressureForTest(int pressure) override; + virtual bool supportsRecoverToStableTimestamp() const override; + virtual bool supportsRecoveryTimestamp() const override; virtual StatusWith<Timestamp> recoverToStableTimestamp(OperationContext* opCtx) override; diff --git a/src/mongo/db/storage/storage_engine.h b/src/mongo/db/storage/storage_engine.h index 746f48a8078..f281efd0290 100644 --- a/src/mongo/db/storage/storage_engine.h +++ b/src/mongo/db/storage/storage_engine.h @@ -327,10 +327,17 @@ public: virtual void setJournalListener(JournalListener* jl) = 0; /** - * Returns whether the storage engine can provide a timestamp that can be used for recovering - * to a stable timestamp. If the storage engine supports "recover to stable timestamp" but does - * not currently have a stable timestamp, then StorageEngine::recoverToStableTimestamp() will - * return a bad status. + * Returns whether the storage engine supports "recover to stable timestamp". Returns true + * if the storage engine supports "recover to stable timestamp" but does not currently have + * a stable timestamp. In that case StorageEngine::recoverToStableTimestamp() will return + * a bad status. + */ + virtual bool supportsRecoverToStableTimestamp() const { + return false; + } + + /** + * Returns whether the storage engine can provide a recovery timestamp. */ virtual bool supportsRecoveryTimestamp() const { return false; @@ -370,7 +377,7 @@ public: * * If successful, returns the timestamp that the storage engine recovered to. * - * fasserts if StorageEngine::supportsRecoveryTimestamp() would return + * fasserts if StorageEngine::supportsRecoverToStableTimestamp() would return * false. Returns a bad status if there is no stable timestamp to recover to. * * It is illegal to call this concurrently with `setStableTimestamp` or @@ -383,7 +390,7 @@ public: /** * Returns the stable timestamp that the storage engine recovered to on startup. If the * recovery point was not stable, returns "none". - * fasserts if StorageEngine::supportsRecoveryTimestamp() would return false. + * fasserts if StorageEngine::supportsRecoverToStableTimestamp() would return false. */ virtual boost::optional<Timestamp> getRecoveryTimestamp() const { MONGO_UNREACHABLE; @@ -395,7 +402,7 @@ public: * durable engines, it is also the guaranteed minimum stable recovery point on server restart * after crash or shutdown. * - * fasserts if StorageEngine::supportsRecoveryTimestamp() would return false. Returns + * fasserts if StorageEngine::supportsRecoverToStableTimestamp() would return false. Returns * boost::none if the recovery time has not yet been established. Replication recoverable * rollback may not succeed before establishment, and restart will require resync. */ diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 3e471d4a962..a3c62668e37 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1657,13 +1657,17 @@ void WiredTigerKVEngine::setInitialDataTimestamp(Timestamp initialDataTimestamp) _initialDataTimestamp.store(initialDataTimestamp.asULL()); } -bool WiredTigerKVEngine::supportsRecoveryTimestamp() const { +bool WiredTigerKVEngine::supportsRecoverToStableTimestamp() const { if (!_keepDataHistory) { return false; } return true; } +bool WiredTigerKVEngine::supportsRecoveryTimestamp() const { + return true; +} + bool WiredTigerKVEngine::_canRecoverToStableTimestamp() const { static const std::uint64_t allowUnstableCheckpointsSentinel = static_cast<std::uint64_t>(Timestamp::kAllowUnstableCheckpointsSentinel.asULL()); @@ -1674,7 +1678,7 @@ bool WiredTigerKVEngine::_canRecoverToStableTimestamp() const { } StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationContext* opCtx) { - if (!supportsRecoveryTimestamp()) { + if (!supportsRecoverToStableTimestamp()) { severe() << "WiredTiger is configured to not support recover to a stable timestamp"; fassertFailed(50665); } @@ -1761,7 +1765,7 @@ boost::optional<Timestamp> WiredTigerKVEngine::getRecoveryTimestamp() const { } boost::optional<Timestamp> WiredTigerKVEngine::getLastStableRecoveryTimestamp() const { - if (!supportsRecoveryTimestamp()) { + if (!supportsRecoverToStableTimestamp()) { severe() << "WiredTiger is configured to not support recover to a stable timestamp"; fassertFailed(50770); } diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 30f1ec78d91..8e6b2995d8a 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -211,6 +211,8 @@ public: */ void setOldestTimestamp(Timestamp newOldestTimestamp, bool force) override; + bool supportsRecoverToStableTimestamp() const override; + bool supportsRecoveryTimestamp() const override; StatusWith<Timestamp> recoverToStableTimestamp(OperationContext* opCtx) override; |