Skip to content

Commit a4218cd

Browse files
committed
Progress should print HeartbeatLag
1 parent 8aee288 commit a4218cd

4 files changed

Lines changed: 8 additions & 1 deletion

File tree

doc/hooks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ The following variables are available on all hooks:
6666
- `GH_OST_ESTIMATED_ROWS` - estimated total rows in table
6767
- `GH_OST_COPIED_ROWS` - number of rows copied by `gh-ost`
6868
- `GH_OST_INSPECTED_LAG` - lag in seconds (floating point) of inspected server
69+
- `GH_OST_HEARTBEAT_LAG` - lag in seconds (floating point) of heartbeat
6970
- `GH_OST_PROGRESS` - progress pct ([0..100], floating point) of migration
7071
- `GH_OST_MIGRATED_HOST`
7172
- `GH_OST_INSPECTED_HOST`

go/base/context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ func (this *MigrationContext) MarkRowCopyEndTime() {
455455
this.RowCopyEndTime = time.Now()
456456
}
457457

458+
func (this *MigrationContext) GetCurrentHeartbeatLagDuration() time.Duration {
459+
return time.Duration(atomic.LoadInt64(&this.CurrentHeartbeatLag))
460+
}
461+
458462
func (this *MigrationContext) GetCurrentLagDuration() time.Duration {
459463
return time.Duration(atomic.LoadInt64(&this.CurrentLag))
460464
}

go/logic/hooks.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func (this *HooksExecutor) applyEnvironmentVariables(extraVariables ...string) [
6464
env = append(env, fmt.Sprintf("GH_OST_INSPECTED_HOST=%s", this.migrationContext.GetInspectorHostname()))
6565
env = append(env, fmt.Sprintf("GH_OST_EXECUTING_HOST=%s", this.migrationContext.Hostname))
6666
env = append(env, fmt.Sprintf("GH_OST_INSPECTED_LAG=%f", this.migrationContext.GetCurrentLagDuration().Seconds()))
67+
env = append(env, fmt.Sprintf("GH_OST_HEARTBEAT_LAG=%f", this.migrationContext.GetCurrentHeartbeatLagDuration().Seconds()))
6768
env = append(env, fmt.Sprintf("GH_OST_PROGRESS=%f", this.migrationContext.GetProgressPct()))
6869
env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT=%s", this.migrationContext.HooksHintMessage))
6970
env = append(env, fmt.Sprintf("GH_OST_HOOKS_HINT_OWNER=%s", this.migrationContext.HooksHintOwner))

go/logic/migrator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,14 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
980980

981981
currentBinlogCoordinates := *this.eventsStreamer.GetCurrentBinlogCoordinates()
982982

983-
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; Lag: %.2fs, State: %s; ETA: %s",
983+
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; Lag: %.2fs, HeartbeatLag: %.2fs, State: %s; ETA: %s",
984984
totalRowsCopied, rowsEstimate, progressPct,
985985
atomic.LoadInt64(&this.migrationContext.TotalDMLEventsApplied),
986986
len(this.applyEventsQueue), cap(this.applyEventsQueue),
987987
base.PrettifyDurationOutput(elapsedTime), base.PrettifyDurationOutput(this.migrationContext.ElapsedRowCopyTime()),
988988
currentBinlogCoordinates,
989989
this.migrationContext.GetCurrentLagDuration().Seconds(),
990+
this.migrationContext.GetCurrentHeartbeatLagDuration().Seconds(),
990991
state,
991992
eta,
992993
)

0 commit comments

Comments
 (0)