Skip to content

Commit

Permalink
Merge branch 'release-6.2' into release-6.2-28a8ffcf67f9
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer authored Jul 25, 2022
2 parents 61f2e02 + 824fddc commit 4fe3086
Show file tree
Hide file tree
Showing 12 changed files with 557 additions and 46 deletions.
386 changes: 376 additions & 10 deletions DEPS.bzl

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion br/pkg/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/pingcap/tidb/br/pkg/version"
"github.com/pingcap/tidb/domain"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/util/engine"
"github.com/tikv/client-go/v2/oracle"
"github.com/tikv/client-go/v2/tikv"
"github.com/tikv/client-go/v2/txnkv/txnlock"
Expand Down Expand Up @@ -100,7 +101,7 @@ func GetAllTiKVStores(
j := 0
for _, store := range stores {
isTiFlash := false
if version.IsTiFlash(store) {
if engine.IsTiFlash(store) {
if storeBehavior == SkipTiFlash {
continue
} else if storeBehavior == ErrorOnTiFlash {
Expand Down
7 changes: 4 additions & 3 deletions br/pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/engine"
"github.com/pingcap/tidb/util/mathutil"
tikverror "github.com/tikv/client-go/v2/error"
"github.com/tikv/client-go/v2/oracle"
Expand Down Expand Up @@ -501,15 +502,15 @@ func (local *local) checkMultiIngestSupport(ctx context.Context) error {

hasTiFlash := false
for _, s := range stores {
if s.State == metapb.StoreState_Up && version.IsTiFlash(s) {
if s.State == metapb.StoreState_Up && engine.IsTiFlash(s) {
hasTiFlash = true
break
}
}

for _, s := range stores {
// skip stores that are not online
if s.State != metapb.StoreState_Up || version.IsTiFlash(s) {
if s.State != metapb.StoreState_Up || engine.IsTiFlash(s) {
continue
}
var err error
Expand Down Expand Up @@ -1994,7 +1995,7 @@ func getRegionSplitSizeKeys(ctx context.Context, cli pd.Client, tls *common.TLS)
return 0, 0, err
}
for _, store := range stores {
if store.StatusAddress == "" || version.IsTiFlash(store) {
if store.StatusAddress == "" || engine.IsTiFlash(store) {
continue
}
serverInfo := infoschema.ServerInfo{
Expand Down
14 changes: 7 additions & 7 deletions br/pkg/lightning/backend/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ import (
"github.com/pingcap/tidb/br/pkg/pdutil"
"github.com/pingcap/tidb/br/pkg/restore"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/br/pkg/version"
tidbkv "github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/sessionctx/stmtctx"
"github.com/pingcap/tidb/tablecodec"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/codec"
"github.com/pingcap/tidb/util/engine"
"github.com/pingcap/tidb/util/hack"
"github.com/stretchr/testify/require"
pd "github.com/tikv/pd/client"
Expand Down Expand Up @@ -1022,7 +1022,7 @@ func TestMultiIngest(t *testing.T) {
return store.State == metapb.StoreState_Up
},
func(s *metapb.Store) bool {
return !version.IsTiFlash(s)
return !engine.IsTiFlash(s)
},
0,
nil,
Expand All @@ -1035,7 +1035,7 @@ func TestMultiIngest(t *testing.T) {
return store.State == metapb.StoreState_Up
},
func(s *metapb.Store) bool {
return version.IsTiFlash(s)
return engine.IsTiFlash(s)
},
0,
nil,
Expand Down Expand Up @@ -1071,10 +1071,10 @@ func TestMultiIngest(t *testing.T) {
// test all non-tiflash stores that support multi ingests
{
func(store *metapb.Store) bool {
return !version.IsTiFlash(store)
return !engine.IsTiFlash(store)
},
func(s *metapb.Store) bool {
return !version.IsTiFlash(s)
return !engine.IsTiFlash(s)
},
0,
nil,
Expand Down Expand Up @@ -1110,7 +1110,7 @@ func TestMultiIngest(t *testing.T) {
// test grpc return error but no tiflash
{
func(store *metapb.Store) bool {
return !version.IsTiFlash(store)
return !engine.IsTiFlash(store)
},
func(s *metapb.Store) bool {
return true
Expand All @@ -1123,7 +1123,7 @@ func TestMultiIngest(t *testing.T) {
// test grpc return error and contains offline tiflash
{
func(store *metapb.Store) bool {
return !version.IsTiFlash(store) || store.State != metapb.StoreState_Up
return !engine.IsTiFlash(store) || store.State != metapb.StoreState_Up
},
func(s *metapb.Store) bool {
return true
Expand Down
14 changes: 3 additions & 11 deletions br/pkg/lightning/restore/check_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/pingcap/tidb/store/pdtypes"
"github.com/pingcap/tidb/table"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/engine"
"github.com/pingcap/tidb/util/mathutil"
"go.uber.org/zap"
"golang.org/x/exp/slices"
Expand Down Expand Up @@ -169,15 +170,6 @@ func (rc *Controller) ClusterIsAvailable(ctx context.Context) {
}
}

func isTiFlash(store *pdtypes.MetaStore) bool {
for _, label := range store.Labels {
if label.Key == "engine" && label.Value == "tiflash" {
return true
}
}
return false
}

func (rc *Controller) checkEmptyRegion(ctx context.Context) error {
passed := true
message := "Cluster doesn't have too many empty regions"
Expand Down Expand Up @@ -228,7 +220,7 @@ func (rc *Controller) checkEmptyRegion(ctx context.Context) error {
if metapb.StoreState(metapb.StoreState_value[store.Store.StateName]) != metapb.StoreState_Up {
continue
}
if isTiFlash(store.Store) {
if engine.IsTiFlash(store.Store.Store) {
continue
}
if regionCnt > errorThrehold {
Expand Down Expand Up @@ -272,7 +264,7 @@ func (rc *Controller) checkRegionDistribution(ctx context.Context) error {
if metapb.StoreState(metapb.StoreState_value[store.Store.StateName]) != metapb.StoreState_Up {
continue
}
if isTiFlash(store.Store) {
if engine.IsTiFlash(store.Store.Store) {
continue
}
stores = append(stores, store)
Expand Down
13 changes: 2 additions & 11 deletions br/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/br/pkg/version/build"
"github.com/pingcap/tidb/sessionctx/variable"
"github.com/pingcap/tidb/util/engine"
pd "github.com/tikv/pd/client"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -71,16 +72,6 @@ func checkTiFlashVersion(store *metapb.Store) error {
return nil
}

// IsTiFlash tests whether the store is based on tiflash engine.
func IsTiFlash(store *metapb.Store) bool {
for _, label := range store.Labels {
if label.Key == "engine" && label.Value == "tiflash" {
return true
}
}
return false
}

// VerChecker is a callback for the CheckClusterVersion, decides whether the cluster is suitable to execute restore.
// See also: CheckVersionForBackup and CheckVersionForBR.
type VerChecker func(store *metapb.Store, ver *semver.Version) error
Expand All @@ -92,7 +83,7 @@ func CheckClusterVersion(ctx context.Context, client pd.Client, checker VerCheck
return errors.Trace(err)
}
for _, s := range stores {
isTiFlash := IsTiFlash(s)
isTiFlash := engine.IsTiFlash(s)
log.Debug("checking compatibility of store in cluster",
zap.Uint64("ID", s.GetId()),
zap.Bool("TiFlash?", isTiFlash),
Expand Down
5 changes: 3 additions & 2 deletions domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"github.com/pingcap/tidb/types"
util2 "github.com/pingcap/tidb/util"
"github.com/pingcap/tidb/util/dbterror"
"github.com/pingcap/tidb/util/engine"
"github.com/pingcap/tidb/util/hack"
"github.com/pingcap/tidb/util/logutil"
"github.com/pingcap/tidb/util/pdapi"
Expand Down Expand Up @@ -450,8 +451,8 @@ func CheckTiKVVersion(store kv.Storage, minVersion semver.Version) error {
return err
}
for _, s := range stores {
// empty version means the store is a mock store.
if s.Version == "" {
// empty version means the store is a mock store. Don't require tiflash version either.
if s.Version == "" || engine.IsTiFlash(s) {
continue
}
ver, err := semver.NewVersion(removeVAndHash(s.Version))
Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,26 @@ require (
github.com/kyoh86/exportloopref v0.1.8
github.com/mgechev/revive v1.2.1
github.com/nishanths/predeclared v0.2.2
github.com/prometheus/prometheus v0.0.0-20190525122359-d20e84d0fb64
github.com/tdakkota/asciicheck v0.1.1
honnef.co/go/tools v0.3.1
)

require (
cloud.google.com/go/compute v1.5.0 // indirect
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/googleapis/gax-go/v2 v2.2.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/kisielk/gotool v1.0.0 // indirect
github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/prometheus/tsdb v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb // indirect
Expand Down
Loading

0 comments on commit 4fe3086

Please sign in to comment.