This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch feat/sidx-timerange in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit f0ec932d23c94059770d44eb44d3458e977f6d14 Author: Hongtao Gao <[email protected]> AuthorDate: Sat Mar 21 01:46:17 2026 +0000 fix(storage): prevent nil pointer panic in segment collectMetrics During shutdown, performCleanup could set s.index to nil after collectMetrics acquired its RLock but before accessing s.index.store, causing a race condition and panic. --- CHANGES.md | 1 + banyand/internal/storage/segment.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 625ba8559..5bd8a7296 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -49,6 +49,7 @@ Release Notes. - Fix memory part leak in syncPartContext Close and prevent double-release in FinishSync. - Fix segment reference leaks in measure/stream/trace queries and ensure chunked sync sessions close part contexts correctly. - Fix duplicate query execution in distributed measure Agg+TopN queries by enabling push-down aggregation, removing the wasteful double-query pattern. +- Fix nil pointer panic in segment collectMetrics during shutdown. ### Document diff --git a/banyand/internal/storage/segment.go b/banyand/internal/storage/segment.go index 2953ce3b5..f9ad6a122 100644 --- a/banyand/internal/storage/segment.go +++ b/banyand/internal/storage/segment.go @@ -197,6 +197,9 @@ func (s *segment[T, O]) initialize(ctx context.Context) error { func (s *segment[T, O]) collectMetrics() { s.mu.RLock() defer s.mu.RUnlock() + if s.index == nil { + return + } s.index.store.CollectMetrics(s.index.p.SegLabelValues()...) }
