Skip to content

Commit

Permalink
fix deadlock in live migration conflict detection (#1742)
Browse files Browse the repository at this point in the history
  • Loading branch information
makalaaneesh authored Oct 9, 2024
1 parent 679efa4 commit 42064d8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion yb-voyager/cmd/conflictDetectionCache.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,16 @@ retry:
if c.eventsConfict(cachedEvent, incomingEvent) {
// flushing all the batches in channels instead of waiting for MAX_INTERVAL_BETWEEN_BATCHES
for i := 0; i < NUM_EVENT_CHANNELS; i++ {
c.evChans[i] <- FLUSH_BATCH_EVENT
// non-blocking send because blocking send can cause deadlock
// between main goroutine acquiring lock and blocking on sending to channel
// and processEvents goroutine waiting to acquire lock in RemoveEvents.
select {
case c.evChans[i] <- FLUSH_BATCH_EVENT:
default:
// channel is full, so it's okay not to send FLUSH_BATCH_EVENT
// because MAX_EVENTS_PER_BATCH would likely be reached in the next batch.
log.Infof("channel %d is full with size %d, not sending FLUSH_BATCH_EVENT", i, len(c.evChans[i]))
}
}
log.Infof("waiting for event(vsn=%d) to be complete before processing event(vsn=%d)", cachedEvent.Vsn, incomingEvent.Vsn)
// wait will release the lock and wait for a broadcast signal
Expand Down

0 comments on commit 42064d8

Please sign in to comment.