From 4d9d9cf48fda0c3216bd68efff9e77072a8c17d1 Mon Sep 17 00:00:00 2001 From: Ahsan Barkati Date: Wed, 29 Sep 2021 15:41:42 +0530 Subject: [PATCH 1/2] Do not retry restore proposal --- worker/online_restore.go | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/worker/online_restore.go b/worker/online_restore.go index e4df6494901..03f6345e829 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -22,7 +22,6 @@ import ( "path/filepath" "strings" "sync" - "time" "github.com/golang/glog" "github.com/minio/minio-go/v6/pkg/credentials" @@ -177,7 +176,7 @@ func ProcessRestoreRequest(ctx context.Context, req *pb.RestoreRequest, wg *sync reqCopy.GroupId = gid wg.Add(1) go func() { - errCh <- tryRestoreProposal(ctx, reqCopy) + errCh <- proposeRestoreOrSend(ctx, req) }() } @@ -209,41 +208,6 @@ func proposeRestoreOrSend(ctx context.Context, req *pb.RestoreRequest) error { return err } -func retriableRestoreError(err error) bool { - switch { - case err == conn.ErrNoConnection: - // Try to recover from temporary connection issues. - return true - case strings.Contains(err.Error(), "Raft isn't initialized yet"): - // Try to recover if raft has not been initialized. - return true - case strings.Contains(err.Error(), errRestoreProposal): - // Do not try to recover from other errors when sending the proposal. - return false - default: - // Try to recover from other errors (e.g wrong group, waiting for timestamp, etc). - return true - } -} - -func tryRestoreProposal(ctx context.Context, req *pb.RestoreRequest) error { - var err error - for i := 0; i < 10; i++ { - err = proposeRestoreOrSend(ctx, req) - if err == nil { - glog.Info("proposeRestoreOrSend done.") - return nil - } - glog.Errorf("Got error while proposeRestoreOrSend: %v, will retry...\n", err) - if retriableRestoreError(err) { - time.Sleep(time.Second) - continue - } - return err - } - return err -} - // Restore implements the Worker interface. func (w *grpcWorker) Restore(ctx context.Context, req *pb.RestoreRequest) (*pb.Status, error) { var emptyRes pb.Status From 8659ff162233af29bf1b31573b7b2d1ecf8af182 Mon Sep 17 00:00:00 2001 From: Ahsan Barkati Date: Thu, 30 Sep 2021 16:17:20 +0530 Subject: [PATCH 2/2] Minor change --- worker/online_restore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/online_restore.go b/worker/online_restore.go index 03f6345e829..e5e0c5b17b3 100644 --- a/worker/online_restore.go +++ b/worker/online_restore.go @@ -176,7 +176,7 @@ func ProcessRestoreRequest(ctx context.Context, req *pb.RestoreRequest, wg *sync reqCopy.GroupId = gid wg.Add(1) go func() { - errCh <- proposeRestoreOrSend(ctx, req) + errCh <- proposeRestoreOrSend(ctx, reqCopy) }() }