Try to fix rare bug in reading of empty arrays#34327
Try to fix rare bug in reading of empty arrays#34327alesapin merged 2 commits intoClickHouse:masterfrom
Conversation
|
I'll add a test a bit later. |
|
Very interesting... |
3165db2 to
a17e7b9
Compare
|
I couldn't construct small functional test on which this bug reproduces, because it will require knowledge of too many implementation details. But it reproduces in case like this: CREATE TABLE test_table
(
`date` Date,
`timestamp` UInt32,
`host` String,
`http_code` UInt16,
`test_id` Array(Int32)
)
ENGINE = MergeTree(date, (timestamp, host, http_code), 8192)There is one detail of data in the table: column SELECT *
FROM test_table
WHERE (date = '2022-01-16') AND (host = 'some_host.com') AND (test_id = [3333])
ORDER BY timestamp DESC
LIMIT 100
SETTINGS optimize_read_in_order = 1In this query we read data in the reverse order of primary key. Assume that while reading we made a seek by the default path. We have some data in buffer from previous calls at this moment and as it written in comment we delay fetching new data to the buffer to the next call of |
There was a problem hiding this comment.
In current master 80 will be read.
|
In other words - when we read zero bytes after seek, we don't change the buffer contents, but it becomes inconsistent with the position in file? Maybe we can reset buffer to zero when we read zero bytes at the different offset? Need to check other buffers that allow seeks? |
|
@Mergifyio rebase |
✅ Branch has been successfully rebased |
6c6cd6d to
ae1fc94
Compare
It's hard because there are two different buffers: |
Yes, it's worth to check. |
Backport #34327 to 22.1: Try to fix rare bug in reading of empty arrays
Backport #34327 to 21.12: Try to fix rare bug in reading of empty arrays
Backport #34327 to 21.11: Try to fix rare bug in reading of empty arrays

Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Try to fix rare bug while reading of empty arrays, which could lead to
Data compressed with different methodserror.