fix(bug): access invalid prime table iterator (#2300)

The bug:
When running dragonfly in cache mode we bump up items on dash table when we find them. If we access few items on the callback that reside next to each other we will invalidate the first found iterator.

The fix:
After we bump up entry we insert the prime table ref to bump set. When checking if we can bump down an item we check the item is not in this set. Once we finish running the transaction callback we clear the set.

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2023-12-20 13:05:29 +02:00 committed by GitHub
parent 6c32c8004d
commit 6398a73942
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 16 deletions

View file

@ -497,6 +497,7 @@ bool Transaction::RunInShard(EngineShard* shard, bool txq_ooo) {
if (is_concluding) // Check last hop
LogAutoJournalOnShard(shard);
shard->db_slice().OnCbFinish();
// at least the coordinator thread owns the reference.
DCHECK_GE(GetUseCount(), 1u);
@ -950,7 +951,7 @@ void Transaction::RunQuickie(EngineShard* shard) {
} catch (std::exception& e) {
LOG(FATAL) << "Unexpected exception " << e.what();
}
shard->db_slice().OnCbFinish();
LogAutoJournalOnShard(shard);
sd.is_armed.store(false, memory_order_relaxed);
@ -1238,6 +1239,7 @@ OpStatus Transaction::RunSquashedMultiCb(RunnableType cb) {
DCHECK_EQ(unique_shard_cnt_, 1u);
auto* shard = EngineShard::tlocal();
auto status = cb(this, shard);
shard->db_slice().OnCbFinish();
LogAutoJournalOnShard(shard);
return status;
}