Skip to content

Commit 79cee99

Browse files
author
Shlomi Noach
committed
support for 'coordinates' command
1 parent de349a7 commit 79cee99

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
@@ -188,6 +188,8 @@ type MigrationContext struct {
188188
MigrationIterationRangeMinValues *sql.ColumnValues
189189
MigrationIterationRangeMaxValues *sql.ColumnValues
190190

191+
recentBinlogCoordinates mysql.BinlogCoordinates
192+
191193
CanStopStreaming func() bool
192194
}
193195

@@ -543,6 +545,19 @@ func (this *MigrationContext) SetNiceRatio(newRatio float64) {
543545
this.niceRatio = newRatio
544546
}
545547

548+
func (this *MigrationContext) GetRecentBinlogCoordinates() mysql.BinlogCoordinates {
549+
this.throttleMutex.Lock()
550+
defer this.throttleMutex.Unlock()
551+
552+
return this.recentBinlogCoordinates
553+
}
554+
555+
func (this *MigrationContext) SetRecentBinlogCoordinates(coordinates mysql.BinlogCoordinates) {
556+
this.throttleMutex.Lock()
557+
defer this.throttleMutex.Unlock()
558+
this.recentBinlogCoordinates = coordinates
559+
}
560+
546561
// ReadMaxLoad parses the `--max-load` flag, which is in multiple key-value format,
547562
// such as: 'Threads_running=100,Threads_connected=500'
548563
// 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
@@ -952,6 +952,13 @@ func (this *Migrator) initiateStreaming() error {
952952
}
953953
log.Debugf("Done streaming")
954954
}()
955+
956+
go func() {
957+
ticker := time.Tick(1 * time.Second)
958+
for range ticker {
959+
this.migrationContext.SetRecentBinlogCoordinates(*this.eventsStreamer.GetCurrentBinlogCoordinates())
960+
}
961+
}()
955962
return nil
956963
}
957964

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)