mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
fix: Add EmptySessionWatcher to prevent panic in IndexNodeBinding mode (#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:
parent
d2e4278b18
commit
ea4bbbda3a
@ -528,6 +528,7 @@ func (s *Server) initServiceDiscovery() error {
|
|||||||
log.Warn("DataCoord failed to add datanode", zap.Error(err))
|
log.Warn("DataCoord failed to add datanode", zap.Error(err))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
s.dnSessionWatcher = sessionutil.EmptySessionWatcher()
|
||||||
} else {
|
} else {
|
||||||
err := s.rewatchDataNodes(sessions)
|
err := s.rewatchDataNodes(sessions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -806,6 +806,20 @@ func (w *sessionWatcher) Stop() {
|
|||||||
w.wg.Wait()
|
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
|
// WatchServices watches the service's up and down in etcd, and sends event to
|
||||||
// eventChannel.
|
// eventChannel.
|
||||||
// prefix is a parameter to know which service to watch and can be obtained in
|
// prefix is a parameter to know which service to watch and can be obtained in
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user