New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix formula for new_size in WriteBufferFromVector(AppendModeTag). #6208
Fix formula for new_size in WriteBufferFromVector(AppendModeTag). #6208
Conversation
dbms/src/IO/WriteBuffer.h
Outdated
@@ -35,8 +35,6 @@ class WriteBuffer : public BufferBase | |||
*/ | |||
inline void next() | |||
{ | |||
if (!offset()) | |||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems WriteBuffer::nextIfAtEnd()
should only check that the cursor reaches the end of the buffer before calling WriteBuffer::nextImpl()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it lead to writing zero bytes into file; compressing block of data with zero size, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right and it's better not to leave a WriteBuffer
with empty size after initialization. So I've removed my changes in WriteBuffer.h and just corrected formula in WriteBufferFromVector(AppendModeTag)
.
dbms/src/IO/WriteBufferFromVector.h
Outdated
@@ -57,7 +57,7 @@ class WriteBufferFromVector : public WriteBuffer | |||
: WriteBuffer(nullptr, 0), vector(vector_) | |||
{ | |||
size_t old_size = vector.size(); | |||
vector.resize(std::max(vector.size() + initial_size, vector.capacity())); | |||
vector.resize(std::max(initial_size, vector.capacity())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in WriteBuffer::next()
fixes the hanging. We can still add initial_size
to vector.size()
here but it seems it's better not to do it in this constructor in advance because WriteBuffer::nextImpl()
also can increase the size of the vector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commend isn't actual anymore. Here I only corrected the formula for consistency with WriteBufferFromVector::nextImpl()
.
870c7d0
to
b51898f
Compare
b51898f
to
d7891ec
Compare
…en-if-zero-offset Fix formula for new_size in WriteBufferFromVector(AppendModeTag). (cherry picked from commit e9c2077)
…en-if-zero-offset Fix formula for new_size in WriteBufferFromVector(AppendModeTag). (cherry picked from commit e9c2077)
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Category (leave one):
It's another approach to fix #6195