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: precheck disk space only when checkpoint first run (#58525) #58538

Open
wants to merge 2 commits into
base: release-8.5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 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.ExistsSnapshotRestoreCheckpoint(ctx, mgr.GetDomain())
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,14 +869,6 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
log.Info("finish removing pd scheduler")
}()

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.ExistsSnapshotRestoreCheckpoint(ctx, mgr.GetDomain())
checkpointFirstRun = !existsCheckpointMetadata
}

if isFullRestore(cmdName) {
if client.NeedCheckFreshCluster(cfg.ExplicitFilter, checkpointFirstRun) {
if err = client.CheckTargetClusterFresh(ctx); err != nil {
Expand Down