Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <mattalord@gmail.com>
  • Loading branch information
mattlord committed Aug 16, 2024
1 parent a76bf9a commit 712e004
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go/vt/vtctl/workflow/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3501,7 +3501,7 @@ func (s *Server) switchWrites(ctx context.Context, req *vtctldatapb.WorkflowSwit
// intra-keyspace materializations that write on the source), and we know for certain
// that any in progress writes are done.
if err := ts.gatherSourcePositions(ctx); err != nil {
return handleError("failed to get replication positions on migration sources", err)
return handleError("failed to gather replication positions on migration sources", err)
}

if err := confirmKeyspaceLocksHeld(); err != nil {
Expand Down
9 changes: 5 additions & 4 deletions go/vt/vtctl/workflow/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ func (ts *trafficSwitcher) stopSourceWrites(ctx context.Context) error {
err = ts.changeShardsAccess(ctx, ts.SourceKeyspaceName(), ts.SourceShards(), disallowWrites)
}
if err != nil {
ts.Logger().Warningf("Error stopping writes: %s", err)
ts.Logger().Warningf("Error stopping writes on migration sources: %v", err)
return err
}
return nil
Expand Down Expand Up @@ -1315,13 +1315,14 @@ func (ts *trafficSwitcher) gatherSourcePositions(ctx context.Context) error {
return ts.ForAllSources(func(source *MigrationSource) error {
var err error
tablet := source.GetPrimary().Tablet
source.Position, err = ts.TabletManagerClient().PrimaryPosition(ctx, tablet)
tabletAlias := topoproto.TabletAliasString(tablet.Alias)
ts.Logger().Infof("Position on migration source %s after having stopped writes: %s", tabletAlias, source.Position)
source.Position, err = ts.TabletManagerClient().PrimaryPosition(ctx, tablet)
if err != nil {
ts.Logger().Errorf("Error getting migration source position on %s: %s", tabletAlias, err)
return vterrors.Wrapf(err, "failed to get position on %s", tabletAlias)
return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "failed to get position on migration source %s: %v",
tabletAlias, err)
}
ts.Logger().Infof("Position on migration source %s after having stopped writes: %s", tabletAlias, source.Position)
return nil
})
}
Expand Down

0 comments on commit 712e004

Please sign in to comment.