fix: [2.6] Add EmptySessionWatcher to prevent panic in IndexNodeBinding mode (#45912)

Cherry-pick from master
pr: #45911
Related to #45910

When IndexNodeBinding mode is enabled, DataCoord skips session watching
for datanodes but the dnSessionWatcher field remains nil. This causes a
panic when other code attempts to access the watcher.

This fix introduces an EmptySessionWatcher as a placeholder for the
IndexNodeBinding mode scenario. The empty watcher implements the
SessionWatcher interface with no-op methods, preventing nil pointer
dereferences while maintaining the expected interface contract.

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2025-11-28 10:21:08 +08:00 committed by GitHub
parent 1403bfdc68
commit 18493d5cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -520,6 +520,7 @@ func (s *Server) initServiceDiscovery() error {
log.Warn("DataCoord failed to add datanode", zap.Error(err))
return err
}
s.dnSessionWatcher = sessionutil.EmptySessionWatcher()
} else {
err := s.rewatchDataNodes(sessions)
if err != nil {

View File

@ -806,6 +806,20 @@ func (w *sessionWatcher) Stop() {
w.wg.Wait()
}
// EmptySessionWatcher returns a place holder for IndexNodeBinding mode datacoord
func EmptySessionWatcher() SessionWatcher {
return emptySessionWatcher{}
}
// emptySessionWatcher is a place holder for IndexNodeBinding mode datacoord
type emptySessionWatcher struct{}
func (emptySessionWatcher) EventChannel() <-chan *SessionEvent {
return nil
}
func (emptySessionWatcher) Stop() {}
// WatchServices watches the service's up and down in etcd, and sends event to
// eventChannel.
// prefix is a parameter to know which service to watch and can be obtained in