forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Follow-up from facebook#12757. New infrastructure to DEBUG builds to catch certain ReadOptions being ignored in a context where they should be in effect. This currently only applies to checking that no IO happens when read_tier == kBlockCacheTier. The check is in effect for unit tests and for stress/crash tests. Specifically, an `EnforceReadOpts` object on the stack establishes a thread-local context under which we assert no IOs are performed if the provided ReadOptions said it should be forbidden. Test Plan: Reports failure before production code fix in facebook#12757
- Loading branch information
1 parent
d64eac2
commit cc86a22
Showing
8 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Meta Platforms, Inc. and affiliates. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
|
||
#include "table/table_reader.h" | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
#ifndef NDEBUG | ||
namespace { | ||
// Thread local flags to connect different instances and calls to | ||
// EnforceReadOpts within a thread. | ||
thread_local bool tl_enforce_block_cache_tier = false; | ||
} // namespace | ||
|
||
EnforceReadOpts::EnforceReadOpts(const ReadOptions& read_opts) { | ||
saved_enforce_block_cache_tier = tl_enforce_block_cache_tier; | ||
if (read_opts.read_tier == ReadTier::kBlockCacheTier) { | ||
tl_enforce_block_cache_tier = true; | ||
} else { | ||
// We should not be entertaining a full read in a context only allowing | ||
// memory-only reads. | ||
assert(tl_enforce_block_cache_tier == false); | ||
} | ||
} | ||
|
||
EnforceReadOpts::~EnforceReadOpts() { | ||
tl_enforce_block_cache_tier = saved_enforce_block_cache_tier; | ||
} | ||
|
||
void EnforceReadOpts::UsedIO() { assert(!tl_enforce_block_cache_tier); } | ||
#endif | ||
|
||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters