Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br: support reset_tiflash after ebs restoration #40124

Merged
merged 16 commits into from
Jan 9, 2023
Prev Previous commit
Next Next commit
fix nil
3pointer committed Dec 23, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
renovate-bot Mend Renovate
commit e75917a4898da38c6647efd98b02f830c1cf33ac
11 changes: 7 additions & 4 deletions br/pkg/restore/client.go
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ import (
"github.com/pingcap/log"
"github.com/pingcap/tidb/br/pkg/backup"
"github.com/pingcap/tidb/br/pkg/checksum"
"github.com/pingcap/tidb/br/pkg/conn"
"github.com/pingcap/tidb/br/pkg/conn/util"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/pingcap/tidb/br/pkg/glue"
@@ -2723,8 +2722,12 @@ func CheckNewCollationEnable(
return nil
}

func (rc *Client) ResetTiFlashReplicas(ctx context.Context, g glue.Glue, mgr *conn.Mgr) error {
info := mgr.GetDomain().InfoSchema()
func (rc *Client) ResetTiFlashReplicas(ctx context.Context, g glue.Glue, storage kv.Storage) error {
dom, err := g.GetDomain(storage)
if err != nil {
return errors.Trace(err)
}
info := dom.InfoSchema()
allSchema := info.AllSchemas()
recorder := tiflashrec.New()

@@ -2744,7 +2747,7 @@ func (rc *Client) ResetTiFlashReplicas(ctx context.Context, g glue.Glue, mgr *co
sqls := recorder.GenerateAlterTableDDLs(info)
log.Info("Generating SQLs for resetting TiFlash Replica",
zap.Strings("sqls", sqls))
return g.UseOneShotSession(mgr.GetStorage(), false, func(se glue.Session) error {
return g.UseOneShotSession(storage, false, func(se glue.Session) error {
for _, sql := range sqls {
if errExec := se.ExecuteInternal(ctx, sql); errExec != nil {
logutil.WarnTerm("Failed to restore tiflash replica config, you may execute the sql restore it manually.",
4 changes: 2 additions & 2 deletions br/pkg/task/restore_data.go
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ func RunResolveKvData(c context.Context, g glue.Glue, cmdName string, cfg *Resto
summary.CollectUint("resolve-ts", resolveTS)

keepaliveCfg := GetKeepalive(&cfg.Config)
mgr, err := NewMgr(ctx, g, cfg.PD, cfg.TLS, keepaliveCfg, cfg.CheckRequirements, true, conn.NormalVersionChecker)
mgr, err := NewMgr(ctx, g, cfg.PD, cfg.TLS, keepaliveCfg, cfg.CheckRequirements, false, conn.NormalVersionChecker)
if err != nil {
return errors.Trace(err)
}
@@ -155,7 +155,7 @@ func RunResolveKvData(c context.Context, g glue.Glue, cmdName string, cfg *Resto
//ModifyVolume(*ec2.ModifyVolumeInput) (*ec2.ModifyVolumeOutput, error) by backupmeta

// since we cannot reset tiflash automaticlly. so we should start it manually
if err = client.ResetTiFlashReplicas(ctx, g, mgr); err != nil {
if err = client.ResetTiFlashReplicas(ctx, g, mgr.GetStorage()); err != nil {
return errors.Trace(err)
}
progress.Close()