From bd2ad2f9a0bc368aa1c183ac9acb8215dc3fc0d7 Mon Sep 17 00:00:00 2001 From: Akanksha Mahajan Date: Mon, 12 Sep 2022 14:48:06 -0700 Subject: [PATCH] Fix stress test failure for async_io (#10660) Summary: Sanitize initial_auto_readahead_size if its greater than max_auto_readahead_size in case of async_io Pull Request resolved: https://github.com/facebook/rocksdb/pull/10660 Test Plan: Ran db_stress with intitial_auto_readahead_size greater than max_auto_readahead_size. Reviewed By: anand1976 Differential Revision: D39408095 Pulled By: akankshamahajan15 fbshipit-source-id: 07f933242f636cfbc7ccf042e0c8b959a8ec5f3a --- table/block_based/block_prefetcher.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/table/block_based/block_prefetcher.cc b/table/block_based/block_prefetcher.cc index 5cd2cc2b5..83ec2cb06 100644 --- a/table/block_based/block_prefetcher.cc +++ b/table/block_based/block_prefetcher.cc @@ -45,6 +45,10 @@ void BlockPrefetcher::PrefetchIfNeeded( return; } + if (initial_auto_readahead_size_ > max_auto_readahead_size) { + initial_auto_readahead_size_ = max_auto_readahead_size; + } + // In case of no_sequential_checking, it will skip the num_file_reads_ and // will always creates the FilePrefetchBuffer. if (no_sequential_checking) { @@ -81,10 +85,6 @@ void BlockPrefetcher::PrefetchIfNeeded( return; } - if (initial_auto_readahead_size_ > max_auto_readahead_size) { - initial_auto_readahead_size_ = max_auto_readahead_size; - } - if (rep->file->use_direct_io()) { rep->CreateFilePrefetchBufferIfNotExists( initial_auto_readahead_size_, max_auto_readahead_size,