diff --git a/build.sh b/build.sh index 44b160567..1743b4df1 100644 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash # # -RELEASE_VERSION="0.9.5" +RELEASE_VERSION="0.9.6" buildpath=/tmp/gh-ost target=gh-ost diff --git a/doc/interactive-commands.md b/doc/interactive-commands.md index cbf8eadb4..6c08de66c 100644 --- a/doc/interactive-commands.md +++ b/doc/interactive-commands.md @@ -16,11 +16,16 @@ Both interfaces may serve at the same time. Both respond to simple text command, - `help`: shows a brief list of available commands - `status`: returns a status summary of migration progress and configuration -- `throttle`: force migration suspend -- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply) +replication lag on to determine throttling - `chunk-size=`: modify the `chunk-size`; applies on next running copy-iteration - `max-load=`: modify the `max-load` config; applies on next running copy-iteration The `max-load` format must be: `some_status=[,some_status=...]`. 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. +- `critical-load=`: change critical load setting (exceeding given thresholds causes panic and abort) +- `throttle-query`: change throttle query +- `throttle-control-replicas`: change list of throttle-control replicas, these are replicas `gh-ost` will cehck +- `throttle`: force migration suspend +- `no-throttle`: cancel forced suspension (though other throttling reasons may still apply) +- `panic`: immediately panic and abort operation ### Examples diff --git a/go/base/context.go b/go/base/context.go index 42012389b..6fcabad47 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -169,6 +169,9 @@ func (this *MigrationContext) GetGhostTableName() string { // GetOldTableName generates the name of the "old" table, into which the original table is renamed. func (this *MigrationContext) GetOldTableName() string { + // if this.TestOnReplica { + // return fmt.Sprintf("_%s_tst", this.OriginalTableName) + // } return fmt.Sprintf("_%s_old", this.OriginalTableName) } @@ -361,6 +364,28 @@ func (this *MigrationContext) ReadCriticalLoad(criticalLoadList string) error { return nil } +func (this *MigrationContext) GetThrottleControlReplicaKeys() *mysql.InstanceKeyMap { + this.throttleMutex.Lock() + defer this.throttleMutex.Unlock() + + keys := mysql.NewInstanceKeyMap() + keys.AddKeys(this.ThrottleControlReplicaKeys.GetInstanceKeys()) + return keys +} + +func (this *MigrationContext) ReadThrottleControlReplicaKeys(throttleControlReplicas string) error { + keys := mysql.NewInstanceKeyMap() + if err := keys.ReadCommaDelimitedList(throttleControlReplicas); err != nil { + return err + } + + this.throttleMutex.Lock() + defer this.throttleMutex.Unlock() + + this.ThrottleControlReplicaKeys = keys + return nil +} + // ApplyCredentials sorts out the credentials between the config file and the CLI flags func (this *MigrationContext) ApplyCredentials() { this.configMutex.Lock() diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 7f167cb56..838b97027 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -153,7 +153,7 @@ func main() { if err := migrationContext.ReadConfigFile(); err != nil { log.Fatale(err) } - if err := migrationContext.ThrottleControlReplicaKeys.ReadCommaDelimitedList(*throttleControlReplicas); err != nil { + if err := migrationContext.ReadThrottleControlReplicaKeys(*throttleControlReplicas); err != nil { log.Fatale(err) } if err := migrationContext.ReadMaxLoad(*maxLoad); err != nil { diff --git a/go/logic/migrator.go b/go/logic/migrator.go index 6dd5fd24f..084c8a05c 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -659,15 +659,16 @@ func (this *Migrator) onServerCommand(command string, writer *bufio.Writer) (err case "help": { fmt.Fprintln(writer, `available commands: -status # Print a status message -chunk-size= # Set a new chunk-size -critical-load= # Set a new set of max-load thresholds -max-load= # Set a new set of max-load thresholds -throttle-query= # Set a new throttle-query -throttle # Force throttling -no-throttle # End forced throttling (other throttling may still apply) -panic # panic and quit without cleanup -help # This message +status # Print a status message +chunk-size= # Set a new chunk-size +critical-load= # Set a new set of max-load thresholds +max-load= # Set a new set of max-load thresholds +throttle-query= # Set a new throttle-query +throttle-control-replicas= # +throttle # Force throttling +no-throttle # End forced throttling (other throttling may still apply) +panic # panic and quit without cleanup +help # This message `) } case "info", "status": @@ -703,6 +704,15 @@ help # This message this.migrationContext.SetThrottleQuery(arg) this.printStatus(ForcePrintStatusAndHint, writer) } + case "throttle-control-replicas": + { + if err := this.migrationContext.ReadThrottleControlReplicaKeys(arg); err != nil { + fmt.Fprintf(writer, "%s\n", err.Error()) + return log.Errore(err) + } + fmt.Fprintf(writer, "%s\n", this.migrationContext.GetThrottleControlReplicaKeys().ToCommaDelimitedList()) + this.printStatus(ForcePrintStatusAndHint, writer) + } case "throttle", "pause", "suspend": { atomic.StoreInt64(&this.migrationContext.ThrottleCommandedByUser, 1)