diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-03-23 10:04:42 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-03-24 20:22:44 +0000 |
commit | edb8778350326d2b33f056b1b5f0b25a4b5b444a (patch) | |
tree | 15afcaa7a707be0872b764cd054aee55d855ba92 /src/mongo/watchdog | |
parent | 51b338ad41653a8188adcc67b682ea12bbe63b4d (diff) | |
download | mongo-edb8778350326d2b33f056b1b5f0b25a4b5b444a.tar.gz |
SERVER-47040 LOGV2_FATAL also fasserts
Added LOGV2_FATAL_NOTRACE and LOGV2_CONTINUE to have different behavior.
Diffstat (limited to 'src/mongo/watchdog')
-rw-r--r-- | src/mongo/watchdog/watchdog.cpp | 125 |
1 files changed, 62 insertions, 63 deletions
diff --git a/src/mongo/watchdog/watchdog.cpp b/src/mongo/watchdog/watchdog.cpp index 401388c0d3d..3a98041bae0 100644 --- a/src/mongo/watchdog/watchdog.cpp +++ b/src/mongo/watchdog/watchdog.cpp @@ -160,9 +160,10 @@ void WatchdogPeriodicThread::doLoop() { } catch (const DBException& e) { // The only bad status is when we are in shutdown if (!opCtx->getServiceContext()->getKillAllOperations()) { - LOGV2_FATAL(23415, - "Watchdog was interrupted, shutting down, reason: {e_toStatus}", - "e_toStatus"_attr = e.toStatus()); + LOGV2_FATAL_CONTINUE( + 23415, + "Watchdog was interrupted, shutting down, reason: {e_toStatus}", + "e_toStatus"_attr = e.toStatus()); exitCleanly(ExitCode::EXIT_ABRUPT); } @@ -351,18 +352,18 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { NULL); if (hFile == INVALID_HANDLE_VALUE) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL( - 23416, - "CreateFile failed for '{file_generic_string}' with error: {errnoWithDescription_gle}", - "file_generic_string"_attr = file.generic_string(), - "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); + LOGV2_FATAL_CONTINUE(23416, + "CreateFile failed for '{file_generic_string}' with error: " + "{errnoWithDescription_gle}", + "file_generic_string"_attr = file.generic_string(), + "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); fassertNoTrace(4074, gle == 0); } DWORD bytesWrittenTotal; if (!WriteFile(hFile, nowStr.c_str(), nowStr.size(), &bytesWrittenTotal, NULL)) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23417, "WriteFile failed for '{file_generic_string}' with error: {errnoWithDescription_gle}", "file_generic_string"_attr = file.generic_string(), @@ -381,22 +382,22 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { if (!FlushFileBuffers(hFile)) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL(23418, - "FlushFileBuffers failed for '{file_generic_string}' with error: " - "{errnoWithDescription_gle}", - "file_generic_string"_attr = file.generic_string(), - "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); + LOGV2_FATAL_CONTINUE(23418, + "FlushFileBuffers failed for '{file_generic_string}' with error: " + "{errnoWithDescription_gle}", + "file_generic_string"_attr = file.generic_string(), + "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); fassertNoTrace(4076, gle == 0); } DWORD newOffset = SetFilePointer(hFile, 0, 0, FILE_BEGIN); if (newOffset != 0) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL(23419, - "SetFilePointer failed for '{file_generic_string}' with error: " - "{errnoWithDescription_gle}", - "file_generic_string"_attr = file.generic_string(), - "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); + LOGV2_FATAL_CONTINUE(23419, + "SetFilePointer failed for '{file_generic_string}' with error: " + "{errnoWithDescription_gle}", + "file_generic_string"_attr = file.generic_string(), + "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); fassertNoTrace(4077, gle == 0); } @@ -404,42 +405,41 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { auto readBuffer = std::make_unique<char[]>(nowStr.size()); if (!ReadFile(hFile, readBuffer.get(), nowStr.size(), &bytesRead, NULL)) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL(23420, - "ReadFile failed for '{file_generic_string}' with error: " - "{errnoWithDescription_gle}", - "file_generic_string"_attr = file.generic_string(), - "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); + LOGV2_FATAL_CONTINUE(23420, + "ReadFile failed for '{file_generic_string}' with error: " + "{errnoWithDescription_gle}", + "file_generic_string"_attr = file.generic_string(), + "errnoWithDescription_gle"_attr = errnoWithDescription(gle)); fassertNoTrace(4078, gle == 0); } if (bytesRead != bytesWrittenTotal) { - LOGV2_FATAL(23421, - "Read wrong number of bytes for '{file_generic_string}' expected " - "{bytesWrittenTotal} bytes but read {bytesRead} bytes", - "file_generic_string"_attr = file.generic_string(), - "bytesWrittenTotal"_attr = bytesWrittenTotal, - "bytesRead"_attr = bytesRead); - fassertNoTrace(50724, false); + LOGV2_FATAL_NOTRACE(50724, + "Read wrong number of bytes for '{file_generic_string}' expected " + "{bytesWrittenTotal} bytes but read {bytesRead} bytes", + "file_generic_string"_attr = file.generic_string(), + "bytesWrittenTotal"_attr = bytesWrittenTotal, + "bytesRead"_attr = bytesRead); } if (memcmp(nowStr.c_str(), readBuffer.get(), nowStr.size()) != 0) { - LOGV2_FATAL(23422, - "Read wrong string from file '{file_generic_string}{nowStr_size} bytes (in " - "hex) '{toHexLower_nowStr_c_str_nowStr_size}' but read bytes " - "'{toHexLower_readBuffer_get_bytesRead}'", - "file_generic_string"_attr = file.generic_string(), - "nowStr_size"_attr = nowStr.size(), - "toHexLower_nowStr_c_str_nowStr_size"_attr = - toHexLower(nowStr.c_str(), nowStr.size()), - "toHexLower_readBuffer_get_bytesRead"_attr = - toHexLower(readBuffer.get(), bytesRead)); - fassertNoTrace(50717, false); + LOGV2_FATAL_NOTRACE( + 50717, + "Read wrong string from file '{file_generic_string}{nowStr_size} bytes (in " + "hex) '{toHexLower_nowStr_c_str_nowStr_size}' but read bytes " + "'{toHexLower_readBuffer_get_bytesRead}'", + "file_generic_string"_attr = file.generic_string(), + "nowStr_size"_attr = nowStr.size(), + "toHexLower_nowStr_c_str_nowStr_size"_attr = + toHexLower(nowStr.c_str(), nowStr.size()), + "toHexLower_readBuffer_get_bytesRead"_attr = + toHexLower(readBuffer.get(), bytesRead)); } } if (!CloseHandle(hFile)) { std::uint32_t gle = ::GetLastError(); - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23423, "CloseHandle failed for '{file_generic_string}' with error: {errnoWithDescription_gle}", "file_generic_string"_attr = file.generic_string(), @@ -468,7 +468,7 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { int fd = open(file.generic_string().c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); if (fd == -1) { auto err = errno; - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23424, "open failed for '{file_generic_string}' with error: {errnoWithDescription_err}", "file_generic_string"_attr = file.generic_string(), @@ -486,7 +486,7 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { continue; } - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23425, "write failed for '{file_generic_string}' with error: {errnoWithDescription_err}", "file_generic_string"_attr = file.generic_string(), @@ -509,7 +509,7 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { if (fsync(fd)) { auto err = errno; - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23426, "fsync failed for '{file_generic_string}' with error: {errnoWithDescription_err}", "file_generic_string"_attr = file.generic_string(), @@ -528,17 +528,17 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { continue; } - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23427, "read failed for '{file_generic_string}' with error: {errnoWithDescription_err}", "file_generic_string"_attr = file.generic_string(), "errnoWithDescription_err"_attr = errnoWithDescription(err)); fassertNoTrace(4083, err == 0); } else if (bytesReadInRead == 0) { - LOGV2_FATAL(23428, - "read failed for '{file_generic_string}' with unexpected end of file", - "file_generic_string"_attr = file.generic_string()); - fassertNoTrace(50719, false); + LOGV2_FATAL_NOTRACE( + 50719, + "read failed for '{file_generic_string}' with unexpected end of file", + "file_generic_string"_attr = file.generic_string()); } // Warn if the read was incomplete @@ -555,22 +555,21 @@ void checkFile(OperationContext* opCtx, const boost::filesystem::path& file) { } if (memcmp(nowStr.c_str(), readBuffer.get(), nowStr.size()) != 0) { - LOGV2_FATAL(23429, - "Read wrong string from file '{file_generic_string}' expected {nowStr_size} " - "bytes (in hex) '{toHexLower_nowStr_c_str_nowStr_size}' but read bytes " - "'{toHexLower_readBuffer_get_bytesReadTotal}'", - "file_generic_string"_attr = file.generic_string(), - "nowStr_size"_attr = nowStr.size(), - "toHexLower_nowStr_c_str_nowStr_size"_attr = - toHexLower(nowStr.c_str(), nowStr.size()), - "toHexLower_readBuffer_get_bytesReadTotal"_attr = - toHexLower(readBuffer.get(), bytesReadTotal)); - fassertNoTrace(50718, false); + LOGV2_FATAL_NOTRACE( + 50718, + "Read wrong string from file '{file_generic_string}' expected {nowStr_size} " + "bytes (in hex) '{toHexLower_nowStr_c_str_nowStr_size}' but read bytes " + "'{toHexLower_readBuffer_get_bytesReadTotal}'", + "file_generic_string"_attr = file.generic_string(), + "nowStr_size"_attr = nowStr.size(), + "toHexLower_nowStr_c_str_nowStr_size"_attr = toHexLower(nowStr.c_str(), nowStr.size()), + "toHexLower_readBuffer_get_bytesReadTotal"_attr = + toHexLower(readBuffer.get(), bytesReadTotal)); } if (close(fd)) { auto err = errno; - LOGV2_FATAL( + LOGV2_FATAL_CONTINUE( 23430, "close failed for '{file_generic_string}' with error: {errnoWithDescription_err}", "file_generic_string"_attr = file.generic_string(), |