From 59893643f6aafc79c9591c8253b08475bec6ceda Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Tue, 21 May 2024 19:11:47 +0800 Subject: [PATCH] external: remove old compatibility check of BR (#50534) (#51340) close pingcap/tidb#50533 --- br/pkg/storage/gcs.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/br/pkg/storage/gcs.go b/br/pkg/storage/gcs.go index 5ee83f286155f..2ea13c5fd2743 100644 --- a/br/pkg/storage/gcs.go +++ b/br/pkg/storage/gcs.go @@ -13,10 +13,8 @@ import ( "cloud.google.com/go/storage" "github.com/pingcap/errors" backuppb "github.com/pingcap/kvproto/pkg/brpb" - "github.com/pingcap/log" berrors "github.com/pingcap/tidb/br/pkg/errors" "github.com/spf13/pflag" - "go.uber.org/zap" "golang.org/x/oauth2/google" "google.golang.org/api/iterator" "google.golang.org/api/option" @@ -336,42 +334,9 @@ func NewGCSStorage(ctx context.Context, gcs *backuppb.GCS, opts *ExternalStorage } bucket := client.Bucket(gcs.Bucket) - // check whether it's a bug before #647, to solve case #2 - // If the storage is set as gcs://bucket/prefix/, - // the backupmeta is written correctly to gcs://bucket/prefix/backupmeta, - // but the SSTs are written wrongly to gcs://bucket/prefix//*.sst (note the extra slash). - // see details about case 2 at https://github.com/pingcap/br/issues/675#issuecomment-753780742 - sstInPrefix := hasSSTFiles(ctx, bucket, gcs.Prefix) - sstInPrefixSlash := hasSSTFiles(ctx, bucket, gcs.Prefix+"//") - if sstInPrefixSlash && !sstInPrefix { - // This is a old bug, but we must make it compatible. - // so we need find sst in slash directory - gcs.Prefix += "//" - } return &GCSStorage{gcs: gcs, bucket: bucket}, nil } -func hasSSTFiles(ctx context.Context, bucket *storage.BucketHandle, prefix string) bool { - query := storage.Query{Prefix: prefix} - _ = query.SetAttrSelection([]string{"Name"}) - it := bucket.Objects(ctx, &query) - for { - attrs, err := it.Next() - if err == iterator.Done { // nolint:errorlint - break - } - if err != nil { - log.Warn("failed to list objects on gcs, will use default value for `prefix`", zap.Error(err)) - break - } - if strings.HasSuffix(attrs.Name, ".sst") { - log.Info("sst file found in prefix slash", zap.String("file", attrs.Name)) - return true - } - } - return false -} - // gcsObjectReader wrap storage.Reader and add the `Seek` method. type gcsObjectReader struct { storage *GCSStorage