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