This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 197c6dfe Increase Seg Ref Count Wrongly (#489)
197c6dfe is described below
commit 197c6dfe01a87cae148904e19d33c2a068427b1f
Author: Gao Hongtao <[email protected]>
AuthorDate: Wed Jul 17 13:23:16 2024 +0800
Increase Seg Ref Count Wrongly (#489)
---
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()
}