Repository navigation
output format does not write to the canceled buffer - #72815
Conversation
|
This is an automated comment for commit bbb271a with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
|
Note that this should also be a bugfix and backported to 24.11 |
|
|
| auto header = current_output_format.getPort(IOutputFormat::PortKind::Main).getHeader(); | ||
| used_output.exception_writer = [&, format_name, header, context_, format_settings](WriteBuffer & buf, int code, const String & message) | ||
| { | ||
| if (used_output.out_holder->isCanceled()) |
There was a problem hiding this comment.
From what I understand, it helps to reduce the probability of writing data to the canceled buffer. Because the buffer still can be canceled after this check, and the data is still written to it. Please correct me if I was wrong.
There was a problem hiding this comment.
Which buffer are we going to prevent it from being written to when it is canceled?
Is it buf? If so, should we check buf.isCanceled()?
There was a problem hiding this comment.
Your are right here. But there are some particularities.
If used_output.out_holder is canceled than buf is also canceled. Because it means that an exception happened on a stack when upper buffer tried to write a data to the socket in bottom buffer.
But it might be a case when buf is canceled but used_output.out_holder is actual. It could be when the exception happend before attempt to write to the socket. It is hard to catch such case.
But we could be ready here for such situation. Will try to adapt.
There was a problem hiding this comment.
Oh, I'm wrong here.
Variable buf is a compession buffer here. We always write over that buffer in green path. So buf is canceled if and only if used_output.out_holder is canceled.
Here is could be similar situation with current_output_format and used_output.out_holder. current_output_format might throw an exception which did not affect used_output.out_holder.
Generally it is up to specific format how to handle exceptions. Usually they use PeekableWriteBuffer in order to prepare some memory aside and do not affect used_output.out_holder. If they fail to do it, PeekableWriteBuffer reject some data and keeps used_output.out_holder active for writing exception here.
There was a problem hiding this comment.
I have added pedantic check that if used_output.out_holder->isCanceled() then buf.isCanceled() too.
| } | ||
| else | ||
| { | ||
| if (used_output.out_holder->isCanceled()) |
There was a problem hiding this comment.
Should we add chassert(buf.isCanceled()); here? Similar to the check above
There was a problem hiding this comment.
There is no var buf in that scope.
Backport #72815 to 24.12: output format does not write to the canceled buffer
Backport #72815 to 24.11: output format does not write to the canceled buffer
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):