From a360a079199ff7290ab420fab212cd2ccf4a0e3e Mon Sep 17 00:00:00 2001 From: Xianhui Lin <35839735+JsDove@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:54:36 +0800 Subject: [PATCH] fix: jsonstats check if cache schema is nil lazy describecollection (#41075) fix: jsonstats check if cache schema is nil lazy describecollection pr:https://github.com/milvus-io/milvus/pull/38039 pr:https://github.com/milvus-io/milvus/pull/41068 issue:https://github.com/milvus-io/milvus/issues/36995 --------- Signed-off-by: chyezh Signed-off-by: Xianhui.Lin Co-authored-by: Zhen Ye --- internal/core/src/segcore/Utils.cpp | 2 +- internal/querycoordv2/checkers/index_checker.go | 7 +++++++ internal/querycoordv2/meta/collection_manager.go | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/internal/core/src/segcore/Utils.cpp b/internal/core/src/segcore/Utils.cpp index ffd144e73d..a04e62671f 100644 --- a/internal/core/src/segcore/Utils.cpp +++ b/internal/core/src/segcore/Utils.cpp @@ -879,7 +879,7 @@ LoadArrowReaderFromRemote(const std::vector& remote_files, futures; futures.reserve(remote_files.size()); for (const auto& file : remote_files) { - auto future = pool.Submit([&]() { + auto future = pool.Submit([rcm, file]() { auto fileSize = rcm->Size(file); auto buf = std::shared_ptr(new uint8_t[fileSize]); rcm->Read(file, buf.get(), fileSize); 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()