Skip to content

Commit

Permalink
rename some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Nov 17, 2024
1 parent a565ed0 commit b715725
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion br/pkg/restore/log_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (rc *LogClient) RestoreCompactedSstFiles(
// TODO: Future enhancements may explore the feasibility of reintroducing batch restoration
// while maintaining optimal performance and resource utilization.
for _, i := range backupFileSets {
err := rc.sstRestoreManager.restorer.Restore(onProgress, []restore.BackupFileSet{i})
err := rc.sstRestoreManager.restorer.GoRestore(onProgress, []restore.BackupFileSet{i})
if err != nil {
return errors.Trace(err)
}
Expand Down
8 changes: 4 additions & 4 deletions br/pkg/restore/restorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func NewFileSet(files []*backuppb.File, rules *utils.RewriteRules) BackupFileSet
// and MultiTablesRestorer. SstRestorer includes FileImporter for handling raw, transactional, and compacted SSTs,
// and MultiTablesRestorer for TiDB-specific backups.
type SstRestorer interface {
// Restore imports the specified backup file sets into TiKV.
// GoRestore imports the specified backup file sets into TiKV asynchronously.
// The onProgress function is called with progress updates as files are processed.
Restore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) error
GoRestore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) error

// WaitUntilFinish blocks until all pending restore files have completed processing.
WaitUntilFinish() error
Expand Down Expand Up @@ -184,7 +184,7 @@ func (s *SimpleRestorer) WaitUntilFinish() error {
return s.eg.Wait()
}

func (s *SimpleRestorer) Restore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) error {
func (s *SimpleRestorer) GoRestore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) error {
for _, sets := range batchFileSets {
for _, set := range sets {
s.workerPool.ApplyOnErrorGroup(s.eg,
Expand Down Expand Up @@ -248,7 +248,7 @@ func (m *MultiTablesRestorer) WaitUntilFinish() error {
return nil
}

func (m *MultiTablesRestorer) Restore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) (err error) {
func (m *MultiTablesRestorer) GoRestore(onProgress func(int64), batchFileSets ...BatchBackupFileSet) (err error) {
start := time.Now()
fileCount := 0
defer func() {
Expand Down
13 changes: 7 additions & 6 deletions br/pkg/restore/restorer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestSimpleRestorerImportAndProgress(t *testing.T) {
fileSet := restore.BatchBackupFileSet{
{SSTFiles: files},
}
err := restorer.Restore(func(progress int64) {
err := restorer.GoRestore(func(progress int64) {
progressCount += progress
}, fileSet)
require.NoError(t, err)
Expand All @@ -65,7 +65,7 @@ func TestSimpleRestorerImportAndProgress(t *testing.T) {
{SSTFiles: files},
}
progressCount = int64(0)
err = restorer.Restore(func(progress int64) {
err = restorer.GoRestore(func(progress int64) {
progressCount += progress
}, batchFileSet)
require.NoError(t, err)
Expand All @@ -89,7 +89,7 @@ func TestSimpleRestorerWithErrorInImport(t *testing.T) {

// Run restore and expect an error
progressCount := int64(0)
err := restorer.Restore(func(progress int64) {}, fileSet)
err := restorer.GoRestore(func(progress int64) {}, fileSet)
require.Error(t, err)
require.Contains(t, err.Error(), "import error")
require.Equal(t, int64(0), progressCount)
Expand Down Expand Up @@ -144,7 +144,8 @@ func TestMultiTablesRestorerRestoreSuccess(t *testing.T) {
var progress int64
fileSets := createSampleBatchFileSets()

err := restorer.Restore(func(p int64) { progress += p }, fileSets)
restorer.GoRestore(func(p int64) { progress += p }, fileSets)
err := restorer.WaitUntilFinish()
require.NoError(t, err)

// Ensure progress was tracked correctly
Expand All @@ -160,7 +161,7 @@ func TestMultiTablesRestorerRestoreWithImportError(t *testing.T) {
restorer := restore.NewMultiTablesRestorer(ctx, importer, workerPool, nil)
fileSets := createSampleBatchFileSets()

restorer.Restore(func(int64) {}, fileSets)
restorer.GoRestore(func(int64) {}, fileSets)
err := restorer.WaitUntilFinish()
require.Error(t, err)
require.Contains(t, err.Error(), "import error")
Expand All @@ -178,7 +179,7 @@ func TestMultiTablesRestorerRestoreWithContextCancel(t *testing.T) {

// Cancel context before restore completes
cancel()
err := restorer.Restore(func(int64) {}, fileSets)
err := restorer.GoRestore(func(int64) {}, fileSets)
require.ErrorIs(t, err, context.Canceled)
}

Expand Down
2 changes: 1 addition & 1 deletion br/pkg/restore/snap_client/tikv_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (rc *SnapClient) RestoreSSTFiles(
}
})

retErr = rc.restorer.Restore(onProgress, tableIDWithFilesGroup...)
retErr = rc.restorer.GoRestore(onProgress, tableIDWithFilesGroup...)
if retErr != nil {
return retErr
}
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/task/restore_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreR
defer restore.RestorePostWork(ctx, importModeSwitcher, restoreSchedulers, cfg.Online)

start := time.Now()
err = client.GetRestorer().Restore(onProgress, restore.CreateUniqueFileSets(files))
err = client.GetRestorer().GoRestore(onProgress, restore.CreateUniqueFileSets(files))
if err != nil {
return errors.Trace(err)
}
Expand Down
2 changes: 1 addition & 1 deletion br/pkg/task/restore_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func RunRestoreTxn(c context.Context, g glue.Glue, cmdName string, cfg *Config)
}
defer restore.RestorePostWork(ctx, importModeSwitcher, restoreSchedulers, false)

err = client.GetRestorer().Restore(onProgress, restore.CreateUniqueFileSets(files))
err = client.GetRestorer().GoRestore(onProgress, restore.CreateUniqueFileSets(files))
if err != nil {
return errors.Trace(err)
}
Expand Down

0 comments on commit b715725

Please sign in to comment.