Skip to content

Commit

Permalink
restore/collection: retry when call create collection fail (#517)
Browse files Browse the repository at this point in the history
Signed-off-by: huanghaoyuanhhy <haoyuan.huang@zilliz.com>
  • Loading branch information
huanghaoyuanhhy authored Jan 23, 2025
1 parent c19a566 commit 70794b6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/restore/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/zilliztech/milvus-backup/core/storage/mpath"
"github.com/zilliztech/milvus-backup/internal/common"
"github.com/zilliztech/milvus-backup/internal/log"
"github.com/zilliztech/milvus-backup/internal/util/retry"
)

const (
Expand Down Expand Up @@ -281,9 +282,11 @@ func (ct *CollectionTask) createColl(ctx context.Context) error {
ConsLevel: commonpb.ConsistencyLevel(ct.task.GetCollBackup().GetConsistencyLevel()),
ShardNum: shardNum,
}

if err := ct.grpcCli.CreateCollection(ctx, opt); err != nil {
return fmt.Errorf("restore_collection: failed to create collection: %w", err)
err = retry.Do(ctx, func() error {
return ct.grpcCli.CreateCollection(ctx, opt)
}, retry.Attempts(10), retry.Sleep(1*time.Second))
if err != nil {
return fmt.Errorf("restore_collection: call create collection api after retry: %w", err)
}

return nil
Expand Down

0 comments on commit 70794b6

Please sign in to comment.