rocksdb/file
Akanksha Mahajan 1562524e63 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
2022-11-14 16:14:41 -08:00
..
delete_scheduler.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
delete_scheduler.h Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
delete_scheduler_test.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
file_prefetch_buffer.cc Fix async_io regression in scans (#10939) 2022-11-11 13:34:49 -08:00
file_prefetch_buffer.h Fix db_stress failure in async_io in FilePrefetchBuffer (#10949) 2022-11-14 16:14:41 -08:00
file_util.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
file_util.h Set Read rate limiter priority dynamically and pass it to FS (#9996) 2022-05-18 19:41:44 -07:00
filename.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
filename.h Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
line_file_reader.cc Support read rate-limiting in SequentialFileReader (#9973) 2022-05-24 10:28:57 -07:00
line_file_reader.h Support read rate-limiting in SequentialFileReader (#9973) 2022-05-24 10:28:57 -07:00
prefetch_test.cc Update unit test to avoid timeout (#10950) 2022-11-14 11:39:22 -08:00
random_access_file_reader.cc Add some async read stats (#10947) 2022-11-13 21:38:35 -08:00
random_access_file_reader.h Provide support for direct_reads with async_io (#10197) 2022-07-06 11:42:59 -07:00
random_access_file_reader_test.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
read_write_util.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
read_write_util.h Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
readahead_file_info.h Reuse internal auto readhead_size at each Level (expect L0) for Iterations (#9056) 2021-11-10 16:20:04 -08:00
readahead_raf.cc Make StringEnv, StringSink, StringSource use FS classes (#7786) 2021-01-04 16:01:01 -08:00
readahead_raf.h Make StringEnv, StringSink, StringSource use FS classes (#7786) 2021-01-04 16:01:01 -08:00
sequence_file_reader.cc Support read rate-limiting in SequentialFileReader (#9973) 2022-05-24 10:28:57 -07:00
sequence_file_reader.h Support read rate-limiting in SequentialFileReader (#9973) 2022-05-24 10:28:57 -07:00
sst_file_manager_impl.cc Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
sst_file_manager_impl.h Run Clang format on file folder (#10860) 2022-10-24 18:34:52 -07:00
writable_file_writer.cc WritableFileWriter to allow operation after failure when SyncWithoutFlush() is involved (#10555) 2022-08-24 07:30:52 -07:00
writable_file_writer.h Add manual_wal_flush, FlushWAL() to stress/crash test (#10698) 2022-09-30 15:48:33 -07:00