diff --git a/internal/querynodev2/segments/segment_loader.go b/internal/querynodev2/segments/segment_loader.go index 4d0a0eb37c..b3164ab74c 100644 --- a/internal/querynodev2/segments/segment_loader.go +++ b/internal/querynodev2/segments/segment_loader.go @@ -1642,7 +1642,15 @@ func (loader *segmentLoader) LoadIndex(ctx context.Context, segment *LocalSegmen indexInfo := lo.Map(infos, func(info *querypb.SegmentLoadInfo, _ int) *querypb.SegmentLoadInfo { info = typeutil.Clone(info) - info.BinlogPaths = nil + // remain binlog paths whose field id is in index infos to estimate resource usage correctly + indexFields := typeutil.NewSet(lo.Map(info.GetIndexInfos(), func(indexInfo *querypb.FieldIndexInfo, _ int) int64 { return indexInfo.GetFieldID() })...) + var binlogPaths []*datapb.FieldBinlog + for _, binlog := range info.GetBinlogPaths() { + if indexFields.Contain(binlog.GetFieldID()) { + binlogPaths = append(binlogPaths, binlog) + } + } + info.BinlogPaths = binlogPaths info.Deltalogs = nil info.Statslogs = nil return info diff --git a/internal/querynodev2/segments/segment_loader_test.go b/internal/querynodev2/segments/segment_loader_test.go index 7261a29614..960857b37e 100644 --- a/internal/querynodev2/segments/segment_loader_test.go +++ b/internal/querynodev2/segments/segment_loader_test.go @@ -42,6 +42,7 @@ import ( "github.com/milvus-io/milvus/internal/util/typeutil" "github.com/milvus-io/milvus/pkg/common" "github.com/milvus-io/milvus/pkg/util/funcutil" + "github.com/milvus-io/milvus/pkg/util/indexparamcheck" "github.com/milvus-io/milvus/pkg/util/merr" "github.com/milvus-io/milvus/pkg/util/metric" "github.com/milvus-io/milvus/pkg/util/paramtable" @@ -491,6 +492,46 @@ func (suite *SegmentLoaderSuite) TestLoadIndex() { suite.ErrorIs(err, merr.ErrIndexNotFound) } +func (suite *SegmentLoaderSuite) TestLoadIndexWithLimitedResource() { + ctx := context.Background() + loadInfo := &querypb.SegmentLoadInfo{ + SegmentID: 1, + PartitionID: suite.partitionID, + CollectionID: suite.collectionID, + IndexInfos: []*querypb.FieldIndexInfo{ + { + FieldID: 1, + IndexFilePaths: []string{}, + IndexParams: []*commonpb.KeyValuePair{ + { + Key: common.IndexTypeKey, + Value: indexparamcheck.IndexINVERTED, + }, + }, + }, + }, + BinlogPaths: []*datapb.FieldBinlog{ + { + FieldID: 1, + Binlogs: []*datapb.Binlog{ + { + LogSize: 1000000000, + }, + }, + }, + }, + } + + segment := &LocalSegment{ + baseSegment: baseSegment{ + loadInfo: atomic.NewPointer[querypb.SegmentLoadInfo](loadInfo), + }, + } + paramtable.Get().QueryNodeCfg.DiskCapacityLimit.SwapTempValue("100000") + err := suite.loader.LoadIndex(ctx, segment, loadInfo, 0) + suite.Error(err) +} + func (suite *SegmentLoaderSuite) TestLoadWithMmap() { key := paramtable.Get().QueryNodeCfg.MmapDirPath.Key paramtable.Get().Save(key, "/tmp/mmap-test")