applyServerCommand parses and executes commands by user
(command string, writer *bufio.Writer)
| 194 | |
| 195 | // applyServerCommand parses and executes commands by user |
| 196 | func (srv *Server) applyServerCommand(command string, writer *bufio.Writer) (printStatusRule PrintStatusRule, err error) { |
| 197 | tokens := strings.SplitN(command, "=", 2) |
| 198 | command = strings.TrimSpace(tokens[0]) |
| 199 | arg := "" |
| 200 | if len(tokens) > 1 { |
| 201 | arg = strings.TrimSpace(tokens[1]) |
| 202 | if unquoted, err := strconv.Unquote(arg); err == nil { |
| 203 | arg = unquoted |
| 204 | } |
| 205 | } |
| 206 | argIsQuestion := (arg == "?") |
| 207 | throttleHint := "# Note: you may only throttle for as long as your binary logs are not purged" |
| 208 | |
| 209 | if err := srv.hooksExecutor.OnInteractiveCommand(command); err != nil { |
| 210 | return NoPrintStatusRule, err |
| 211 | } |
| 212 | |
| 213 | switch command { |
| 214 | case "help": |
| 215 | { |
| 216 | fmt.Fprint(writer, `available commands: |
| 217 | status # Print a detailed status message |
| 218 | sup # Print a short status message |
| 219 | cpu-profile=<options> # Print a base64-encoded runtime/pprof CPU profile using a duration, default: 30s. Comma-separated options 'gzip' and/or 'block' (blocked profile) may follow the profile duration |
| 220 | coordinates # Print the currently inspected coordinates |
| 221 | applier # Print the hostname of the applier |
| 222 | inspector # Print the hostname of the inspector |
| 223 | chunk-size=<newsize> # Set a new chunk-size |
| 224 | dml-batch-size=<newsize> # Set a new dml-batch-size |
| 225 | nice-ratio=<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, ...) |
| 226 | critical-load=<load> # Set a new set of max-load thresholds |
| 227 | max-lag-millis=<max-lag> # Set a new replication lag threshold |
| 228 | replication-lag-query=<query> # Set a new query that determines replication lag (no quotes) |
| 229 | max-load=<load> # Set a new set of max-load thresholds |
| 230 | throttle-query=<query> # Set a new throttle-query (no quotes) |
| 231 | throttle-http=<URL> # Set a new throttle URL |
| 232 | throttle-control-replicas=<replicas> # Set a new comma delimited list of throttle control replicas |
| 233 | throttle # Force throttling |
| 234 | no-throttle # End forced throttling (other throttling may still apply) |
| 235 | postpone-cut-over-flag-file=<path> # Postpone the cut-over phase, writing a cut over flag file to the given path |
| 236 | unpostpone # Bail out a cut-over postpone; proceed to cut-over |
| 237 | panic # panic and quit without cleanup |
| 238 | help # This message |
| 239 | - use '?' (question mark) as argument to get info rather than set. e.g. "max-load=?" will just print out current max-load. |
| 240 | `) |
| 241 | } |
| 242 | case "sup": |
| 243 | return ForcePrintStatusOnlyRule, nil |
| 244 | case "info", "status": |
| 245 | return ForcePrintStatusAndHintRule, nil |
| 246 | case "cpu-profile": |
| 247 | cpuProfile, err := srv.runCPUProfile(arg) |
| 248 | if err == nil { |
| 249 | fmt.Fprint(base64.NewEncoder(base64.StdEncoding, writer), cpuProfile) |
| 250 | } |
| 251 | return NoPrintStatusRule, err |
| 252 | case "coordinates": |
| 253 | { |
no test coverage detected