This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch patch-seg-ref in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit aa2a7e080f9e0765eb5d756e46d77ab8478d32a3 Author: Gao Hongtao <[email protected]> AuthorDate: Wed Jul 17 12:57:03 2024 +0800 Increase Seg Ref Count Wrongly Signed-off-by: Gao Hongtao <[email protected]> --- CHANGES.md | 1 + banyand/internal/storage/segment.go | 1 - banyand/measure/tstable.go | 4 ++-- banyand/stream/tstable.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8ab401c5..d3362043 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,7 @@ Release Notes. - Fix memory leak in sorting the stream by the inverted index. - Fix the wrong array flags parsing in command line. The array flags should be parsed by "StringSlice" instead of "StringArray". - Fix a bug that the Stream module didn't support duplicated in index-based filtering and sorting +- Fix the bug that segment's reference count is increased twice when the controller try to create an existing segment. ## 0.6.1 diff --git a/banyand/internal/storage/segment.go b/banyand/internal/storage/segment.go index 507846d6..8138244d 100644 --- a/banyand/internal/storage/segment.go +++ b/banyand/internal/storage/segment.go @@ -244,7 +244,6 @@ func (sc *segmentController[T, O]) create(start time.Time) (*segment[T], error) for i := range sc.lst { s := sc.lst[last-i] if s.Contains(start.UnixNano()) { - s.incRef() return s, nil } } diff --git a/banyand/measure/tstable.go b/banyand/measure/tstable.go index e65aef6e..d2a20b4a 100644 --- a/banyand/measure/tstable.go +++ b/banyand/measure/tstable.go @@ -235,8 +235,8 @@ func (tst *tsTable) Close() error { tst.loopCloser.Done() tst.loopCloser.CloseThenWait() } - tst.RLock() - defer tst.RUnlock() + tst.Lock() + defer tst.Unlock() if tst.snapshot == nil { return nil } diff --git a/banyand/stream/tstable.go b/banyand/stream/tstable.go index 6fbad53a..dff93b39 100644 --- a/banyand/stream/tstable.go +++ b/banyand/stream/tstable.go @@ -248,8 +248,8 @@ func (tst *tsTable) Close() error { tst.loopCloser.Done() tst.loopCloser.CloseThenWait() } - tst.RLock() - defer tst.RUnlock() + tst.Lock() + defer tst.Unlock() if tst.snapshot == nil { return tst.index.Close() }
