diff --git a/src/server/db_slice.cc b/src/server/db_slice.cc index 769ae5ea8..70a12845b 100644 --- a/src/server/db_slice.cc +++ b/src/server/db_slice.cc @@ -152,7 +152,7 @@ bool PrimeEvictionPolicy::CanGrow(const PrimeTable& tbl) const { if (!apply_memory_limit_ || mem_budget_ > soft_limit_) return true; - DCHECK_LT(tbl.size(), tbl.capacity()); + DCHECK_LE(tbl.size(), tbl.capacity()); // We take a conservative stance here - // we estimate how much memory we will take with the current capacity diff --git a/src/server/dragonfly_test.cc b/src/server/dragonfly_test.cc index 0ad66e808..cde768de9 100644 --- a/src/server/dragonfly_test.cc +++ b/src/server/dragonfly_test.cc @@ -382,16 +382,15 @@ TEST_F(DflyEngineTest, OOM) { /// Reproduces the case where items with expiry data were evicted, /// and then written with the same key. TEST_F(DflyEngineTest, Bug207) { + max_memory_limit = 300000; shard_set->TEST_EnableHeartBeat(); shard_set->TEST_EnableCacheMode(); absl::FlagSaver fs; absl::SetFlag(&FLAGS_oom_deny_ratio, 4); - max_memory_limit = 300000; - ssize_t i = 0; RespExpr resp; - for (; i < 5000; ++i) { + for (; i < 10000; ++i) { resp = Run({"setex", StrCat("key", i), "30", "bar"}); // we evict some items because 5000 is too much when max_memory_limit is 300000. ASSERT_EQ(resp, "OK");