Skip to content

Commit

Permalink
fix: proxy retry to get shard leader on unloaded collection (#37326)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
weiliu1031 authored Nov 5, 2024
1 parent 3806621 commit 6b69170
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/proxy/lb_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ 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
err := retry.Handle(ctx, func() (bool, error) {
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
Expand Down

0 comments on commit 6b69170

Please sign in to comment.