Skip to content

Commit

Permalink
fix: use cut-over-lock-timeout for instant DDL
Browse files Browse the repository at this point in the history
Addresses #1386

by reusing the cut-over-lock-timeout from the cutover code.
The lock wait timeout in the original code is actually set to double
the setting, so we keep that consistent.
  • Loading branch information
artemvovk committed Nov 7, 2024
1 parent a6ccd3f commit eb84b56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions go/logic/applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ func (this *Applier) ValidateOrDropExistingTables() error {
func (this *Applier) AttemptInstantDDL() error {
query := this.generateInstantDDLQuery()
this.migrationContext.Log.Infof("INSTANT DDL query is: %s", query)

// Reuse cut-over-lock-timeout from regular migration process to reduce risk
// in situations where there maybe long-running transactions.
tableLockTimeoutSeconds := this.migrationContext.CutOverLockTimeoutSeconds * 2
this.migrationContext.Log.Infof("Setting LOCK timeout as %d seconds", tableLockTimeoutSeconds)
query = fmt.Sprintf(`set /* gh-ost */ session lock_wait_timeout:=%d`, tableLockTimeoutSeconds)
if _, err := this.db.Exec(query); err != nil {
return err
}
// We don't need a trx, because for instant DDL the SQL mode doesn't matter.
_, err := this.db.Exec(query)
return err
Expand Down

0 comments on commit eb84b56

Please sign in to comment.