-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Prefetch buffer may not contain all of requested data if EOF is hit #13376
Conversation
file/file_prefetch_buffer.cc
Outdated
@@ -865,8 +865,7 @@ bool FilePrefetchBuffer::TryReadFromCacheUntracked( | |||
if (copy_to_overlap_buffer) { | |||
buf = overlap_buf_; | |||
} | |||
assert(buf->offset_ <= offset); | |||
assert(buf->IsDataBlockInBuffer(offset, n)); | |||
assert(buf->IsOffsetInBuffer(offset)); | |||
uint64_t offset_in_buffer = offset - buf->offset_; | |||
*result = Slice(buf->buffer_.BufferStart() + offset_in_buffer, n); |
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 this is a bug from this 2019 commit siying@3737d06: https://github.com/siying/rocksdb/blob/4eb51130917c260f5637731cd77baaa45dfdc5ec/file/file_prefetch_buffer.cc#L130
What happens if we try to read more bytes than there exists in the file? I don't think we always want to return n
bytes.
5507d62
to
0e22c2e
Compare
0e22c2e
to
159dd79
Compare
@archang19 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
fyi @jowlyzhang this error affected the warm storage crash tests |
@archang19 merged this pull request in c1fb33e. |
Summary
There was a stress test that failed at the assertion check for
IsDataBlockInBuffer
.IsDataBlockInBuffer
is too strict of a condition if we are trying to read past the end of the file.This seems to be a bug from the original 2019 commit siying@3737d06: https://github.com/siying/rocksdb/blob/4eb51130917c260f5637731cd77baaa45dfdc5ec/file/file_prefetch_buffer.cc#L130
If the caller tries requesting more bytes than are available, then we still return
n
bytes, even if the buffer really only containsm < n
bytes.Test Plan
I added a unit test which caused the original
IsDataBlockInBuffer
assertion to fail. I also updated the unit test to check for the result size, which triggered the bug (without this fix) where we return a size ofn
even if less thann
bytes exist.