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-20.0] Online DDL: fix defer function, potential connection pool exhaustion (#17207) #17209

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 @@ -964,9 +964,22 @@

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

Check failure on line 967 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 967 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 970 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 970 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 982 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 982 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 @@ -976,14 +989,14 @@
return err
}
defer renameConn.Recycle()
defer func() {

Check failure on line 992 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 992 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 992 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 992 in go/vt/vttablet/onlineddl/executor.go

View workflow job for this annotation

GitHub Actions / Code Coverage

syntax error: unexpected {, expected name
if !renameWasSuccessful {
err := renameConn.Conn.Kill("premature exit while renaming tables", 0)
if err != nil {
log.Warningf("Failed to kill connection being used to rename tables in OnlineDDL migration %s: %v", onlineDDL.UUID, err)
}
}
}()

Check failure on line 999 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 999 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 @@ -1000,12 +1013,12 @@
}

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

Check failure on line 1016 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 1016 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 1016 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 1016 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 1020 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 1020 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 1021 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 1021 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