Skip to content

Commit

Permalink
fix: merge datanode bm25 error after reload growing segment with no d…
Browse files Browse the repository at this point in the history
…ata (#37154)

Segment with numrow 0 don't init bm25 stats, cause flush with bm25 stats
failed.
relate: #37150

Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd authored Oct 25, 2024
1 parent 05f8807 commit fd72151
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions internal/flushcommon/metacache/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func RollStats(newStats ...*storage.PrimaryKeyStats) SegmentAction {

func MergeBm25Stats(newStats map[int64]*storage.BM25Stats) SegmentAction {
return func(info *SegmentInfo) {
if info.bm25stats == nil {
info.bm25stats = NewEmptySegmentBM25Stats()
}
info.bm25stats.Merge(newStats)
}
}
Expand Down
11 changes: 10 additions & 1 deletion internal/flushcommon/syncmgr/storage_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (s *storageV1Serializer) EncodeBuffer(ctx context.Context, pack *SyncPack)
}
task.mergedStatsBlob = mergedStatsBlob

if len(pack.bm25Stats) > 0 {
if hasBM25Function(s.schema) {
mergedBM25Blob, err := s.serializeMergedBM25Stats(pack)
if err != nil {
log.Warn("failed to serialize merged bm25 stats log", zap.Error(err))
Expand Down Expand Up @@ -311,3 +311,12 @@ func (s *storageV1Serializer) serializeDeltalog(pack *SyncPack) (*storage.Blob,
writer.Close()
return finalizer()
}

func hasBM25Function(schema *schemapb.CollectionSchema) bool {
for _, function := range schema.GetFunctions() {
if function.GetType() == schemapb.FunctionType_BM25 {
return true
}
}
return false
}

0 comments on commit fd72151

Please sign in to comment.