mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #31712 from Avogar/fix-write-after-finalize
Fix possible Logical error: Cannot write to finalized buffer
This commit is contained in:
commit
5f17109a84
@ -929,6 +929,15 @@ void HTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse
|
||||
request_credentials.reset(); // ...so that the next requests on the connection have to always start afresh in case of exceptions.
|
||||
});
|
||||
|
||||
/// Check if exception was thrown in used_output.finalize().
|
||||
/// In this case used_output can be in invalid state and we
|
||||
/// cannot write in it anymore. So, just log this exception.
|
||||
if (used_output.isFinalized())
|
||||
{
|
||||
tryLogCurrentException(log, "Cannot flush data to client");
|
||||
return;
|
||||
}
|
||||
|
||||
tryLogCurrentException(log);
|
||||
|
||||
/** If exception is received from remote server, then stack trace is embedded in message.
|
||||
|
@ -60,13 +60,19 @@ private:
|
||||
/// Points to 'out' or to CompressedWriteBuffer(*out) or to CascadeWriteBuffer.
|
||||
std::shared_ptr<WriteBuffer> out_maybe_delayed_and_compressed;
|
||||
|
||||
bool finalized = false;
|
||||
|
||||
inline bool hasDelayed() const
|
||||
{
|
||||
return out_maybe_delayed_and_compressed != out_maybe_compressed;
|
||||
}
|
||||
|
||||
inline void finalize() const
|
||||
inline void finalize()
|
||||
{
|
||||
if (finalized)
|
||||
return;
|
||||
finalized = true;
|
||||
|
||||
if (out_maybe_delayed_and_compressed)
|
||||
out_maybe_delayed_and_compressed->finalize();
|
||||
if (out_maybe_compressed)
|
||||
@ -74,6 +80,11 @@ private:
|
||||
if (out)
|
||||
out->finalize();
|
||||
}
|
||||
|
||||
inline bool isFinalized() const
|
||||
{
|
||||
return finalized;
|
||||
}
|
||||
};
|
||||
|
||||
IServer & server;
|
||||
|
Loading…
Reference in New Issue
Block a user