mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 09:55:45 +02:00
fix: fix RegisterOnChange methods for journal and db_slice (#3171)
* fix: fix RegisterOnChange methods for journal and db_slice. Call db_slice and journal callbacks atomically. Made a hack to avoid deadlock during SAVE
This commit is contained in:
parent
f66ee5f47d
commit
d75c79ce5c
6 changed files with 50 additions and 13 deletions
|
@ -627,6 +627,7 @@ void Transaction::RunCallback(EngineShard* shard) {
|
|||
DCHECK_EQ(shard, EngineShard::tlocal());
|
||||
|
||||
RunnableResult result;
|
||||
shard->db_slice().LockChangeCb();
|
||||
try {
|
||||
result = (*cb_ptr_)(this, shard);
|
||||
|
||||
|
@ -664,7 +665,10 @@ void Transaction::RunCallback(EngineShard* shard) {
|
|||
// Log to journal only once the command finished running
|
||||
if ((coordinator_state_ & COORD_CONCLUDING) || (multi_ && multi_->concluding)) {
|
||||
LogAutoJournalOnShard(shard, result);
|
||||
shard->db_slice().UnlockChangeCb();
|
||||
MaybeInvokeTrackingCb();
|
||||
} else {
|
||||
shard->db_slice().UnlockChangeCb();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1247,9 +1251,11 @@ OpStatus Transaction::RunSquashedMultiCb(RunnableType cb) {
|
|||
DCHECK_EQ(unique_shard_cnt_, 1u);
|
||||
|
||||
auto* shard = EngineShard::tlocal();
|
||||
shard->db_slice().LockChangeCb();
|
||||
auto result = cb(this, shard);
|
||||
shard->db_slice().OnCbFinish();
|
||||
LogAutoJournalOnShard(shard, result);
|
||||
shard->db_slice().UnlockChangeCb();
|
||||
MaybeInvokeTrackingCb();
|
||||
|
||||
DCHECK_EQ(result.flags, 0); // if it's sophisticated, we shouldn't squash it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue