Skip to content

Commit 0200cc9

Browse files
author
Shlomi Noach
authored
Merge pull request #75 from github/dynamic-throttle-control-replicas
supporting interactive command throttle-control-replicas
2 parents 94c8812 + 2c8121c commit 0200cc9

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
#
33
#
4-
RELEASE_VERSION="0.9.5"
4+
RELEASE_VERSION="0.9.6"
55

66
buildpath=/tmp/gh-ost
77
target=gh-ost

doc/interactive-commands.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ Both interfaces may serve at the same time. Both respond to simple text command,
1616

1717
- `help`: shows a brief list of available commands
1818
- `status`: returns a status summary of migration progress and configuration
19-
- `throttle`: force migration suspend
20-
- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply)
19+
replication lag on to determine throttling
2120
- `chunk-size=<newsize>`: modify the `chunk-size`; applies on next running copy-iteration
2221
- `max-load=<max-load-thresholds>`: modify the `max-load` config; applies on next running copy-iteration
2322
The `max-load` format must be: `some_status=<numeric-threshold>[,some_status=<numeric-threshold>...]`. For example: `Threads_running=50,threads_connected=1000`, and you would then write/echo `max-load=Threads_running=50,threads_connected=1000` to the socket.
23+
- `critical-load=<load>`: change critical load setting (exceeding given thresholds causes panic and abort)
24+
- `throttle-query`: change throttle query
25+
- `throttle-control-replicas`: change list of throttle-control replicas, these are replicas `gh-ost` will cehck
26+
- `throttle`: force migration suspend
27+
- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply)
28+
- `panic`: immediately panic and abort operation
2429

2530
### Examples
2631

go/base/context.go

+25
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ func (this *MigrationContext) GetGhostTableName() string {
169169

170170
// GetOldTableName generates the name of the "old" table, into which the original table is renamed.
171171
func (this *MigrationContext) GetOldTableName() string {
172+
// if this.TestOnReplica {
173+
// return fmt.Sprintf("_%s_tst", this.OriginalTableName)
174+
// }
172175
return fmt.Sprintf("_%s_old", this.OriginalTableName)
173176
}
174177

@@ -361,6 +364,28 @@ func (this *MigrationContext) ReadCriticalLoad(criticalLoadList string) error {
361364
return nil
362365
}
363366

367+
func (this *MigrationContext) GetThrottleControlReplicaKeys() *mysql.InstanceKeyMap {
368+
this.throttleMutex.Lock()
369+
defer this.throttleMutex.Unlock()
370+
371+
keys := mysql.NewInstanceKeyMap()
372+
keys.AddKeys(this.ThrottleControlReplicaKeys.GetInstanceKeys())
373+
return keys
374+
}
375+
376+
func (this *MigrationContext) ReadThrottleControlReplicaKeys(throttleControlReplicas string) error {
377+
keys := mysql.NewInstanceKeyMap()
378+
if err := keys.ReadCommaDelimitedList(throttleControlReplicas); err != nil {
379+
return err
380+
}
381+
382+
this.throttleMutex.Lock()
383+
defer this.throttleMutex.Unlock()
384+
385+
this.ThrottleControlReplicaKeys = keys
386+
return nil
387+
}
388+
364389
// ApplyCredentials sorts out the credentials between the config file and the CLI flags
365390
func (this *MigrationContext) ApplyCredentials() {
366391
this.configMutex.Lock()

go/cmd/gh-ost/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func main() {
153153
if err := migrationContext.ReadConfigFile(); err != nil {
154154
log.Fatale(err)
155155
}
156-
if err := migrationContext.ThrottleControlReplicaKeys.ReadCommaDelimitedList(*throttleControlReplicas); err != nil {
156+
if err := migrationContext.ReadThrottleControlReplicaKeys(*throttleControlReplicas); err != nil {
157157
log.Fatale(err)
158158
}
159159
if err := migrationContext.ReadMaxLoad(*maxLoad); err != nil {

go/logic/migrator.go

+19-9
Original file line numberDiff line numberDiff line change
@@ -659,15 +659,16 @@ func (this *Migrator) onServerCommand(command string, writer *bufio.Writer) (err
659659
case "help":
660660
{
661661
fmt.Fprintln(writer, `available commands:
662-
status # Print a status message
663-
chunk-size=<newsize> # Set a new chunk-size
664-
critical-load=<load> # Set a new set of max-load thresholds
665-
max-load=<load> # Set a new set of max-load thresholds
666-
throttle-query=<query> # Set a new throttle-query
667-
throttle # Force throttling
668-
no-throttle # End forced throttling (other throttling may still apply)
669-
panic # panic and quit without cleanup
670-
help # This message
662+
status # Print a status message
663+
chunk-size=<newsize> # Set a new chunk-size
664+
critical-load=<load> # Set a new set of max-load thresholds
665+
max-load=<load> # Set a new set of max-load thresholds
666+
throttle-query=<query> # Set a new throttle-query
667+
throttle-control-replicas=<replicas> #
668+
throttle # Force throttling
669+
no-throttle # End forced throttling (other throttling may still apply)
670+
panic # panic and quit without cleanup
671+
help # This message
671672
`)
672673
}
673674
case "info", "status":
@@ -703,6 +704,15 @@ help # This message
703704
this.migrationContext.SetThrottleQuery(arg)
704705
this.printStatus(ForcePrintStatusAndHint, writer)
705706
}
707+
case "throttle-control-replicas":
708+
{
709+
if err := this.migrationContext.ReadThrottleControlReplicaKeys(arg); err != nil {
710+
fmt.Fprintf(writer, "%s\n", err.Error())
711+
return log.Errore(err)
712+
}
713+
fmt.Fprintf(writer, "%s\n", this.migrationContext.GetThrottleControlReplicaKeys().ToCommaDelimitedList())
714+
this.printStatus(ForcePrintStatusAndHint, writer)
715+
}
706716
case "throttle", "pause", "suspend":
707717
{
708718
atomic.StoreInt64(&this.migrationContext.ThrottleCommandedByUser, 1)

0 commit comments

Comments
 (0)