Skip to content

Commit d31f3aa

Browse files
author
Justin Fudally
committed
Add CLI flag for ignoring http errors
1 parent ca0b822 commit d31f3aa

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

go/base/context.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type MigrationContext struct {
119119
ThrottleAdditionalFlagFile string
120120
throttleQuery string
121121
throttleHTTP string
122+
ignoreHTTPErrors bool
122123
ThrottleCommandedByUser int64
123124
HibernateUntil int64
124125
maxLoad LoadMap
@@ -574,6 +575,13 @@ func (this *MigrationContext) SetThrottleHTTP(throttleHTTP string) {
574575
this.throttleHTTP = throttleHTTP
575576
}
576577

578+
func (this *MigrationContext) SetIgnoreHTTPErrors(ignoreHTTPErrors bool) {
579+
this.throttleHTTPMutex.Lock()
580+
defer this.throttleHTTPMutex.Unlock()
581+
582+
this.ignoreHTTPErrors = ignoreHTTPErrors
583+
}
584+
577585
func (this *MigrationContext) GetMaxLoad() LoadMap {
578586
this.throttleMutex.Lock()
579587
defer this.throttleMutex.Unlock()

go/cmd/gh-ost/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func main() {
106106
throttleControlReplicas := flag.String("throttle-control-replicas", "", "List of replicas on which to check for lag; comma delimited. Example: myhost1.com:3306,myhost2.com,myhost3.com:3307")
107107
throttleQuery := flag.String("throttle-query", "", "when given, issued (every second) to check if operation should throttle. Expecting to return zero for no-throttle, >0 for throttle. Query is issued on the migrated server. Make sure this query is lightweight")
108108
throttleHTTP := flag.String("throttle-http", "", "when given, gh-ost checks given URL via HEAD request; any response code other than 200 (OK) causes throttling; make sure it has low latency response")
109+
ignoreHTTPErrors := flag.Bool("ignore-http-error", false, "ignore HTTP connection errors during throttle check")
109110
heartbeatIntervalMillis := flag.Int64("heartbeat-interval-millis", 100, "how frequently would gh-ost inject a heartbeat value")
110111
flag.StringVar(&migrationContext.ThrottleFlagFile, "throttle-flag-file", "", "operation pauses when this file exists; hint: use a file that is specific to the table being altered")
111112
flag.StringVar(&migrationContext.ThrottleAdditionalFlagFile, "throttle-additional-flag-file", "/tmp/gh-ost.throttle", "operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations")
@@ -259,6 +260,7 @@ func main() {
259260
migrationContext.SetMaxLagMillisecondsThrottleThreshold(*maxLagMillis)
260261
migrationContext.SetThrottleQuery(*throttleQuery)
261262
migrationContext.SetThrottleHTTP(*throttleHTTP)
263+
migrationContext.SetIgnoreHTTPErrors(*ignoreHTTPErrors)
262264
migrationContext.SetDefaultNumRetries(*defaultRetries)
263265
migrationContext.ApplyCredentials()
264266
if err := migrationContext.SetupTLS(); err != nil {

0 commit comments

Comments
 (0)