mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Merge pull request #60769 from ClickHouse/catch-finalize-exception
Catch exceptions on finalize in `InterserverIOHTTPHandler`
This commit is contained in:
commit
09924899ea
@ -91,24 +91,35 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
|
||||
used_output.out = std::make_shared<WriteBufferFromHTTPServerResponse>(
|
||||
response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout, write_event);
|
||||
|
||||
auto finalize_output = [&]
|
||||
{
|
||||
try
|
||||
{
|
||||
used_output.out->finalize();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(log, "Failed to finalize response write buffer");
|
||||
}
|
||||
};
|
||||
|
||||
auto write_response = [&](const std::string & message)
|
||||
{
|
||||
auto & out = *used_output.out;
|
||||
if (response.sent())
|
||||
{
|
||||
out.finalize();
|
||||
finalize_output();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
writeString(message, out);
|
||||
out.finalize();
|
||||
writeString(message, *used_output.out);
|
||||
finalize_output();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(log);
|
||||
out.finalize();
|
||||
finalize_output();
|
||||
}
|
||||
};
|
||||
|
||||
@ -117,7 +128,7 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
|
||||
if (auto [message, success] = checkAuthentication(request); success)
|
||||
{
|
||||
processQuery(request, response, used_output);
|
||||
used_output.out->finalize();
|
||||
finalize_output();
|
||||
LOG_DEBUG(log, "Done processing query");
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user