fix: proxy retry to get shard leader on unloaded collection (#37326)

issue: #37115

pr#37116 let proxy retry to get shard leader if error happens, which
cause if search/query on a unloaded collection, which will keep retrying
until ctx done.

This PR add error type check to skip retry on ErrCollectionLoaded.

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
wei liu 2024-11-05 11:02:25 +08:00 committed by GitHub
parent 380662153f
commit 6b69170a64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -98,6 +98,7 @@ func (lb *LBPolicyImpl) Start(ctx context.Context) {
}
}
// GetShardLeaders should always retry until ctx done, except the collection is not loaded.
func (lb *LBPolicyImpl) GetShardLeaders(ctx context.Context, dbName string, collName string, collectionID int64, withCache bool) (map[string][]nodeInfo, error) {
var shardLeaders map[string][]nodeInfo
// use retry to handle query coord service not ready
@ -105,7 +106,7 @@ func (lb *LBPolicyImpl) GetShardLeaders(ctx context.Context, dbName string, coll
var err error
shardLeaders, err = globalMetaCache.GetShards(ctx, withCache, dbName, collName, collectionID)
if err != nil {
return true, err
return !errors.Is(err, merr.ErrCollectionLoaded), err
}
return false, nil