Skip to content

Commit 1585357

Browse files
committed
Avoid blocking backfilling transaction if context is blocked while writing to the events channel
1 parent 0b096ef commit 1585357

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/sqlcache/informer/listoption_indexer.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,15 @@ func (l *ListOptionIndexer) Watch(ctx context.Context, opts WatchOptions, events
366366
continue
367367
}
368368

369-
eventsCh <- watch.Event{
369+
ev := watch.Event{
370370
Type: eventType,
371371
Object: obj,
372372
}
373+
select {
374+
case eventsCh <- ev:
375+
case <-ctx.Done():
376+
return ctx.Err()
377+
}
373378
}
374379
return rows.Err()
375380
}); err != nil {

0 commit comments

Comments
 (0)