From 0b556df02c3f096b4eb97e7cae04198215a3ecfc Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:14:17 +0300 Subject: [PATCH 1/2] channel close() should be owned by the writer Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- go/vt/vttablet/onlineddl/executor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/vt/vttablet/onlineddl/executor.go b/go/vt/vttablet/onlineddl/executor.go index 5ac7f98e8f6..278e913d551 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -863,7 +863,6 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream) er defer lockConn.Exec(ctx, sqlUnlockTables, 1, false) renameCompleteChan := make(chan error) - defer close(renameCompleteChan) renameWasSuccessful := false renameConn, err := e.pool.Get(ctx, nil) if err != nil { @@ -974,6 +973,7 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream) er go func() { _, err := renameConn.Exec(ctx, renameQuery.Query, 1, false) renameCompleteChan <- err + close(renameCompleteChan) }() // the rename should block, because of the LOCK. Wait for it to show up. e.updateMigrationStage(ctx, onlineDDL.UUID, "waiting for RENAME to block") From e2e3e2422ee1ad7ea0fc6f55aa15ba285d7e5c4e Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Sun, 6 Aug 2023 17:42:45 +0300 Subject: [PATCH 2/2] defer close Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- go/vt/vttablet/onlineddl/executor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/vt/vttablet/onlineddl/executor.go b/go/vt/vttablet/onlineddl/executor.go index 278e913d551..38d5981e7c9 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -971,9 +971,9 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream) er e.updateMigrationStage(ctx, onlineDDL.UUID, "renaming tables") go func() { + defer close(renameCompleteChan) _, err := renameConn.Exec(ctx, renameQuery.Query, 1, false) renameCompleteChan <- err - close(renameCompleteChan) }() // the rename should block, because of the LOCK. Wait for it to show up. e.updateMigrationStage(ctx, onlineDDL.UUID, "waiting for RENAME to block")