Respect fill_cache when reading blobs in DBIter (#10492)

Summary:
Similarly to https://github.com/facebook/rocksdb/pull/10457, we now have
to explicitly set the `fill_cache` read option when reading blobs in
`DBIter` to prevent the cache from getting polluted by queries with
`fill_cache` set to false. (Before we added support for a blob cache,
the setting had not made any difference either way.)

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

Test Plan: `make check`

Reviewed By: akankshamahajan15

Differential Revision: D38476121

Pulled By: ltamasi

fbshipit-source-id: ea5c5e252f83e4a4e2c74156b37d40308d7e0c80
main
Levi Tamasi 2 years ago committed by Facebook GitHub Bot
parent e446bc65e6
commit 0cc9e98bbb
  1. 7
      db/blob/db_blob_basic_test.cc
  2. 2
      db/db_iter.cc
  3. 1
      db/db_iter.h

@ -135,6 +135,8 @@ TEST_F(DBBlobBasicTest, IterateBlobsFromCache) {
block_based_options.cache_index_and_filter_blocks = true; block_based_options.cache_index_and_filter_blocks = true;
options.table_factory.reset(NewBlockBasedTableFactory(block_based_options)); options.table_factory.reset(NewBlockBasedTableFactory(block_based_options));
options.statistics = CreateDBStatistics();
Reopen(options); Reopen(options);
int num_blobs = 5; int num_blobs = 5;
@ -165,6 +167,7 @@ TEST_F(DBBlobBasicTest, IterateBlobsFromCache) {
++i; ++i;
} }
ASSERT_EQ(i, num_blobs); ASSERT_EQ(i, num_blobs);
ASSERT_EQ(options.statistics->getAndResetTickerCount(BLOB_DB_CACHE_ADD), 0);
} }
{ {
@ -180,6 +183,7 @@ TEST_F(DBBlobBasicTest, IterateBlobsFromCache) {
iter->SeekToFirst(); iter->SeekToFirst();
ASSERT_NOK(iter->status()); ASSERT_NOK(iter->status());
ASSERT_FALSE(iter->Valid()); ASSERT_FALSE(iter->Valid());
ASSERT_EQ(options.statistics->getAndResetTickerCount(BLOB_DB_CACHE_ADD), 0);
} }
{ {
@ -198,6 +202,8 @@ TEST_F(DBBlobBasicTest, IterateBlobsFromCache) {
++i; ++i;
} }
ASSERT_EQ(i, num_blobs); ASSERT_EQ(i, num_blobs);
ASSERT_EQ(options.statistics->getAndResetTickerCount(BLOB_DB_CACHE_ADD),
num_blobs);
} }
{ {
@ -217,6 +223,7 @@ TEST_F(DBBlobBasicTest, IterateBlobsFromCache) {
++i; ++i;
} }
ASSERT_EQ(i, num_blobs); ASSERT_EQ(i, num_blobs);
ASSERT_EQ(options.statistics->getAndResetTickerCount(BLOB_DB_CACHE_ADD), 0);
} }
} }

@ -71,6 +71,7 @@ DBIter::DBIter(Env* _env, const ReadOptions& read_options,
read_options.total_order_seek || read_options.total_order_seek ||
read_options.auto_prefix_mode), read_options.auto_prefix_mode),
read_tier_(read_options.read_tier), read_tier_(read_options.read_tier),
fill_cache_(read_options.fill_cache),
verify_checksums_(read_options.verify_checksums), verify_checksums_(read_options.verify_checksums),
expose_blob_index_(expose_blob_index), expose_blob_index_(expose_blob_index),
is_blob_(false), is_blob_(false),
@ -189,6 +190,7 @@ bool DBIter::SetBlobValueIfNeeded(const Slice& user_key,
// avoid having to copy options back and forth. // avoid having to copy options back and forth.
ReadOptions read_options; ReadOptions read_options;
read_options.read_tier = read_tier_; read_options.read_tier = read_tier_;
read_options.fill_cache = fill_cache_;
read_options.verify_checksums = verify_checksums_; read_options.verify_checksums = verify_checksums_;
constexpr FilePrefetchBuffer* prefetch_buffer = nullptr; constexpr FilePrefetchBuffer* prefetch_buffer = nullptr;

@ -356,6 +356,7 @@ class DBIter final : public Iterator {
// prefix_extractor_ must be non-NULL if the value is false. // prefix_extractor_ must be non-NULL if the value is false.
const bool expect_total_order_inner_iter_; const bool expect_total_order_inner_iter_;
ReadTier read_tier_; ReadTier read_tier_;
bool fill_cache_;
bool verify_checksums_; bool verify_checksums_;
// Whether the iterator is allowed to expose blob references. Set to true when // Whether the iterator is allowed to expose blob references. Set to true when
// the stacked BlobDB implementation is used, false otherwise. // the stacked BlobDB implementation is used, false otherwise.

Loading…
Cancel
Save