From 92a6be0ec5f161241176c9c34c7b47eda30ff696 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 22 Jan 2025 22:52:07 +0000 Subject: [PATCH] Maintain the locks in the new cancel context Signed-off-by: Matt Lord --- go/vt/vtctl/workflow/traffic_switcher.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 {