diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp | 58 |
1 files changed, 15 insertions, 43 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 244a11ac071..66f419dd63e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -143,12 +143,7 @@ boost::filesystem::path getOngoingBackupPath() { } // namespace -bool WiredTigerFileVersion::shouldDowngrade(bool readOnly, bool hasRecoveryTimestamp) { - if (readOnly) { - // A read-only state must not have upgraded. Nor could it downgrade. - return false; - } - +bool WiredTigerFileVersion::shouldDowngrade(bool hasRecoveryTimestamp) { const auto replCoord = repl::ReplicationCoordinator::get(getGlobalServiceContext()); if (replCoord && replCoord->getMemberState().arbiter()) { // SERVER-35361: Arbiters will no longer downgrade their data files. To downgrade @@ -304,8 +299,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, size_t maxHistoryFileSizeMB, bool durable, bool ephemeral, - bool repair, - bool readOnly) + bool repair) : _clockSource(cs), _oplogManager(std::make_unique<WiredTigerOplogManager>()), _canonicalName(canonicalName), @@ -314,7 +308,6 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, _durable(durable), _ephemeral(ephemeral), _inRepairMode(repair), - _readOnly(readOnly), _keepDataHistory(serverGlobalParams.enableMajorityReadConcern) { _pinnedOplogTimestamp.store(Timestamp::max().asULL()); boost::filesystem::path journalPath = path; @@ -359,8 +352,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, // The setting may have a later setting override it if not using the journal. We make it // unconditional here because even nojournal may need this setting if it is a transition // from using the journal. - ss << "log=(enabled=true,remove=" << (_readOnly ? "false" : "true") - << ",path=journal,compressor="; + ss << "log=(enabled=true,remove=true,path=journal,compressor="; ss << wiredTigerGlobalOptions.journalCompressor << "),"; ss << "builtin_extension_config=(zstd=(compression_level=" << wiredTigerGlobalOptions.zstdCompressorLevel << ")),"; @@ -530,7 +522,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, setOldestActiveTransactionTimestampCallback( [](Timestamp) { return StatusWith(boost::make_optional(Timestamp::min())); }); - if (!_readOnly && !_ephemeral) { + if (!_ephemeral) { if (!_recoveryTimestamp.isNull()) { // If the oldest/initial data timestamps were unset (there was no persisted durable // history), initialize them to the recovery timestamp. @@ -575,7 +567,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, _sizeStorerUri = _uri("sizeStorer"); WiredTigerSession session(_conn); - if (!_readOnly && repair && _hasUri(session.getSession(), _sizeStorerUri)) { + if (repair && _hasUri(session.getSession(), _sizeStorerUri)) { LOGV2(22316, "Repairing size cache"); auto status = _salvageIfNeeded(_sizeStorerUri.c_str()); @@ -583,7 +575,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, fassertNoTrace(28577, status); } - _sizeStorer = std::make_unique<WiredTigerSizeStorer>(_conn, _sizeStorerUri, _readOnly); + _sizeStorer = std::make_unique<WiredTigerSizeStorer>(_conn, _sizeStorerUri); _runTimeConfigParam.reset(makeServerParameter<WiredTigerEngineRuntimeConfigParameter>( "wiredTigerEngineRuntimeConfig", ServerParameterType::kRuntimeOnly)); _runTimeConfigParam->_data.second = this; @@ -740,9 +732,7 @@ void WiredTigerKVEngine::cleanShutdown() { _sessionCache->shuttingDown(); - if (!_readOnly) { - syncSizeInfo(/*syncToDisk=*/true); - } + syncSizeInfo(/*syncToDisk=*/true); // The size storer has to be destructed after the session cache has shut down. This sets the // shutdown flag internally in the session cache. As operations get interrupted during shutdown, @@ -782,7 +772,7 @@ void WiredTigerKVEngine::cleanShutdown() { quickExit(EXIT_SUCCESS); } - if (_fileVersion.shouldDowngrade(_readOnly, !_recoveryTimestamp.isNull())) { + if (_fileVersion.shouldDowngrade(!_recoveryTimestamp.isNull())) { auto startTime = Date_t::now(); LOGV2(22324, "Closing WiredTiger in preparation for reconfiguring", @@ -1604,7 +1594,6 @@ std::unique_ptr<RecordStore> WiredTigerKVEngine::getRecordStore(OperationContext params.isLogged = isLogged; params.cappedCallback = nullptr; params.sizeStorer = _sizeStorer.get(); - params.isReadOnly = _readOnly; params.tracksSizeAdjustments = true; params.forceUpdateWithFullDocument = options.timeseries != boost::none; @@ -1713,33 +1702,21 @@ std::unique_ptr<SortedDataInterface> WiredTigerKVEngine::getSortedDataInterface( if (desc->isIdIndex()) { invariant(!collOptions.clusteredIndex); return std::make_unique<WiredTigerIdIndex>( - opCtx, _uri(ident), ident, desc, WiredTigerUtil::useTableLogging(nss), _readOnly); + opCtx, _uri(ident), ident, desc, WiredTigerUtil::useTableLogging(nss)); } auto keyFormat = (collOptions.clusteredIndex) ? KeyFormat::String : KeyFormat::Long; if (desc->unique()) { - return std::make_unique<WiredTigerIndexUnique>(opCtx, - _uri(ident), - ident, - keyFormat, - desc, - WiredTigerUtil::useTableLogging(nss), - _readOnly); + return std::make_unique<WiredTigerIndexUnique>( + opCtx, _uri(ident), ident, keyFormat, desc, WiredTigerUtil::useTableLogging(nss)); } - return std::make_unique<WiredTigerIndexStandard>(opCtx, - _uri(ident), - ident, - keyFormat, - desc, - WiredTigerUtil::useTableLogging(nss), - _readOnly); + return std::make_unique<WiredTigerIndexStandard>( + opCtx, _uri(ident), ident, keyFormat, desc, WiredTigerUtil::useTableLogging(nss)); } std::unique_ptr<RecordStore> WiredTigerKVEngine::makeTemporaryRecordStore(OperationContext* opCtx, StringData ident, KeyFormat keyFormat) { - invariant(!_readOnly || !recoverToOplogTimestamp.empty()); - _ensureIdentPath(ident); WiredTigerSession wtSession(_conn); @@ -1780,7 +1757,6 @@ std::unique_ptr<RecordStore> WiredTigerKVEngine::makeTemporaryRecordStore(Operat params.sizeStorer = nullptr; // Temporary collections do not need to reconcile collection size/counts. params.tracksSizeAdjustments = false; - params.isReadOnly = false; params.forceUpdateWithFullDocument = false; std::unique_ptr<WiredTigerRecordStore> rs; @@ -1937,7 +1913,7 @@ bool WiredTigerKVEngine::haveDropsQueued() const { Date_t now = _clockSource->now(); Milliseconds delta = now - Date_t::fromMillisSinceEpoch(_previousCheckedDropsQueued.load()); - if (!_readOnly && _sizeStorerSyncTracker.intervalHasElapsed()) { + if (_sizeStorerSyncTracker.intervalHasElapsed()) { _sizeStorerSyncTracker.resetLastTime(); syncSizeInfo(false); } @@ -2453,7 +2429,7 @@ StatusWith<Timestamp> WiredTigerKVEngine::recoverToStableTimestamp(OperationCont _highestSeenDurableTimestamp = stableTimestamp.asULL(); } - _sizeStorer = std::make_unique<WiredTigerSizeStorer>(_conn, _sizeStorerUri, _readOnly); + _sizeStorer = std::make_unique<WiredTigerSizeStorer>(_conn, _sizeStorerUri); return {stableTimestamp}; } @@ -2538,10 +2514,6 @@ boost::optional<Timestamp> WiredTigerKVEngine::getOplogNeededForCrashRecovery() return boost::none; } - if (_readOnly) { - return boost::none; - } - return Timestamp(_oplogNeededForCrashRecovery.load()); } |