Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-19.0] Online DDL: fix defer function, potential connection pool exhaustion (#17207) #17208

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,22 @@

lockConn, err := e.pool.Get(ctx, nil)
if err != nil {
<<<<<<< HEAD

Check failure on line 969 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected <<, expected }

Check failure on line 969 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected <<, expected }
return err
}
defer lockConn.Recycle()

Check failure on line 972 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body

Check failure on line 972 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body
=======
return vterrors.Wrapf(err, "failed getting locking connection")
}
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 vterrors.Wrapf(err, "failed setting lock_wait_timeout on locking connection")
}
defer lockConnRestoreLockWaitTimeout()
>>>>>>> 8952b5af4e (Online DDL: fix defer function, potential connection pool exhaustion (#17207))

Check failure on line 984 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

invalid character U+0023 '#'

Check failure on line 984 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

invalid character U+0023 '#'
defer lockConn.Conn.Exec(ctx, sqlUnlockTables, 1, false)

renameCompleteChan := make(chan error)
Expand All @@ -978,11 +991,11 @@
return err
}
defer renameConn.Recycle()
defer func() {

Check failure on line 994 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

method has no receiver

Check failure on line 994 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected {, expected name

Check failure on line 994 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

method has no receiver

Check failure on line 994 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected {, expected name
if !renameWasSuccessful {
renameConn.Conn.Kill("premature exit while renaming tables", 0)
}
}()

Check failure on line 998 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected ( after top level declaration

Check failure on line 998 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected ( after top level declaration
// See if backend MySQL server supports 'rename_table_preserve_foreign_key' variable
preserveFKSupported, err := e.isPreserveForeignKeySupported(ctx)
if err != nil {
Expand All @@ -999,12 +1012,12 @@
}

renameQuery := sqlparser.BuildParsedQuery(sqlSwapTables, onlineDDL.Table, sentryTableName, vreplTable, onlineDDL.Table, sentryTableName, vreplTable)
waitForRenameProcess := func() error {

Check failure on line 1015 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

method has no receiver

Check failure on line 1015 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected {, expected (

Check failure on line 1015 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

method has no receiver

Check failure on line 1015 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected {, expected (
// This function waits until it finds the RENAME TABLE... query running in MySQL's PROCESSLIST, or until timeout
// The function assumes that one of the renamed tables is locked, thus causing the RENAME to block. If nothing
// is locked, then the RENAME will be near-instantaneous and it's unlikely that the function will find it.
renameWaitCtx, cancel := context.WithTimeout(ctx, migrationCutOverThreshold)

Check failure on line 1019 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected := in parameter list; possibly missing comma or )

Check failure on line 1019 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected := in parameter list; possibly missing comma or )
defer cancel()

Check failure on line 1020 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body

Check failure on line 1020 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: non-declaration statement outside function body

for {
renameProcessFound, err := e.doesConnectionInfoMatch(renameWaitCtx, renameConn.Conn.ID(), "rename")
Expand Down
Loading