From 0d3679d0af7662bf92f5c4deafb672c0d97216f4 Mon Sep 17 00:00:00 2001 From: Levi Tamasi Date: Tue, 18 Jun 2019 14:53:35 -0700 Subject: [PATCH] Revert to respecting only the read_tier read option for index blocks (#5481) Summary: PR https://github.com/facebook/rocksdb/issues/5298 subtly changed how read options are applied to the index block during a Get, MultiGet, or iteration. Earlier, only the read_tier option applied to the index block read; since PR https://github.com/facebook/rocksdb/issues/5298, fill_cache and verify_checksums also have an effect. This patch restores the earlier behavior to prevent surprise memory increases for clients due to the index block not being cached. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5481 Test Plan: make check Differential Revision: D15883082 Pulled By: ltamasi fbshipit-source-id: 9a065ec3a6db5a365cf6dd5e95190a20c5756356 --- table/block_based/block_based_table_reader.cc | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/table/block_based/block_based_table_reader.cc b/table/block_based/block_based_table_reader.cc index 8f61b0b1c..12fc173d0 100644 --- a/table/block_based/block_based_table_reader.cc +++ b/table/block_based/block_based_table_reader.cc @@ -217,8 +217,7 @@ class BlockBasedTable::IndexReaderCommon : public BlockBasedTable::IndexReader { return properties == nullptr || !properties->index_value_is_delta_encoded; } - Status GetOrReadIndexBlock(const ReadOptions& read_options, - GetContext* get_context, + Status GetOrReadIndexBlock(bool no_io, GetContext* get_context, BlockCacheLookupContext* lookup_context, CachableEntry* index_block) const; @@ -257,7 +256,7 @@ Status BlockBasedTable::IndexReaderCommon::ReadIndexBlock( } Status BlockBasedTable::IndexReaderCommon::GetOrReadIndexBlock( - const ReadOptions& read_options, GetContext* get_context, + bool no_io, GetContext* get_context, BlockCacheLookupContext* lookup_context, CachableEntry* index_block) const { assert(index_block != nullptr); @@ -267,6 +266,11 @@ Status BlockBasedTable::IndexReaderCommon::GetOrReadIndexBlock( return Status::OK(); } + ReadOptions read_options; + if (no_io) { + read_options.read_tier = kBlockCacheTier; + } + return ReadIndexBlock(table_, /*prefetch_buffer=*/nullptr, read_options, get_context, lookup_context, index_block); } @@ -311,9 +315,10 @@ class PartitionIndexReader : public BlockBasedTable::IndexReaderCommon { const ReadOptions& read_options, bool /* disable_prefix_seek */, IndexBlockIter* iter, GetContext* get_context, BlockCacheLookupContext* lookup_context) override { + const bool no_io = (read_options.read_tier == kBlockCacheTier); CachableEntry index_block; - const Status s = GetOrReadIndexBlock(read_options, get_context, - lookup_context, &index_block); + const Status s = + GetOrReadIndexBlock(no_io, get_context, lookup_context, &index_block); if (!s.ok()) { if (iter != nullptr) { iter->Invalidate(s); @@ -373,7 +378,7 @@ class PartitionIndexReader : public BlockBasedTable::IndexReaderCommon { Statistics* kNullStats = nullptr; CachableEntry index_block; - Status s = GetOrReadIndexBlock(ReadOptions(), nullptr /* get_context */, + Status s = GetOrReadIndexBlock(false /* no_io */, nullptr /* get_context */, &lookup_context, &index_block); if (!s.ok()) { ROCKS_LOG_WARN(rep->ioptions.info_log, @@ -497,9 +502,10 @@ class BinarySearchIndexReader : public BlockBasedTable::IndexReaderCommon { const ReadOptions& read_options, bool /* disable_prefix_seek */, IndexBlockIter* iter, GetContext* get_context, BlockCacheLookupContext* lookup_context) override { + const bool no_io = (read_options.read_tier == kBlockCacheTier); CachableEntry index_block; - const Status s = GetOrReadIndexBlock(read_options, get_context, - lookup_context, &index_block); + const Status s = + GetOrReadIndexBlock(no_io, get_context, lookup_context, &index_block); if (!s.ok()) { if (iter != nullptr) { iter->Invalidate(s); @@ -639,9 +645,10 @@ class HashIndexReader : public BlockBasedTable::IndexReaderCommon { const ReadOptions& read_options, bool disable_prefix_seek, IndexBlockIter* iter, GetContext* get_context, BlockCacheLookupContext* lookup_context) override { + const bool no_io = (read_options.read_tier == kBlockCacheTier); CachableEntry index_block; - const Status s = GetOrReadIndexBlock(read_options, get_context, - lookup_context, &index_block); + const Status s = + GetOrReadIndexBlock(no_io, get_context, lookup_context, &index_block); if (!s.ok()) { if (iter != nullptr) { iter->Invalidate(s);