mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
bug(replication): fix deadlock in cancle replication flow (#1007)
Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
44c477142a
commit
0312b66244
4 changed files with 15 additions and 20 deletions
|
@ -25,11 +25,17 @@ uint64_t JournalStreamer::GetRecordCount() const {
|
|||
}
|
||||
|
||||
void JournalStreamer::Cancel() {
|
||||
Finalize(); // Finalize must be called before UnregisterOnChange because we first need to stop
|
||||
// writing to buffer and notify the all the producers.
|
||||
// Writing to journal holds mutex protecting change_cb_arr_, than the fiber can
|
||||
// preemt when calling NotifyWritten and it will not run again till notified.
|
||||
// UnregisterOnChange will try to lock the mutex therefor calling UnregisterOnChange
|
||||
// before Finalize may cause deadlock.
|
||||
journal_->UnregisterOnChange(journal_cb_id_);
|
||||
Finalize();
|
||||
|
||||
if (write_fb_.IsJoinable())
|
||||
if (write_fb_.IsJoinable()) {
|
||||
write_fb_.Join();
|
||||
}
|
||||
}
|
||||
|
||||
void JournalStreamer::WriterFb(io::Sink* dest) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue