Skip to content

Commit 8f8e5af

Browse files
committed
fix: use cut-over-lock-timeout for instant DDL
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.
1 parent a6ccd3f commit 8f8e5af

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

go/logic/applier.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ func (this *Applier) ValidateOrDropExistingTables() error {
255255
func (this *Applier) AttemptInstantDDL() error {
256256
query := this.generateInstantDDLQuery()
257257
this.migrationContext.Log.Infof("INSTANT DDL query is: %s", query)
258+
259+
// Reuse cut-over-lock-timeout from regular migration process to reduce risk
260+
// in situations where there may be long-running transactions.
261+
tableLockTimeoutSeconds := this.migrationContext.CutOverLockTimeoutSeconds * 2
262+
this.migrationContext.Log.Infof("Setting LOCK timeout as %d seconds", tableLockTimeoutSeconds)
263+
query = fmt.Sprintf(`set /* gh-ost */ session lock_wait_timeout:=%d`, tableLockTimeoutSeconds)
264+
if _, err := this.db.Exec(query); err != nil {
265+
return err
266+
}
258267
// We don't need a trx, because for instant DDL the SQL mode doesn't matter.
259268
_, err := this.db.Exec(query)
260269
return err

0 commit comments

Comments
 (0)