From fbf4334cf45d779079a274f58710b44abf70a637 Mon Sep 17 00:00:00 2001
From: Matt Lord <mattalord@gmail.com>
Date: Wed, 22 Jan 2025 22:52:07 +0000
Subject: [PATCH] Maintain the locks in the new cancel context

Signed-off-by: Matt Lord <mattalord@gmail.com>
---
 go/vt/vtctl/workflow/traffic_switcher.go |  5 ++++-
 go/vt/vtctl/workflow/workflows.go        | 10 ----------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/go/vt/vtctl/workflow/traffic_switcher.go b/go/vt/vtctl/workflow/traffic_switcher.go
index 4fc34992b0f..1732f3425b7 100644
--- a/go/vt/vtctl/workflow/traffic_switcher.go
+++ b/go/vt/vtctl/workflow/traffic_switcher.go
@@ -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 {
diff --git a/go/vt/vtctl/workflow/workflows.go b/go/vt/vtctl/workflow/workflows.go
index f5dcc29ed1d..99739d3556b 100644
--- a/go/vt/vtctl/workflow/workflows.go
+++ b/go/vt/vtctl/workflow/workflows.go
@@ -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