mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
bug(server): log evicted keys in journal in PrimeEvictionPolicy. (#2302)
fixes #2296 added a regression test that tests both policy based eviction as well as heart beat eviction. --------- Signed-off-by: Yue Li <61070669+theyueli@users.noreply.github.com>
This commit is contained in:
parent
9fe7d038b7
commit
8d09478474
3 changed files with 99 additions and 1 deletions
|
@ -249,6 +249,20 @@ unsigned PrimeEvictionPolicy::Evict(const PrimeTable::HotspotBuckets& eb, PrimeT
|
|||
}
|
||||
|
||||
DbTable* table = db_slice_->GetDBTable(cntx_.db_index);
|
||||
auto& lt = table->trans_locks;
|
||||
string tmp;
|
||||
string_view key = last_slot_it->first.GetSlice(&tmp);
|
||||
// do not evict locked keys
|
||||
if (lt.find(KeyLockArgs::GetLockKey(key)) != lt.end())
|
||||
return 0;
|
||||
|
||||
// log the evicted keys to journal.
|
||||
if (auto journal = db_slice_->shard_owner()->journal(); journal) {
|
||||
ArgSlice delete_args{key};
|
||||
journal->RecordEntry(0, journal::Op::EXPIRED, cntx_.db_index, 1, ClusterConfig::KeySlot(key),
|
||||
make_pair("DEL", delete_args), false);
|
||||
}
|
||||
|
||||
db_slice_->PerformDeletion(last_slot_it, db_slice_->shard_owner(), table);
|
||||
++evicted_;
|
||||
}
|
||||
|
@ -1260,7 +1274,7 @@ void DbSlice::FreeMemWithEvictionStep(DbIndex db_ind, size_t increase_goal_bytes
|
|||
continue;
|
||||
|
||||
if (auto journal = owner_->journal(); journal) {
|
||||
keys_to_journal.push_back(tmp);
|
||||
keys_to_journal.push_back(string(key));
|
||||
}
|
||||
|
||||
PerformDeletion(evict_it, shard_owner(), db_table.get());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue