Skip to content

Commit

Permalink
Try to fix 02963_remote_read_small_buffer_size_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
vitlibar committed Feb 14, 2024
1 parent 8919e3b commit 66a6565
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Disks/IO/AsynchronousBoundedReadBuffer.cpp
Expand Up @@ -105,7 +105,7 @@ size_t AsynchronousBoundedReadBuffer::getBufferSizeForReading() const
{
if (file_offset_of_buffer_end > *read_until_position)
throwReadBeyondLastOffset();
buffer_size = std::min(buffer_size, *read_until_position - file_offset_of_buffer_end);
//buffer_size = std::min(buffer_size, *read_until_position - file_offset_of_buffer_end);
}
return buffer_size;
}
Expand Down Expand Up @@ -257,9 +257,14 @@ bool AsynchronousBoundedReadBuffer::nextImpl()
chassert(file_offset_of_buffer_end <= impl->getFileSize());

if (read_until_position && (file_offset_of_buffer_end > *read_until_position))
throwReadBeyondLastOffset();
{
size_t excessive_bytes_read = file_offset_of_buffer_end - *read_until_position;
chassert(working_buffer.size() >= excessive_bytes_read);
working_buffer.resize(working_buffer.size() - excessive_bytes_read);
file_offset_of_buffer_end = *read_until_position;
}

return bytes_read;
return working_buffer.size();
}


Expand Down

0 comments on commit 66a6565

Please sign in to comment.