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 9a5b05a commit 833bb09
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,18 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
if client.IsRawKvMode() {
return errors.Annotate(berrors.ErrRestoreModeMismatch, "cannot do transactional restore from raw kv data")
}
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 {
// 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 {
return err
}
Expand All @@ -817,7 +829,7 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
return errors.Annotate(berrors.ErrRestoreInvalidBackup, "contain tables but no databases")
}

if cfg.CheckRequirements {
if cfg.CheckRequirements && checkpointFirstRun {
if err := checkDiskSpace(ctx, mgr, files, tables); err != nil {
return errors.Trace(err)
}
Expand All @@ -837,12 +849,6 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
return checkInfo.FullRestoreCheckErr
}

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
}

importModeSwitcher := restore.NewImportModeSwitcher(mgr.GetPDClient(), cfg.Config.SwitchModeInterval, mgr.GetTLSConfig())
restoreSchedulers, schedulersConfig, err := restore.RestorePreWork(ctx, mgr, importModeSwitcher, cfg.Online, true)
if err != nil {
Expand All @@ -863,6 +869,7 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
log.Info("finish removing pd scheduler")
}()

<<<<<<< HEAD

Check failure on line 872 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 872 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-latest

syntax error: unexpected <<, expected }
var checkpointFirstRun = true
if cfg.UseCheckpoint {

Check failure on line 874 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 874 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
// if the checkpoint metadata exists in the checkpoint storage, the restore is not
Expand All @@ -871,6 +878,8 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
checkpointFirstRun = !existsCheckpointMetadata
}

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

Check failure on line 882 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 882 in br/pkg/task/restore.go

View workflow job for this annotation

GitHub Actions / Compile for macos-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 833bb09

Please sign in to comment.