-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Do not acquire lock for total_bytes/total_rows for Buffer engine #24066
Do not acquire lock for total_bytes/total_rows for Buffer engine #24066
Conversation
When Buffer() is under preassure, acquiring per-layer lock may take significant time. And so the following query may take significant amount of time: SELECT total_bytes, total_rows FROM system.tables WHERE engine='Buffer'
9b7b7db
to
074b57f
Compare
SIGKILL
Unrelated |
@@ -606,6 +606,9 @@ class BufferBlockOutputStream : public IBlockOutputStream | |||
if (!buffer.data) | |||
{ | |||
buffer.data = sorted_block.cloneEmpty(); | |||
|
|||
storage.total_writes.rows += buffer.data.rows(); | |||
storage.total_writes.bytes += buffer.data.allocatedBytes(); |
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 is useless
size_t old_rows = buffer.data.rows(); | ||
size_t old_bytes = buffer.data.allocatedBytes(); | ||
|
||
appendBlock(sorted_block, buffer.data); | ||
|
||
storage.total_writes.rows += (buffer.data.rows() - old_rows); | ||
storage.total_writes.bytes += (buffer.data.allocatedBytes() - old_bytes); |
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.
Looks like it is better to check this for overflow
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Do not acquire lock for total_bytes/total_rows for Buffer engine
Detailed description / Documentation draft:
When Buffer() is under preassure, acquiring per-layer lock may take
significant time. And so the following query may take significant amount of time: