chore: more debug checks around tiered storage (#3277)

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
Roman Gershman 2024-07-07 11:55:58 +03:00 committed by GitHub
parent 765be950af
commit ac328e1516
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View file

@ -275,6 +275,9 @@ bool TieredStorage::TryStash(DbIndex dbid, string_view key, PrimeValue* value) {
if (!ShouldStash(*value))
return false;
// This invariant should always hold because ShouldStash tests for IoPending flag.
CHECK(!bins_->IsPending(dbid, key));
// TODO: When we are low on memory we should introduce a back-pressure, to avoid OOMs
// with a lot of underutilized disk space.
if (op_manager_->GetStats().pending_stash_cnt >= write_depth_limit_) {

View file

@ -43,6 +43,11 @@ class SmallBins {
// List of item key db indices and hashes
using KeyHashDbList = std::vector<std::tuple<DbIndex, uint64_t /* hash */, DiskSegment>>;
// Returns true if the entry is pending inside SmallBins.
bool IsPending(DbIndex dbid, std::string_view key) const {
return current_bin_.count({dbid, std::string(key)}) > 0;
}
// Enqueue key/value pair for stash. Returns page to be stashed if it filled up.
std::optional<FilledBin> Stash(DbIndex dbid, std::string_view key, std::string_view value);