enhance: Remove partition load infos with prefix (#28969)

Removing partition load infos with prefix instead of removing them one
by one. This enhance can save transactions.

issue: https://github.com/milvus-io/milvus/issues/28343

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
This commit is contained in:
yihao.dai 2023-12-05 12:52:34 +08:00 committed by GitHub
parent e2d0333831
commit 7f819ac594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,26 +192,14 @@ func (s Catalog) GetResourceGroups() ([]*querypb.ResourceGroup, error) {
}
func (s Catalog) ReleaseCollection(collection int64) error {
// obtain partitions of this collection
_, values, err := s.cli.LoadWithPrefix(fmt.Sprintf("%s/%d", PartitionLoadInfoPrefix, collection))
if err != nil {
return err
}
partitionIDs := make([]int64, 0)
for _, v := range values {
info := querypb.PartitionLoadInfo{}
if err = proto.Unmarshal([]byte(v), &info); err != nil {
return err
}
partitionIDs = append(partitionIDs, (&info).GetPartitionID())
}
// remove collection and obtained partitions
collectionKey := EncodeCollectionLoadInfoKey(collection)
err = s.cli.Remove(collectionKey)
err := s.cli.Remove(collectionKey)
if err != nil {
return err
}
return s.ReleasePartition(collection, partitionIDs...)
partitionsPrefix := fmt.Sprintf("%s/%d", PartitionLoadInfoPrefix, collection)
return s.cli.RemoveWithPrefix(partitionsPrefix)
}
func (s Catalog) ReleasePartition(collection int64, partitions ...int64) error {