diff options
author | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2018-06-14 15:05:46 -0400 |
---|---|---|
committer | Daniel Gottlieb <daniel.gottlieb@mongodb.com> | 2018-06-14 15:05:46 -0400 |
commit | ef999ac2018d29fd7425ea32df03eaab37d4709b (patch) | |
tree | 0b23d5f2644b885c275a03ae47c04697ad53e8c8 /src | |
parent | 13c65fa47bc60b785bc9c6a90bd68d5167c34ba7 (diff) | |
download | mongo-ef999ac2018d29fd7425ea32df03eaab37d4709b.tar.gz |
SERVER-35271: Suppress WT compatibility error messages on startup.
Diffstat (limited to 'src')
4 files changed, 78 insertions, 19 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 7a6a35f778d..d421e5a8c71 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -76,7 +76,6 @@ #include "mongo/db/storage/wiredtiger/wiredtiger_recovery_unit.h" #include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h" #include "mongo/db/storage/wiredtiger/wiredtiger_size_storer.h" -#include "mongo/db/storage/wiredtiger/wiredtiger_util.h" #include "mongo/platform/atomic_word.h" #include "mongo/stdx/memory.h" #include "mongo/util/background.h" @@ -187,6 +186,7 @@ void openWiredTiger(const std::string& path, return; } + severe() << "Failed to start up WiredTiger under any compatibility version."; if (ret == EINVAL) { fassertFailedNoTrace(28561); } @@ -449,8 +449,7 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, bool ephemeral, bool repair, bool readOnly) - : _eventHandler(WiredTigerUtil::defaultEventHandlers()), - _clockSource(cs), + : _clockSource(cs), _oplogManager(stdx::make_unique<WiredTigerOplogManager>()), _canonicalName(canonicalName), _path(path), @@ -518,7 +517,8 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, string config = ss.str(); log() << "Detected WT journal files. Running recovery from last checkpoint."; log() << "journal to nojournal transition config: " << config; - int ret = wiredtiger_open(path.c_str(), &_eventHandler, config.c_str(), &_conn); + int ret = wiredtiger_open( + path.c_str(), _eventHandler.getWtEventHandler(), config.c_str(), &_conn); if (ret == EINVAL) { fassertFailedNoTrace(28717); } else if (ret != 0) { @@ -540,7 +540,8 @@ WiredTigerKVEngine::WiredTigerKVEngine(const std::string& canonicalName, string config = ss.str(); log() << "wiredtiger_open config: " << config; - openWiredTiger(path, &_eventHandler, config, &_conn, &_fileVersion); + openWiredTiger(path, _eventHandler.getWtEventHandler(), config, &_conn, &_fileVersion); + _eventHandler.setStartupSuccessful(); _wtOpenConfig = config; { @@ -673,7 +674,8 @@ void WiredTigerKVEngine::cleanShutdown() { WT_CONNECTION* conn; std::stringstream openConfig; openConfig << _wtOpenConfig << ",log=(archive=false)"; - invariantWTOK(wiredtiger_open(_path.c_str(), &_eventHandler, openConfig.str().c_str(), &conn)); + invariantWTOK(wiredtiger_open( + _path.c_str(), _eventHandler.getWtEventHandler(), openConfig.str().c_str(), &conn)); WT_SESSION* session; conn->open_session(conn, nullptr, "", &session); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h index 6d62e8663b7..cc636d9e44e 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.h @@ -42,6 +42,7 @@ #include "mongo/db/storage/kv/kv_engine.h" #include "mongo/db/storage/wiredtiger/wiredtiger_oplog_manager.h" #include "mongo/db/storage/wiredtiger/wiredtiger_session_cache.h" +#include "mongo/db/storage/wiredtiger/wiredtiger_util.h" #include "mongo/stdx/functional.h" #include "mongo/stdx/mutex.h" #include "mongo/util/elapsed_tracker.h" @@ -305,7 +306,7 @@ private: void _setOldestTimestamp(Timestamp newOldestTimestamp, bool force); WT_CONNECTION* _conn; - WT_EVENT_HANDLER _eventHandler; + WiredTigerEventHandler _eventHandler; std::unique_ptr<WiredTigerSessionCache> _sessionCache; ClockSource* const _clockSource; diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp index 648e2db7418..f3acf41adb5 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.cpp @@ -386,6 +386,32 @@ size_t WiredTigerUtil::getCacheSizeMB(double requestedCacheSizeGB) { } namespace { +int mdb_handle_error_with_startup_suppression(WT_EVENT_HANDLER* handler, + WT_SESSION* session, + int errorCode, + const char* message) { + WiredTigerEventHandler* wtHandler = reinterpret_cast<WiredTigerEventHandler*>(handler); + + try { + StringData sd(message); + if (!wtHandler->wasStartupSuccessful()) { + // During startup, storage tries different WiredTiger compatibility modes to determine + // the state of the data files before FCV can be read. Suppress the error messages + // regarding expected version compatibility requirements. + if (sd.find("Version incompatibility detected:") != std::string::npos) { + return 0; + } + } + + error() << "WiredTiger error (" << errorCode << ") " << redact(message) + << " Raw: " << message; + fassert(50853, errorCode != WT_PANIC); + } catch (...) { + std::terminate(); + } + return 0; +} + int mdb_handle_error(WT_EVENT_HANDLER* handler, WT_SESSION* session, int errorCode, @@ -420,15 +446,26 @@ int mdb_handle_progress(WT_EVENT_HANDLER* handler, return 0; } -} -WT_EVENT_HANDLER WiredTigerUtil::defaultEventHandlers() { +WT_EVENT_HANDLER defaultEventHandlers() { WT_EVENT_HANDLER handlers = {}; handlers.handle_error = mdb_handle_error; handlers.handle_message = mdb_handle_message; handlers.handle_progress = mdb_handle_progress; return handlers; } +} + +WT_EVENT_HANDLER* WiredTigerEventHandler::getWtEventHandler() { + WT_EVENT_HANDLER* ret = static_cast<WT_EVENT_HANDLER*>(this); + invariant((void*)this == (void*)ret); + + ret->handle_error = mdb_handle_error_with_startup_suppression; + ret->handle_message = mdb_handle_message; + ret->handle_progress = mdb_handle_progress; + + return ret; +} WiredTigerUtil::ErrorAccumulator::ErrorAccumulator(std::vector<std::string>* errors) : WT_EVENT_HANDLER(defaultEventHandlers()), diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h index 4b09387a157..2e8cefebdc1 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_util.h +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_util.h @@ -92,6 +92,35 @@ struct WiredTigerItem : public WT_ITEM { } }; +/** + * Returns a WT_EVENT_HANDLER with MongoDB's default handlers. + * The default handlers just log so it is recommended that you consider calling them even if + * you are capturing the output. + * + * There is no default "close" handler. You only need to provide one if you need to call a + * destructor. + */ +class WiredTigerEventHandler : private WT_EVENT_HANDLER { +public: + WT_EVENT_HANDLER* getWtEventHandler(); + + bool wasStartupSuccessful() { + return _startupSuccessful; + } + + void setStartupSuccessful() { + _startupSuccessful = true; + } + +private: + int suppressibleStartupErrorLog(WT_EVENT_HANDLER* handler, + WT_SESSION* sesion, + int errorCode, + const char* message); + + bool _startupSuccessful = false; +}; + class WiredTigerUtil { MONGO_DISALLOW_COPYING(WiredTigerUtil); @@ -203,16 +232,6 @@ public: */ static size_t getCacheSizeMB(double requestedCacheSizeGB); - /** - * Returns a WT_EVENT_HANDER with MongoDB's default handlers. - * The default handlers just log so it is recommended that you consider calling them even if - * you are capturing the output. - * - * There is no default "close" handler. You only need to provide one if you need to call a - * destructor. - */ - static WT_EVENT_HANDLER defaultEventHandlers(); - class ErrorAccumulator : public WT_EVENT_HANDLER { public: ErrorAccumulator(std::vector<std::string>* errors); |