From 004cb4dfcb3dfb800ce70a5e84105bbf6be2abeb Mon Sep 17 00:00:00 2001 From: Yevgeniy Miretskiy Date: Sat, 16 Sep 2023 19:43:27 +0000 Subject: [PATCH] changefeedccl: Fix potential shutdown NPE 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 --- pkg/ccl/changefeedccl/changefeed_processors.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/ccl/changefeedccl/changefeed_processors.go b/pkg/ccl/changefeedccl/changefeed_processors.go index 8942f8cd60ef..6ae183b80064 100644 --- a/pkg/ccl/changefeedccl/changefeed_processors.go +++ b/pkg/ccl/changefeedccl/changefeed_processors.go @@ -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 {