未验证 提交 99b958e3 编写于 作者: X Xiaofan 提交者: GitHub

Fix BF Concurrency issue (#20211)

Signed-off-by: Nxiaofan-luan <xiaofan.luan@zilliz.com>
Signed-off-by: Nxiaofan-luan <xiaofan.luan@zilliz.com>
上级 4f93dbc3
......@@ -17,6 +17,7 @@
package datanode
import (
"sync"
"sync/atomic"
"github.com/bits-and-blooms/bloom/v3"
......@@ -36,6 +37,7 @@ type Segment struct {
memorySize int64
compactedTo UniqueID
statLock sync.Mutex
currentStat *storage.PkStatistics
historyStats []*storage.PkStatistics
......@@ -70,6 +72,8 @@ func (s *Segment) setType(t datapb.SegmentType) {
}
func (s *Segment) updatePKRange(ids storage.FieldData) {
s.statLock.Lock()
defer s.statLock.Unlock()
s.InitCurrentStat()
err := s.currentStat.UpdatePKRange(ids)
if err != nil {
......@@ -87,6 +91,8 @@ func (s *Segment) InitCurrentStat() {
// check if PK exists is current
func (s *Segment) isPKExist(pk primaryKey) bool {
s.statLock.Lock()
defer s.statLock.Unlock()
if s.currentStat != nil && s.currentStat.PkExist(pk) {
return true
}
......
......@@ -95,6 +95,7 @@ type Segment struct {
indexedFieldInfos *typeutil.ConcurrentMap[UniqueID, *IndexedFieldInfo]
statLock sync.Mutex
// only used by sealed segments
currentStat *storage.PkStatistics
historyStats []*storage.PkStatistics
......@@ -618,6 +619,8 @@ func (s *Segment) fillIndexedFieldsData(ctx context.Context, collectionID Unique
}
func (s *Segment) updateBloomFilter(pks []primaryKey) {
s.statLock.Lock()
defer s.statLock.Unlock()
s.InitCurrentStat()
buf := make([]byte, 8)
for _, pk := range pks {
......@@ -647,6 +650,8 @@ func (s *Segment) InitCurrentStat() {
// check if PK exists is current
func (s *Segment) isPKExist(pk primaryKey) bool {
s.statLock.Lock()
defer s.statLock.Unlock()
if s.currentStat != nil && s.currentStat.PkExist(pk) {
return true
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册