Skip to content

Commit

Permalink
Maintain the locks in the new cancel context
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Jan 22, 2025
1 parent 084ace8 commit fbf4334
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
5 changes: 4 additions & 1 deletion go/vt/vtctl/workflow/traffic_switcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,11 @@ func (ts *trafficSwitcher) cancelMigration(ctx context.Context, sm *StreamMigrat

// We create a new context while canceling the migration, so that we are independent of the original
// context being cancelled prior to or during the cancel operation.
// Create a child context that cannot be canceled by the parent, so that we maintain the locks.
cctx := context.WithoutCancel(ctx)
// Now create a child context from that which has a timeout.
cmTimeout := 60 * time.Second
cmCtx, cmCancel := context.WithTimeout(context.Background(), cmTimeout)
cmCtx, cmCancel := context.WithTimeout(cctx, cmTimeout)
defer cmCancel()

if ts.MigrationType() == binlogdatapb.MigrationType_TABLES {
Expand Down
10 changes: 0 additions & 10 deletions go/vt/vtctl/workflow/workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,16 +647,6 @@ func getStreamState(stream *vtctldatapb.Workflow_Stream, rstream *tabletmanagerd
return rstream.State.String()
}

type GenericStream interface {
*tabletmanagerdatapb.ReadVReplicationWorkflowResponse_Stream | *vtctldatapb.Workflow_Stream
}

type Stream[T GenericStream] struct {
TransactionTimestamp *vttimepb.Time
TimeUpdated *vttimepb.Time
State binlogdatapb.VReplicationWorkflowState
}

// getVReplicationTrxLag estimates the actual statement processing lag between the
// source and the target. If we are still processing source events it is the
// difference between current time and the timestamp of the last event. If
Expand Down

0 comments on commit fbf4334

Please sign in to comment.