Skip to content

Commit d7208ca

Browse files
authored
Merge pull request ClickHouse#39531 from ClickHouse/backport/22.3/36763
Backport ClickHouse#36763 to 22.3: Fix some issues with low cardinality and async reads from remote fs
2 parents 3e2c2fb + 325014c commit d7208ca

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/Disks/IO/AsynchronousReadIndirectBufferFromRemoteFS.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ void AsynchronousReadIndirectBufferFromRemoteFS::prefetch()
134134
void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilPosition(size_t position)
135135
{
136136
if (prefetch_future.valid())
137-
throw Exception(ErrorCodes::LOGICAL_ERROR, "Prefetch is valid in readUntilPosition");
137+
{
138+
prefetch_future.wait();
139+
prefetch_future = {};
140+
}
138141

139142
if (position > read_until_position)
140143
{
@@ -147,7 +150,10 @@ void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilPosition(size_t pos
147150
void AsynchronousReadIndirectBufferFromRemoteFS::setReadUntilEnd()
148151
{
149152
if (prefetch_future.valid())
150-
throw Exception(ErrorCodes::LOGICAL_ERROR, "Prefetch is valid in readUntilEnd");
153+
{
154+
prefetch_future.wait();
155+
prefetch_future = {};
156+
}
151157

152158
read_until_position = impl->getFileSize();
153159
impl->setReadUntilPosition(*read_until_position);

src/Disks/IO/ReadBufferFromRemoteFSGather.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ String ReadBufferFromRemoteFSGather::getInfoForLog()
271271
size_t ReadBufferFromRemoteFSGather::getImplementationBufferOffset() const
272272
{
273273
if (!current_buf)
274-
throw Exception(ErrorCodes::LOGICAL_ERROR, "Buffer not initialized");
274+
return file_offset_of_buffer_end;
275275

276276
return current_buf->getFileOffsetOfBufferEnd();
277277
}

tests/queries/1_stateful/00167_read_bytes_from_fs.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
-- Tags: no-random-settings
2+
13
SELECT sum(cityHash64(*)) FROM test.hits SETTINGS max_threads=40;
24

35
-- We had a bug which lead to additional compressed data read. test.hits compressed size is about 1.2Gb, but we read more then 3Gb.

0 commit comments

Comments
 (0)