Skip to content

Commit d016760

Browse files
author
Shlomi Noach
authored
Merge pull request #411 from github/server-report-coordinates
support for 'coordinates' command
2 parents d757539 + eaa3489 commit d016760

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

doc/interactive-commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Both interfaces may serve at the same time. Both respond to simple text command,
1717
- `help`: shows a brief list of available commands
1818
- `status`: returns a detailed status summary of migration progress and configuration
1919
- `sup`: returns a brief status summary of migration progress
20+
- `coordinates`: returns recent (though not exactly up to date) binary log coordinates of the inspected server
2021
- `chunk-size=<newsize>`: modify the `chunk-size`; applies on next running copy-iteration
2122
- `max-lag-millis=<max-lag>`: modify the maximum replication lag threshold (milliseconds, minimum value is `100`, i.e. `0.1` second)
2223
- `max-load=<max-load-thresholds>`: modify the `max-load` config; applies on next running copy-iteration

go/base/context.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ type MigrationContext struct {
189189
MigrationIterationRangeMinValues *sql.ColumnValues
190190
MigrationIterationRangeMaxValues *sql.ColumnValues
191191

192+
recentBinlogCoordinates mysql.BinlogCoordinates
193+
192194
CanStopStreaming func() bool
193195
}
194196

@@ -544,6 +546,19 @@ func (this *MigrationContext) SetNiceRatio(newRatio float64) {
544546
this.niceRatio = newRatio
545547
}
546548

549+
func (this *MigrationContext) GetRecentBinlogCoordinates() mysql.BinlogCoordinates {
550+
this.throttleMutex.Lock()
551+
defer this.throttleMutex.Unlock()
552+
553+
return this.recentBinlogCoordinates
554+
}
555+
556+
func (this *MigrationContext) SetRecentBinlogCoordinates(coordinates mysql.BinlogCoordinates) {
557+
this.throttleMutex.Lock()
558+
defer this.throttleMutex.Unlock()
559+
this.recentBinlogCoordinates = coordinates
560+
}
561+
547562
// ReadMaxLoad parses the `--max-load` flag, which is in multiple key-value format,
548563
// such as: 'Threads_running=100,Threads_connected=500'
549564
// It only applies changes in case there's no parsing error.

go/logic/migrator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,13 @@ func (this *Migrator) initiateStreaming() error {
953953
}
954954
log.Debugf("Done streaming")
955955
}()
956+
957+
go func() {
958+
ticker := time.Tick(1 * time.Second)
959+
for range ticker {
960+
this.migrationContext.SetRecentBinlogCoordinates(*this.eventsStreamer.GetCurrentBinlogCoordinates())
961+
}
962+
}()
956963
return nil
957964
}
958965

go/logic/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ func (this *Server) applyServerCommand(command string, writer *bufio.Writer) (pr
144144
fmt.Fprintln(writer, `available commands:
145145
status # Print a detailed status message
146146
sup # Print a short status message
147+
coordinates # Print the currently inspected coordinates
147148
chunk-size=<newsize> # Set a new chunk-size
148149
nice-ratio=<ratio> # Set a new nice-ratio, immediate sleep after each row-copy operation, float (examples: 0 is agrressive, 0.7 adds 70% runtime, 1.0 doubles runtime, 2.0 triples runtime, ...)
149150
critical-load=<load> # Set a new set of max-load thresholds
@@ -165,6 +166,14 @@ help # This message
165166
return ForcePrintStatusOnlyRule, nil
166167
case "info", "status":
167168
return ForcePrintStatusAndHintRule, nil
169+
case "coordinates":
170+
{
171+
if argIsQuestion || arg == "" {
172+
fmt.Fprintf(writer, "%+v\n", this.migrationContext.GetRecentBinlogCoordinates())
173+
return NoPrintStatusRule, nil
174+
}
175+
return NoPrintStatusRule, fmt.Errorf("coordinates are read-only")
176+
}
168177
case "chunk-size":
169178
{
170179
if argIsQuestion {

0 commit comments

Comments
 (0)