mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 20:09:57 +08:00
Fix BF Concurrency issue (#20211)
Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>
This commit is contained in:
parent
4f93dbc335
commit
99b958e360
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user