From 2fb524f43a8d24e9b3f8e5e1f26624780112913f Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Fri, 2 Apr 2021 01:50:11 +0200 Subject: [PATCH 1/7] Adds 'hosts' command to server --- go/logic/server.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/go/logic/server.go b/go/logic/server.go index 1606884..aa5b43a 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -1,5 +1,5 @@ /* - Copyright 2016 GitHub Inc. + Copyright 2021 GitHub Inc. See https://github.com/github/gh-ost/blob/master/LICENSE */ @@ -146,7 +146,8 @@ func (this *Server) applyServerCommand(command string, writer *bufio.Writer) (pr fmt.Fprint(writer, `available commands: status # Print a detailed status message sup # Print a short status message -coordinates # Print the currently inspected coordinates +coordinates # Print the currently inspected coordinates +hosts # Print the list of hosts used to perform the migration (hostname, applier and migrator) chunk-size= # Set a new chunk-size dml-batch-size= # Set a new dml-batch-size nice-ratio= # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is aggressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...) @@ -177,6 +178,16 @@ help # This message } return NoPrintStatusRule, fmt.Errorf("coordinates are read-only") } + case "hosts": + fields := map[string]interface{}{ + "Applier": this.migrationContext.GetApplierHostname(), + "Hostname": this.migrationContext.Hostname, + "Inspector": this.migrationContext.GetInspectorHostname(), + } + for key, val := range fields { + fmt.Fprintf(writer, "%s: %v", key, val) + } + return NoPrintStatusRule, nil case "chunk-size": { if argIsQuestion { From 094d11d722eb0fd8fe69f01a0645ff2559b1623c Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Fri, 2 Apr 2021 01:58:06 +0200 Subject: [PATCH 2/7] Use a single line --- go/logic/server.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/go/logic/server.go b/go/logic/server.go index aa5b43a..749cc70 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -179,14 +179,11 @@ help # This message return NoPrintStatusRule, fmt.Errorf("coordinates are read-only") } case "hosts": - fields := map[string]interface{}{ - "Applier": this.migrationContext.GetApplierHostname(), - "Hostname": this.migrationContext.Hostname, - "Inspector": this.migrationContext.GetInspectorHostname(), - } - for key, val := range fields { - fmt.Fprintf(writer, "%s: %v", key, val) - } + fmt.Fprintf(writer, "Hostname: %s, Applier: %s, Inspector: %s\n", + this.migrationContext.GetApplierHostname(), + this.migrationContext.Hostname, + this.migrationContext.GetInspectorHostname(), + ) return NoPrintStatusRule, nil case "chunk-size": { From 7ea47cbfb5b02b08866b8c9638a37622b9be02e4 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Fri, 2 Apr 2021 01:58:59 +0200 Subject: [PATCH 3/7] Fix order --- go/logic/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/logic/server.go b/go/logic/server.go index 749cc70..44e4c91 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -180,8 +180,8 @@ help # This message } case "hosts": fmt.Fprintf(writer, "Hostname: %s, Applier: %s, Inspector: %s\n", - this.migrationContext.GetApplierHostname(), this.migrationContext.Hostname, + this.migrationContext.GetApplierHostname(), this.migrationContext.GetInspectorHostname(), ) return NoPrintStatusRule, nil From cffb523badf2b98d3b5618f8e28c384ab483ac9f Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Fri, 2 Apr 2021 02:02:08 +0200 Subject: [PATCH 4/7] Fix help typo --- go/logic/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/logic/server.go b/go/logic/server.go index 44e4c91..bf319ac 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -147,7 +147,7 @@ func (this *Server) applyServerCommand(command string, writer *bufio.Writer) (pr status # Print a detailed status message sup # Print a short status message coordinates # Print the currently inspected coordinates -hosts # Print the list of hosts used to perform the migration (hostname, applier and migrator) +hosts # Print the list of hosts used to perform the migration (hostname, applier and inspector) chunk-size= # Set a new chunk-size dml-batch-size= # Set a new dml-batch-size nice-ratio= # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is aggressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...) From 123b46f9bb091989aba9b8bdaa674bb4424774ec Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Fri, 2 Apr 2021 16:57:13 +0200 Subject: [PATCH 5/7] Split into 'applier' and 'inspector' commands --- doc/interactive-commands.md | 2 ++ go/logic/server.go | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/interactive-commands.md b/doc/interactive-commands.md index 591aa49..7ad44f1 100644 --- a/doc/interactive-commands.md +++ b/doc/interactive-commands.md @@ -18,6 +18,8 @@ Both interfaces may serve at the same time. Both respond to simple text command, - `status`: returns a detailed status summary of migration progress and configuration - `sup`: returns a brief status summary of migration progress - `coordinates`: returns recent (though not exactly up to date) binary log coordinates of the inspected server +- `applier`: returns the hostname of the applier +- `inspector`: returns the hostname of the inspector - `chunk-size=`: modify the `chunk-size`; applies on next running copy-iteration - `dml-batch-size=`: modify the `dml-batch-size`; applies on next applying of binary log events - `max-lag-millis=`: modify the maximum replication lag threshold (milliseconds, minimum value is `100`, i.e. `0.1` second) diff --git a/go/logic/server.go b/go/logic/server.go index bf319ac..a70c08f 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -147,7 +147,8 @@ func (this *Server) applyServerCommand(command string, writer *bufio.Writer) (pr status # Print a detailed status message sup # Print a short status message coordinates # Print the currently inspected coordinates -hosts # Print the list of hosts used to perform the migration (hostname, applier and inspector) +applier # Print the hostname of the applier +inspector # Print the hostname of the inspector chunk-size= # Set a new chunk-size dml-batch-size= # Set a new dml-batch-size nice-ratio= # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is aggressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...) @@ -178,12 +179,11 @@ help # This message } return NoPrintStatusRule, fmt.Errorf("coordinates are read-only") } - case "hosts": - fmt.Fprintf(writer, "Hostname: %s, Applier: %s, Inspector: %s\n", - this.migrationContext.Hostname, - this.migrationContext.GetApplierHostname(), - this.migrationContext.GetInspectorHostname(), - ) + case "applier": + fmt.Fprintln(writer, this.migrationContext.GetApplierHostname()) + return NoPrintStatusRule, nil + case "inspector": + fmt.Fprintln(writer, this.migrationContext.GetInspectorHostname()) return NoPrintStatusRule, nil case "chunk-size": { From 23a421cef7f6a2b3a90a5e4765678322e41b1dc0 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Sat, 3 Apr 2021 22:34:20 +0200 Subject: [PATCH 6/7] Add 'Hostname:' prefix to output --- go/logic/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go/logic/server.go b/go/logic/server.go index a70c08f..29d8318 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -180,10 +180,10 @@ help # This message return NoPrintStatusRule, fmt.Errorf("coordinates are read-only") } case "applier": - fmt.Fprintln(writer, this.migrationContext.GetApplierHostname()) + fmt.Fprintf(writer, "Hostname: %s\n", this.migrationContext.GetApplierHostname()) return NoPrintStatusRule, nil case "inspector": - fmt.Fprintln(writer, this.migrationContext.GetInspectorHostname()) + fmt.Fprintf(writer, "Hostname: %s\n", this.migrationContext.GetInspectorHostname()) return NoPrintStatusRule, nil case "chunk-size": { From 157dba920c1dddbb6b405dc6b7f2fdd5a1270b8b Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Sat, 3 Apr 2021 23:24:29 +0200 Subject: [PATCH 7/7] Add mysql port and version --- go/logic/server.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/go/logic/server.go b/go/logic/server.go index 29d8318..3d128b1 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -180,10 +180,20 @@ help # This message return NoPrintStatusRule, fmt.Errorf("coordinates are read-only") } case "applier": - fmt.Fprintf(writer, "Hostname: %s\n", this.migrationContext.GetApplierHostname()) + if this.migrationContext.ApplierConnectionConfig != nil && this.migrationContext.ApplierConnectionConfig.ImpliedKey != nil { + fmt.Fprintf(writer, "Host: %s, Version: %s\n", + this.migrationContext.ApplierConnectionConfig.ImpliedKey.String(), + this.migrationContext.ApplierMySQLVersion, + ) + } return NoPrintStatusRule, nil case "inspector": - fmt.Fprintf(writer, "Hostname: %s\n", this.migrationContext.GetInspectorHostname()) + if this.migrationContext.InspectorConnectionConfig != nil && this.migrationContext.InspectorConnectionConfig.ImpliedKey != nil { + fmt.Fprintf(writer, "Host: %s, Version: %s\n", + this.migrationContext.InspectorConnectionConfig.ImpliedKey.String(), + this.migrationContext.InspectorMySQLVersion, + ) + } return NoPrintStatusRule, nil case "chunk-size": {