Skip to content

Commit d64db70

Browse files
abhijatromange
authored andcommitted
replication: Ensure snapshot fiber joined in all code paths (#5171)
While replicating data through the incremental snapshot code path, if an error occurs, the journal callback id is not set. When finalizing the stream, this id is used to decide on early return. In the error code path mentioned above, the snapshot fiber may end up not being joined by the time the containing object is destroyed, triggering an assertion (and generally leaving things in an inconsistent state). To avoid this even if journal callback id is 0, we still wait for the snapshot fiber. Signed-off-by: Abhijat Malviya <abhijat@dragonflydb.io>
1 parent 28c2a0f commit d64db70

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/server/snapshot.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ void SliceSnapshot::FinalizeJournalStream(bool cancel) {
115115
VLOG(1) << "FinalizeJournalStream";
116116
DCHECK(db_slice_->shard_owner()->IsMyThread());
117117
if (!journal_cb_id_) { // Finalize only once.
118+
// In case of incremental snapshotting in StartIncremental, if an error is encountered,
119+
// journal_cb_id_ may not be set, but the snapshot fiber is still running.
120+
snapshot_fb_.JoinIfNeeded();
118121
return;
119122
}
120123
uint32_t cb_id = journal_cb_id_;

0 commit comments

Comments
 (0)