summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Galtsev <sergey.galtsev@mongodb.com>2021-02-18 21:10:56 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-07 20:45:40 +0000
commitae83ae0fa283efabb93c0fc55bf640cedd4916d7 (patch)
treeb9e5706ceecc1cb201139dd365f8c7bc71e5e886
parentd323b0b7502e80d7cb7018cfb801e2b83f5b420a (diff)
downloadmongo-ae83ae0fa283efabb93c0fc55bf640cedd4916d7.tar.gz
SERVER-53852 MongoDB hangs randomly (combined patches)
(cherry picked from commit 51142d61eeea0a30b2691680663d60c17441afce) (cherry picked from commit 77d144dad2f49d78903c98985f61bf9245145e49)
-rw-r--r--src/mongo/logv2/file_rotate_sink.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mongo/logv2/file_rotate_sink.cpp b/src/mongo/logv2/file_rotate_sink.cpp
index eefc8da6543..2f58a47c168 100644
--- a/src/mongo/logv2/file_rotate_sink.cpp
+++ b/src/mongo/logv2/file_rotate_sink.cpp
@@ -29,6 +29,7 @@
#include "mongo/logv2/file_rotate_sink.h"
+#include <boost/exception/diagnostic_information.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/iterator/filter_iterator.hpp>
#include <boost/iterator/transform_iterator.hpp>
@@ -39,9 +40,10 @@
#include "mongo/logv2/json_formatter.h"
#include "mongo/logv2/log_detail.h"
#include "mongo/logv2/shared_access_fstream.h"
+#include "mongo/util/quick_exit.h"
+#include "mongo/util/stacktrace.h"
#include "mongo/util/string_map.h"
-
namespace mongo::logv2 {
namespace {
#if _WIN32
@@ -147,7 +149,7 @@ void FileRotateSink::consume(const boost::log::record_view& rec,
auto failedBegin =
boost::make_filter_iterator(isFailed, _impl->files.begin(), _impl->files.end());
auto failedEnd =
- boost::make_filter_iterator(isFailed, _impl->files.begin(), _impl->files.end());
+ boost::make_filter_iterator(isFailed, _impl->files.end(), _impl->files.end());
auto getFilename = [](const auto& file) -> const auto& {
return file.first;
@@ -173,13 +175,19 @@ void FileRotateSink::consume(const boost::log::record_view& rec,
LogTruncation::Disabled);
// Commented out log line below to get validation of the log id with the errorcodes
// linter LOGV2(4522200, "Writing to log file failed, aborting application");
- std::cout << StringData(buffer.data(), buffer.size()) << std::endl;
+ std::cerr << StringData(buffer.data(), buffer.size()) << std::endl;
+ } catch (const std::exception& ex) {
+ std::cerr << "Caught std::exception of type " << demangleName(typeid(ex)) << ": "
+ << ex.what() << std::endl;
+ } catch (const boost::exception& ex) {
+ std::cerr << "Caught boost::exception of type " << demangleName(typeid(ex)) << ": "
+ << boost::diagnostic_information(ex) << std::endl;
} catch (...) {
- // If the formatting code throws for any reason, ignore and proceed with aborting the
- // application.
+ std::cerr << "Caught unidentified exception" << std::endl;
}
- std::abort();
+ printStackTrace(std::cerr);
+ quickExit(EXIT_FAILURE);
}
}