Skip to content

Commit

Permalink
This is an automated cherry-pick of #58525
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
Leavrth authored and ti-chi-bot committed Dec 25, 2024
1 parent 80db670 commit 2fc4f78
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,15 +778,41 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
if client.IsRawKvMode() {
return errors.Annotate(berrors.ErrRestoreModeMismatch, "cannot do transactional restore from raw kv data")
}
<<<<<<< HEAD

Check failure on line 781 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

syntax error: unexpected <<, expected }

Check failure on line 781 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

syntax error: unexpected <<, expected }

Check failure on line 781 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

syntax error: unexpected <<, expected }
if err = CheckRestoreDBAndTable(client, cfg); err != nil {
=======
if client.IsIncremental() {
// don't support checkpoint for the ddl restore
log.Info("the incremental snapshot restore doesn't support checkpoint mode, disable checkpoint.")
cfg.UseCheckpoint = false
}
var checkpointFirstRun = true
if cfg.UseCheckpoint {

Check failure on line 790 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

syntax error: non-declaration statement outside function body

Check failure on line 790 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

syntax error: non-declaration statement outside function body

Check failure on line 790 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

syntax error: non-declaration statement outside function body
// if the checkpoint metadata exists in the checkpoint storage, the restore is not
// for the first time.
existsCheckpointMetadata := checkpoint.ExistsSstRestoreCheckpoint(ctx, mgr.GetDomain(), checkpoint.SnapshotRestoreCheckpointDatabaseName)
checkpointFirstRun = !existsCheckpointMetadata
}
if err = CheckRestoreDBAndTable(client.GetDatabases(), cfg); err != nil {
>>>>>>> 444a1b9dab1 (br: precheck disk space only when checkpoint first run (#58525))

Check failure on line 797 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

invalid character U+0023 '#'

Check failure on line 797 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

invalid character U+0023 '#'

Check failure on line 797 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

invalid character U+0023 '#'
return err
}
files, tables, dbs := filterRestoreFiles(client, cfg)
if len(dbs) == 0 && len(tables) != 0 {
return errors.Annotate(berrors.ErrRestoreInvalidBackup, "contain tables but no databases")
}

<<<<<<< HEAD
archiveSize := reader.ArchiveSize(ctx, files)
=======
if cfg.CheckRequirements && checkpointFirstRun {
if err := checkDiskSpace(ctx, mgr, files, tables); err != nil {
return errors.Trace(err)
}
}

archiveSize := metautil.ArchiveSize(files)
>>>>>>> 444a1b9dab1 (br: precheck disk space only when checkpoint first run (#58525))

Check failure on line 815 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

invalid character U+0023 '#'

Check failure on line 815 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

invalid character U+0023 '#'

Check failure on line 815 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

invalid character U+0023 '#'
g.Record(summary.RestoreDataSize, archiveSize)
//restore from tidb will fetch a general Size issue https://github.com/pingcap/tidb/issues/27247
g.Record("Size", archiveSize)
Expand All @@ -795,13 +821,23 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
return errors.Trace(err)
}

<<<<<<< HEAD
if client.IsIncremental() {
// don't support checkpoint for the ddl restore
log.Info("the incremental snapshot restore doesn't support checkpoint mode, so unuse checkpoint.")
cfg.UseCheckpoint = false
}

restoreSchedulers, schedulersConfig, err := restorePreWork(ctx, client, mgr, true)
=======
// for full + log restore. should check the cluster is empty.
if client.IsFull() && checkInfo != nil && checkInfo.FullRestoreCheckErr != nil {
return checkInfo.FullRestoreCheckErr
}

importModeSwitcher := restore.NewImportModeSwitcher(mgr.GetPDClient(), cfg.Config.SwitchModeInterval, mgr.GetTLSConfig())
restoreSchedulers, schedulersConfig, err := restore.RestorePreWork(ctx, mgr, importModeSwitcher, cfg.Online, true)
>>>>>>> 444a1b9dab1 (br: precheck disk space only when checkpoint first run (#58525))

Check failure on line 840 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

invalid character U+0023 '#'

Check failure on line 840 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

invalid character U+0023 '#'

Check failure on line 840 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

invalid character U+0023 '#'
if err != nil {
return errors.Trace(err)
}
Expand All @@ -820,6 +856,7 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
log.Info("finish removing pd scheduler")
}()

Check failure on line 857 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

syntax error: unexpected ( after top level declaration

Check failure on line 857 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

syntax error: unexpected ( after top level declaration

Check failure on line 857 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

syntax error: unexpected ( after top level declaration

<<<<<<< HEAD
var checkpointTaskName string
var checkpointFirstRun bool = true
if cfg.UseCheckpoint {

Check failure on line 862 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

syntax error: non-declaration statement outside function body

Check failure on line 862 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

syntax error: non-declaration statement outside function body

Check failure on line 862 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

syntax error: non-declaration statement outside function body
Expand All @@ -833,6 +870,8 @@ func runRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
checkpointFirstRun = !existsCheckpointMetadata
}

=======
>>>>>>> 444a1b9dab1 (br: precheck disk space only when checkpoint first run (#58525))

Check failure on line 874 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for FreeBSD job

invalid character U+0023 '#'

Check failure on line 874 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

invalid character U+0023 '#'

Check failure on line 874 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for ubuntu-latest

invalid character U+0023 '#'
if isFullRestore(cmdName) {
if client.NeedCheckFreshCluster(cfg.ExplicitFilter, checkpointFirstRun) {
if err = client.CheckTargetClusterFresh(ctx); err != nil {
Expand Down

0 comments on commit 2fc4f78

Please sign in to comment.