Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix kBlockCacheTier read with table cache miss #12443

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions db/db_test2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7808,6 +7808,27 @@ TEST_F(DBTest2, ZSTDChecksum) {
}
#endif

TEST_F(DBTest2, TableCacheMissDuringReadFromBlockCacheTier) {
Options options = CurrentOptions();
options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
Reopen(options);

// Give table cache zero capacity to prevent preloading tables. That way,
// `kBlockCacheTier` reads will fail due to table cache misses.
dbfull()->TEST_table_cache()->SetCapacity(0);
ASSERT_OK(Put("foo", "bar"));
ASSERT_OK(Flush());

uint64_t orig_num_file_opens = TestGetTickerCount(options, NO_FILE_OPENS);

ReadOptions non_blocking_opts;
non_blocking_opts.read_tier = kBlockCacheTier;
std::string value;
ASSERT_TRUE(db_->Get(non_blocking_opts, "foo", &value).IsIncomplete());

ASSERT_EQ(orig_num_file_opens, TestGetTickerCount(options, NO_FILE_OPENS));
}

} // namespace ROCKSDB_NAMESPACE

int main(int argc, char** argv) {
Expand Down
5 changes: 2 additions & 3 deletions db/table_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,8 @@ Status TableCache::Get(
s = t->Get(options, k, get_context, prefix_extractor.get(), skip_filters);
get_context->SetReplayLog(nullptr);
} else if (options.read_tier == kBlockCacheTier && s.IsIncomplete()) {
// Couldn't find Table in cache but treat as kFound if no_io set
// Couldn't find table in cache and couldn't open it because of no_io.
get_context->MarkKeyMayExist();
s = Status::OK();
done = true;
}
}
Expand Down Expand Up @@ -729,4 +728,4 @@ uint64_t TableCache::ApproximateSize(

return result;
}
} // namespace ROCKSDB_NAMESPACE
} // namespace ROCKSDB_NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fixed `kBlockCacheTier` reads to return `Status::Incomplete` on table cache miss rather than incorrectly returning an empty value.
Loading