diff --git a/internal/querycoordv2/checkers/index_checker.go b/internal/querycoordv2/checkers/index_checker.go index f4eb8a8b6a..7d97c7492d 100644 --- a/internal/querycoordv2/checkers/index_checker.go +++ b/internal/querycoordv2/checkers/index_checker.go @@ -97,6 +97,13 @@ func (c *IndexChecker) Check(ctx context.Context) []task.Task { log.Warn("collection released during check index", zap.Int64("collection", collectionID)) continue } + if schema == nil && paramtable.Get().CommonCfg.EnabledJSONKeyStats.GetAsBool() { + collectionSchema, err1 := c.broker.DescribeCollection(ctx, collectionID) + if err1 == nil { + schema = collectionSchema.GetSchema() + c.meta.PutCollectionSchema(ctx, collectionID, collectionSchema.GetSchema()) + } + } replicas := c.meta.ReplicaManager.GetByCollection(ctx, collectionID) for _, replica := range replicas { tasks = append(tasks, c.checkReplica(ctx, collection, replica, indexInfos, schema)...) diff --git a/internal/querycoordv2/meta/collection_manager.go b/internal/querycoordv2/meta/collection_manager.go index 0d8e5600ed..aceb0f4853 100644 --- a/internal/querycoordv2/meta/collection_manager.go +++ b/internal/querycoordv2/meta/collection_manager.go @@ -266,6 +266,17 @@ func (m *CollectionManager) GetCollectionSchema(ctx context.Context, collectionI return collection.Schema } +func (m *CollectionManager) PutCollectionSchema(ctx context.Context, collectionID typeutil.UniqueID, schema *schemapb.CollectionSchema) { + m.rwmutex.Lock() + defer m.rwmutex.Unlock() + + collection, ok := m.collections[collectionID] + if !ok { + return + } + collection.Schema = schema +} + func (m *CollectionManager) GetPartition(ctx context.Context, partitionID typeutil.UniqueID) *Partition { m.rwmutex.RLock() defer m.rwmutex.RUnlock()