Skip to content

Commit

Permalink
Integrate in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Jan 14, 2025
1 parent c752e2a commit 082d245
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cmd/experimental/migrate/internal/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,23 @@ func Migrate(ctx context.Context, numWorkers int, sourceSize uint64, sourceRoot
return m.migrateWorker(ctx)
})
}
if err := eg.Wait(); err != nil {
return fmt.Errorf("migrate failed to copy resources: %v", err)
}
var root []byte
eg.Go(func() error {
r, err := m.storage.AwaitIntegration(ctx, sourceSize)
if err != nil {
return fmt.Errorf("Migration failed: %v", err)
}
if !bytes.Equal(root, sourceRoot) {
return fmt.Errorf("migration completed, but local root hash %x != source root hash %x", targetRoot, sourceRoot)
}
root = r
return nil
})

root, err := m.storage.AwaitIntegration(ctx, sourceSize)
if err != nil {
if err := eg.Wait(); err != nil {
return fmt.Errorf("Migration failed: %v", err)
}
if !bytes.Equal(root, sourceRoot) {
return fmt.Errorf("migration completed, but local root hash %x != source root hash %x", targetRoot, sourceRoot)
}

klog.Infof("Migration successful.")
return nil
}
Expand Down

0 comments on commit 082d245

Please sign in to comment.