diff --git a/src/server/db_slice.cc b/src/server/db_slice.cc index 88f18696b555..012e45e65985 100644 --- a/src/server/db_slice.cc +++ b/src/server/db_slice.cc @@ -1478,9 +1478,13 @@ void DbSlice::PerformDeletion(Iterator del_it, ExpIterator exp_it, DbTable* tabl } DbTableStats& stats = table->stats; - const PrimeValue& pv = del_it->second; + PrimeValue& pv = del_it->second; - if (pv.IsExternal() && shard_owner()->tiered_storage()) { + if (pv.HasStashPending()) { + string scratch; + string_view key = del_it->first.GetSlice(&scratch); + shard_owner()->tiered_storage()->CancelStash(table->index, key, &pv); + } else if (pv.IsExternal()) { shard_owner()->tiered_storage()->Delete(table->index, &del_it->second); } diff --git a/src/server/dfly_bench.cc b/src/server/dfly_bench.cc index 8d0d974a7222..8d2093a1cc79 100644 --- a/src/server/dfly_bench.cc +++ b/src/server/dfly_bench.cc @@ -487,7 +487,7 @@ void Driver::ParseRESP() { PopRequest(); } io_buf_.ConsumeInput(consumed); - } while (result == RedisParser::OK); + } while (result == RedisParser::OK && io_buf_.InputLen() > 0); } void Driver::ParseMC() { diff --git a/src/server/tiered_storage.cc b/src/server/tiered_storage.cc index eb323aab9c84..181320825057 100644 --- a/src/server/tiered_storage.cc +++ b/src/server/tiered_storage.cc @@ -391,7 +391,7 @@ bool TieredStorage::TryStash(DbIndex dbid, string_view key, PrimeValue* value) { return false; // This invariant should always hold because ShouldStash tests for IoPending flag. - DCHECK(!bins_->IsPending(dbid, key)); + 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. diff --git a/src/server/tiered_storage_test.cc b/src/server/tiered_storage_test.cc index 038d72e9c9c0..cb13032bb1b3 100644 --- a/src/server/tiered_storage_test.cc +++ b/src/server/tiered_storage_test.cc @@ -317,4 +317,13 @@ TEST_F(TieredStorageTest, MemoryPressure) { EXPECT_LT(used_mem_peak.load(), 20_MB); } +TEST_F(TieredStorageTest, Expiry) { + string val = BuildString(100); + Run({"psetex", "key1", "1", val}); + AdvanceTime(10); + Run({"psetex", "key1", "1", val}); + auto resp = Run({"get", "key1"}); + EXPECT_EQ(resp, val); +} + } // namespace dfly