Skip to content

Commit 421aca0

Browse files
authored
Recover panic in vcopier due to closed channel (vitessio#18228)
Signed-off-by: Noble Mittal <[email protected]>
1 parent 6c597f6 commit 421aca0

File tree

1 file changed

+6
-0
lines changed
  • go/vt/vttablet/tabletmanager/vreplication

1 file changed

+6
-0
lines changed

go/vt/vttablet/tabletmanager/vreplication/vcopier.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,12 @@ func (vrh *vcopierCopyTaskResultHooks) notify(ctx context.Context, result *vcopi
919919
// }()
920920
func (vrh *vcopierCopyTaskResultHooks) sendTo(ch chan<- *vcopierCopyTaskResult) {
921921
vrh.do(func(ctx context.Context, result *vcopierCopyTaskResult) {
922+
defer func() {
923+
// This recover prevents panics when sending to a potentially closed channel.
924+
if err := recover(); err != nil {
925+
log.Errorf("uncaught panic, vcopier copy task result: %v, error: %+v", result, err)
926+
}
927+
}()
922928
select {
923929
case ch <- result:
924930
case <-ctx.Done():

0 commit comments

Comments
 (0)