diff options
Diffstat (limited to 'src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp')
| -rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp index 7fa7416d58f..1afdb79babc 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -602,9 +602,12 @@ logv2::LogSeverity getWTLOGV2SeverityLevel(const BSONObj& obj) { return logv2::LogSeverity::Info(); case WT_VERBOSE_INFO: return logv2::LogSeverity::Log(); - case WT_VERBOSE_DEBUG: - return logv2::LogSeverity::Debug(1); default: + // MongoDB enables some WT debug compnonents by default. If performed a 1:1 + // translation from WT log severity levels, MongoDB would not log anything + // below default level Log, even if a Debug message came through the message + // handler. To solve this, we upgrade all Debug messages to the Log level + // to ensure they are seen. return logv2::LogSeverity::Log(); } } @@ -1191,6 +1194,30 @@ std::string WiredTigerUtil::generateWTVerboseConfiguration() { return cfg; } +// static +boost::optional<std::string> WiredTigerUtil::getConfigStringFromStorageOptions( + const BSONObj& options) { + if (auto wtElem = options[kWiredTigerEngineName]) { + BSONObj wtObj = wtElem.Obj(); + if (auto configStringElem = wtObj.getField(kConfigStringField)) { + return configStringElem.String(); + } + } + + return boost::none; +} + +// static +BSONObj WiredTigerUtil::setConfigStringToStorageOptions(const BSONObj& options, + const std::string& configString) { + // Storage options may contain settings for non-WiredTiger storage engines (e.g. inMemory). + // We should leave these settings intact. + auto wtElem = options[kWiredTigerEngineName]; + auto wtObj = wtElem ? wtElem.Obj() : BSONObj(); + return options.addFields( + BSON(kWiredTigerEngineName << wtObj.addFields(BSON(kConfigStringField << configString)))); +} + void WiredTigerUtil::removeEncryptionFromConfigString(std::string* configString) { static const StaticImmortal<pcrecpp::RE> encryptionOptsRegex(R"re(encryption=\([^\)]*\),?)re"); encryptionOptsRegex->GlobalReplace("", configString); @@ -1198,20 +1225,13 @@ void WiredTigerUtil::removeEncryptionFromConfigString(std::string* configString) // static BSONObj WiredTigerUtil::getSanitizedStorageOptionsForSecondaryReplication(const BSONObj& options) { - // Storage options may contain settings for non-WiredTiger storage engines (e.g. inMemory). - // We should leave these settings intact. - if (auto wtElem = options[kWiredTigerEngineName]) { - BSONObj wtObj = wtElem.Obj(); - if (auto configStringElem = wtObj.getField(kConfigStringField)) { - auto configString = configStringElem.String(); - removeEncryptionFromConfigString(&configString); - // Return a new BSONObj with the configString field sanitized. - return options.addFields(BSON(kWiredTigerEngineName << wtObj.addFields( - BSON(kConfigStringField << configString)))); - } + auto configString = getConfigStringFromStorageOptions(options); + if (!configString) { + return options; } - return options; + removeEncryptionFromConfigString(configString.get_ptr()); + return setConfigStringToStorageOptions(options, *configString); } } // namespace mongo |
