Skip to content

Commit 05a26c8

Browse files
Update docs
Signed-off-by: Tim Vaillancourt <[email protected]>
1 parent 85116ad commit 05a26c8

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

doc/command-line-flags.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ Optional. Default is `safe`. See more discussion in [`cut-over`](cut-over.md)
106106

107107
Default `3`. Max number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout).
108108

109+
### cut-over-wait-timeout-seconds
110+
111+
When set to a value greater than zero, this flag causes `gh-ost` to set a [MySQL `wait_timeout`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout) for the MySQL session performing the cut-over, specified in seconds. This timeout is to ensure the locks held by the cut-over are released if the `gh-ost` process terminates or pauses mid-cut-over.
112+
109113
### discard-foreign-keys
110114

111115
**Danger**: this flag will _silently_ discard any foreign keys existing on your table.
@@ -202,10 +206,6 @@ List of metrics and threshold values; topping the threshold of any will cause th
202206

203207
Typically `gh-ost` is used to migrate tables on a master. If you wish to only perform the migration in full on a replica, connect `gh-ost` to said replica and pass `--migrate-on-replica`. `gh-ost` will briefly connect to the master but otherwise will make no changes on the master. Migration will be fully executed on the replica, while making sure to maintain a small replication lag.
204208

205-
### mysql-wait-timeout
206-
207-
If set to a value greater than zero, causes `gh-ost` to set a provided [MySQL `wait_timeout`](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_wait_timeout) for MySQL sessions opened by `gh-ost`, specified in seconds.
208-
209209
### postpone-cut-over-flag-file
210210

211211
Indicate a file name, such that the final [cut-over](cut-over.md) step does not take place as long as the file exists.

go/logic/applier.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -977,21 +977,23 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
977977
return err
978978
}
979979

980-
this.migrationContext.Log.Infof("Setting cut-over idle timeout as %d seconds", this.migrationContext.CutOverIdleTimeoutSeconds)
981-
query = fmt.Sprintf(`set /* gh-ost */ session wait_timeout:=%d`, this.migrationContext.CutOverIdleTimeoutSeconds)
982-
if _, err := tx.Exec(query); err != nil {
983-
tableLocked <- err
984-
return err
985-
}
986-
defer func() {
987-
this.migrationContext.Log.Infof("Restoring applier idle timeout as %d seconds", this.migrationContext.ApplierWaitTimeout)
988-
query = fmt.Sprintf(`set /* gh-ost */ session wait_timeout:=%d`, this.migrationContext.ApplierWaitTimeout)
989-
if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil {
990-
this.migrationContext.Log.Errorf("Failed to restore applier wait_timeout to %d seconds: %v",
991-
this.migrationContext.ApplierWaitTimeout, err,
992-
)
980+
if this.migrationContext.CutOverIdleTimeoutSeconds > 0 {
981+
this.migrationContext.Log.Infof("Setting cut-over idle timeout as %d seconds", this.migrationContext.CutOverIdleTimeoutSeconds)
982+
query = fmt.Sprintf(`set /* gh-ost */ session wait_timeout:=%d`, this.migrationContext.CutOverIdleTimeoutSeconds)
983+
if _, err := tx.Exec(query); err != nil {
984+
tableLocked <- err
985+
return err
993986
}
994-
}()
987+
defer func() {
988+
this.migrationContext.Log.Infof("Restoring applier idle timeout as %d seconds", this.migrationContext.ApplierWaitTimeout)
989+
query = fmt.Sprintf(`set /* gh-ost */ session wait_timeout:=%d`, this.migrationContext.ApplierWaitTimeout)
990+
if _, err := sqlutils.ExecNoPrepare(this.db, query); err != nil {
991+
this.migrationContext.Log.Errorf("Failed to restore applier wait_timeout to %d seconds: %v",
992+
this.migrationContext.ApplierWaitTimeout, err,
993+
)
994+
}
995+
}()
996+
}
995997

996998
if err := this.CreateAtomicCutOverSentryTable(); err != nil {
997999
tableLocked <- err

0 commit comments

Comments
 (0)