Skip to content

Commit

Permalink
backup: add version checker for store based backup (#54131)
Browse files Browse the repository at this point in the history
ref #52534
  • Loading branch information
3pointer authored Jun 20, 2024
1 parent 805ea36 commit c5ddf0d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions br/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ func CheckVersionForBR(s *metapb.Store, tikvVersion *semver.Version) error {
s.Address, tikvVersion)
}

// 8.2 br(store based backup) does not support tikv <= 8.1
// due to the performance issue https://github.com/tikv/tikv/issues/17168
// TODO: we can remove this check if the performance issue is fixed and cherry-pick
if (BRVersion.Major > 8 || (BRVersion.Major == 8 && BRVersion.Minor >= 2)) &&
(tikvVersion.Major < 8 || (tikvVersion.Major == 8 && tikvVersion.Minor < 2)) {
return errors.Annotatef(berrors.ErrVersionMismatch, "TiKV node %s version %s and BR %s version mismatch, please use the same version of BR",
s.Address, tikvVersion, build.ReleaseVersion)
}

// don't warn if we are the master build, which always have the version v4.0.0-beta.2-*
if build.GitBranch != "master" && tikvVersion.Compare(*BRVersion) > 0 {
log.Warn(fmt.Sprintf("BR version is outdated, please consider use version %s of BR", tikvVersion))
Expand Down
18 changes: 18 additions & 0 deletions br/pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,24 @@ func TestCheckClusterVersion(t *testing.T) {
require.Error(t, err)
}

{
build.ReleaseVersion = "v8.2.0"
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: "v8.1.0"}}
}
err := CheckClusterVersion(context.Background(), &mock, CheckVersionForBR)
require.Error(t, err)
}

{
build.ReleaseVersion = "v8.1.0"
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: "v8.2.0"}}
}
err := CheckClusterVersion(context.Background(), &mock, CheckVersionForBR)
require.NoError(t, err)
}

{
mock.getAllStores = func() []*metapb.Store {
return []*metapb.Store{{Version: "v6.4.0"}}
Expand Down

0 comments on commit c5ddf0d

Please sign in to comment.