From cacac66c9369e2d805c710729fc2ad1bdeef9c49 Mon Sep 17 00:00:00 2001 From: congqixia Date: Thu, 12 Dec 2024 17:18:43 +0800 Subject: [PATCH] fix: [2.4] Check target partition load state only when dropping partition (#38375) (#38394) Cherry pick from master pr: #38375 Related to #38372 This PR make drop partition only check target partition load states only in case of concurrent releasing other partition in same collection. --------- Signed-off-by: Congqi Xia --- internal/proxy/util.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/internal/proxy/util.go b/internal/proxy/util.go index bc37e9a94cb34..0c5274a37d38e 100644 --- a/internal/proxy/util.go +++ b/internal/proxy/util.go @@ -47,6 +47,7 @@ import ( "github.com/milvus-io/milvus/pkg/util/commonpbutil" "github.com/milvus-io/milvus/pkg/util/contextutil" "github.com/milvus-io/milvus/pkg/util/crypto" + "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" @@ -1302,23 +1303,17 @@ func isPartitionLoaded(ctx context.Context, qc types.QueryCoordClient, collID in // get all loading collections resp, err := qc.ShowPartitions(ctx, &querypb.ShowPartitionsRequest{ CollectionID: collID, - PartitionIDs: nil, + PartitionIDs: partIDs, }) - if err != nil { + if err := merr.CheckRPCCall(resp, err); err != nil { + // qc returns error if partition not loaded + if errors.Is(err, merr.ErrPartitionNotLoaded) { + return false, nil + } return false, err } - if resp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success { - return false, merr.Error(resp.GetStatus()) - } - for _, loadedPartID := range resp.GetPartitionIDs() { - for _, partID := range partIDs { - if partID == loadedPartID { - return true, nil - } - } - } - return false, nil + return funcutil.SliceSetEqual(partIDs, resp.GetPartitionIDs()), nil } func checkFieldsDataBySchema(schema *schemapb.CollectionSchema, insertMsg *msgstream.InsertMsg, inInsert bool) error {