Invalidate cache first when shard leader list contains error (#21451)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/21459/head
congqixia 2022-12-29 23:29:32 +08:00 committed by GitHub
parent 037ccccfcc
commit daa4492e95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -336,6 +336,8 @@ func (t *queryTask) Execute(ctx context.Context) error {
if err != nil {
log.Warn("invalid shard leaders cache, updating shardleader caches and retry query",
zap.Error(err))
// invalidate cache first, since ctx may be canceled or timeout here
globalMetaCache.ClearShards(t.collectionName)
err = executeQuery(WithoutCache)
}
if err != nil {

View File

@ -410,6 +410,8 @@ func (t *searchTask) Execute(ctx context.Context) error {
if err != nil {
log.Warn("first search failed, updating shardleader caches and retry search",
zap.Error(err))
// invalidate cache first, since ctx may be canceled or timeout here
globalMetaCache.ClearShards(t.collectionName)
err = executeSearch(WithoutCache)
}
if err != nil {

View File

@ -285,6 +285,8 @@ func (g *getStatisticsTask) getStatisticsFromQueryNode(ctx context.Context) erro
if errors.Is(err, errInvalidShardLeaders) || funcutil.IsGrpcErr(err) || errors.Is(err, grpcclient.ErrConnect) {
log.Warn("first get statistics failed, updating shard leader caches and retry",
zap.Error(err))
// invalidate cache first, since ctx may be canceled or timeout here
globalMetaCache.ClearShards(g.collectionName)
err = executeGetStatistics(WithoutCache)
}
if err != nil {