Skip to content

Commit

Permalink
fix go leak
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Mou <[email protected]>
  • Loading branch information
Tristan1900 committed Dec 30, 2024
1 parent cdcc291 commit 1ea3cf8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ func RunRestore(c context.Context, g glue.Glue, cmdName string, cfg *RestoreConf
return nil
}

func markRestoreSuccess(schedulersRemovable *bool) {
*schedulersRemovable = true
summary.SetSuccessStatus(true)
}

func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName string, cfg *RestoreConfig, checkInfo *PiTRTaskInfo) error {
cfg.Adjust()
defer summary.Summary(cmdName)
Expand Down Expand Up @@ -1012,7 +1017,7 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
if len(dbs) == 0 && len(tables) == 0 {
log.Info("nothing to restore, all databases and tables are filtered out")
// even nothing to restore, we show a success message since there is no failure.
summary.SetSuccessStatus(true)
markRestoreSuccess(&schedulersRemovable)
return nil
}

Expand Down Expand Up @@ -1041,7 +1046,6 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s

if len(files) == 0 {
log.Info("no files, empty databases and tables are restored")
summary.SetSuccessStatus(true)
// don't return immediately, wait all pipeline done.
} else {
oldKeyspace, _, err := tikv.DecodeKey(files[0].GetStartKey(), backupMeta.ApiVersion)
Expand Down Expand Up @@ -1161,10 +1165,7 @@ func runSnapshotRestore(c context.Context, mgr *conn.Mgr, g glue.Glue, cmdName s
return errors.Trace(err)
}

schedulersRemovable = true

// Set task summary to success status.
summary.SetSuccessStatus(true)
markRestoreSuccess(&schedulersRemovable)
return nil
}

Expand Down

0 comments on commit 1ea3cf8

Please sign in to comment.