Skip to content

Commit

Permalink
changefeedccl: Fix potential shutdown NPE
Browse files Browse the repository at this point in the history
A flow may be cancelled immediately after it's created,
before it has `Start`ed.  If this happens, change aggregator
may panic because certain state may not be initialized.

Fixes #110772

Release note: None
  • Loading branch information
Yevgeniy Miretskiy committed Sep 16, 2023
1 parent c30cb16 commit 004cb4d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/ccl/changefeedccl/changefeed_processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,11 @@ func (ca *changeAggregator) close() {
if ca.Closed {
return
}
if ca.cancel == nil {
// consumer close may be called even before Start is called.
// If that's the case, cancel is not initialized.
return
}
ca.cancel()
// Wait for the poller to finish shutting down.
if ca.kvFeedDoneCh != nil {
Expand Down

0 comments on commit 004cb4d

Please sign in to comment.