Merge pull request #67177 from ClickHouse/vdimir/connection_reset_by_peer_spam_log

Do not spam logs with messages related to connection reset by peer
This commit is contained in:
Alexey Milovidov 2024-08-08 17:42:22 +00:00 committed by GitHub
commit 63d7697115
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@
#include <Server/TCPServer.h> #include <Server/TCPServer.h>
#include <Poco/Net/NetException.h> #include <Poco/Net/NetException.h>
#include <Common/logger_useful.h>
namespace DB namespace DB
{ {
@ -97,6 +98,21 @@ void HTTPServerConnection::run()
{ {
sendErrorResponse(session, Poco::Net::HTTPResponse::HTTP_BAD_REQUEST); sendErrorResponse(session, Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
} }
catch (const Poco::Net::NetException & e)
{
/// Do not spam logs with messages related to connection reset by peer.
if (e.code() == POCO_ENOTCONN)
{
LOG_DEBUG(LogFrequencyLimiter(getLogger("HTTPServerConnection"), 10), "Connection reset by peer while processing HTTP request: {}", e.message());
break;
}
if (session.networkException())
session.networkException()->rethrow();
else
throw;
}
catch (const Poco::Exception &) catch (const Poco::Exception &)
{ {
if (session.networkException()) if (session.networkException())