rocksdb/file
anand76 dbf37c290a Fix async prefetch heap use after free (#11049)
Summary:
This PR fixes a heap use after free bug in the async prefetch code that happens in the following scenario -
1. Scan thread starts 2 async reads for Seek, one for the seek block and one for prefetching
2. Before the first read in https://github.com/facebook/rocksdb/issues/1 completes, another thread reads and loads the block in cache
3. The first scan thread finds the block in cache, continues and the next block cache miss is for a block that spans the boundary of the 2 prefetch buffers, and the 1st read is complete but the 2nd one is not complete yet
4. The scan thread will reallocate (i.e free the old buffer and allocate a new one) the 2nd prefetch buffer, and the in-progress prefetch is orphaned
5. The orphaned prefetch finally completes, resulting in a use after free

Also add a few asserts to surface bugs earlier in the crash tests.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/11049

Test Plan: Repro with db_stress and verify the fix

Reviewed By: akankshamahajan15

Differential Revision: D42181118

Pulled By: anand1976

fbshipit-source-id: 1ac55d2f64a89ce128c1c574262b8aa7d82eb8cc
2022-12-21 09:15:53 -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 prefetch heap use after free (#11049) 2022-12-21 09:15:53 -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