fix: panic when streaming coord shutdown but query coord still work (#45696)

issue: #44984
pr: #45695

Signed-off-by: chyezh <chyezh@outlook.com>
This commit is contained in:
Zhen Ye 2025-11-20 12:05:09 +08:00 committed by GitHub
parent e4a85ab92e
commit 78c479ce9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,6 +67,7 @@ type StreamingNodeManager struct {
cond *syncutil.ContextCond
latestAssignments map[string]types.PChannelInfoAssigned // The latest assignments info got from streaming coord balance module.
nodeChangedNotifier *syncutil.VersionedNotifier // used to notify that node in streaming node manager has been changed.
previousNodeIDs typeutil.UniqueSet // used to store the previous node ids.
}
// GetBalancer returns the balancer of the streaming node manager.
@ -151,12 +152,15 @@ func (s *StreamingNodeManager) GetStreamingQueryNodeIDs() typeutil.UniqueSet {
}
streamingNodes, err := balancer.GetAllStreamingNodes(context.Background())
if err != nil {
panic(err)
// when the streaming coord is on shutdown, the balancer will return an error,
// causing panic, so we need to return the previous node ids.
return s.previousNodeIDs
}
streamingNodeIDs := typeutil.NewUniqueSet()
for _, streamingNode := range streamingNodes {
streamingNodeIDs.Insert(streamingNode.ServerID)
}
s.previousNodeIDs = streamingNodeIDs
return streamingNodeIDs
}