From 484f0fb2238ced5782bcf0e99ff236777d790ba3 Mon Sep 17 00:00:00 2001 From: "vitess-bot[bot]" <108069721+vitess-bot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:26:32 +0200 Subject: [PATCH] [release-21.0] Online DDL: fix defer function, potential connection pool exhaustion (#17207) (#17210) Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@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 0d3a1dec679..f7296593738 100644 --- a/go/vt/vttablet/onlineddl/executor.go +++ b/go/vt/vttablet/onlineddl/executor.go @@ -963,13 +963,13 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream, sh if err != nil { return err } + defer lockConn.Recycle() // Set large enough `@@lock_wait_timeout` so that it does not interfere with the cut-over operation. // The code will ensure everything that needs to be terminated by `migrationCutOverThreshold` will be terminated. lockConnRestoreLockWaitTimeout, err := e.initConnectionLockWaitTimeout(ctx, lockConn.Conn, 5*migrationCutOverThreshold) if err != nil { return err } - defer lockConn.Recycle() defer lockConnRestoreLockWaitTimeout() defer lockConn.Conn.Exec(ctx, sqlUnlockTables, 1, false)