diff options
author | Akanksha Mahajan <43301668+akankshamahajan15@users.noreply.github.com> | 2022-11-14 16:14:41 -0800 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-11-14 16:14:41 -0800 |
commit | 1562524e63229f41547f8d72c88001a4e259a4c3 (patch) | |
tree | 6c512d2e90711e0f2d475ee0fcb91f1cf7ca03f7 /file/file_prefetch_buffer.h | |
parent | 0993c9225f8086bab6c4c0a2d7206897d1cc688c (diff) |
Fix db_stress failure in async_io in FilePrefetchBuffer (#10949)
Summary:
Fix db_stress failure in async_io in FilePrefetchBuffer.
From the logs, assertion was caused when
- prev_offset_ = offset but somehow prev_len != 0 and explicit_prefetch_submitted_ = true. That scenario is when we send async request to prefetch buffer during seek but in second seek that data is found in cache. prev_offset_ and prev_len_ get updated but we were not setting explicit_prefetch_submitted_ = false because of which buffers were getting out of sync.
It's possible a read by another thread might have loaded the block into the cache in the meantime.
Particular assertion example:
```
prev_offset: 0, prev_len_: 8097 , offset: 0, length: 8097, actual_length: 8097 , actual_offset: 0 ,
curr_: 0, bufs_[curr_].offset_: 4096 ,bufs_[curr_].CurrentSize(): 48541 , async_len_to_read: 278528, bufs_[curr_].async_in_progress_: false
second: 1, bufs_[second].offset_: 282624 ,bufs_[second].CurrentSize(): 0, async_len_to_read: 262144 ,bufs_[second].async_in_progress_: true ,
explicit_prefetch_submitted_: true , copy_to_third_buffer: false
```
As we can see curr_ was expected to read 278528 but it read 48541. Also buffers are out of sync.
Also `explicit_prefetch_submitted_` is set true but prev_len not 0.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/10949
Test Plan:
- Ran db_bench for regression to make sure there is no regression;
- Ran db_stress failing without this fix,
- Ran build-linux-mini-crashtest 7- 8 times locally + CircleCI
Reviewed By: anand1976
Differential Revision: D41257786
Pulled By: akankshamahajan15
fbshipit-source-id: 1d100f94f8c06bbbe4cc76ca27f1bbc820c2494f
Diffstat (limited to 'file/file_prefetch_buffer.h')
-rw-r--r-- | file/file_prefetch_buffer.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/file/file_prefetch_buffer.h b/file/file_prefetch_buffer.h index bd8ba9d7d..a4a75fe2b 100644 --- a/file/file_prefetch_buffer.h +++ b/file/file_prefetch_buffer.h @@ -237,6 +237,7 @@ class FilePrefetchBuffer { } prev_offset_ = offset; prev_len_ = len; + explicit_prefetch_submitted_ = false; } void GetReadaheadState(ReadaheadFileInfo::ReadaheadInfo* readahead_info) { |