Skip to content

Commit c562df4

Browse files
author
Shlomi Noach
committed
status: State and ETA decoupling
1 parent dfde634 commit c562df4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

go/logic/migrator.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -906,14 +906,8 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
906906

907907
var etaSeconds float64 = math.MaxFloat64
908908
eta := "N/A"
909-
if atomic.LoadInt64(&this.migrationContext.CountingRowsFlag) > 0 && !this.migrationContext.ConcurrentCountTableRows {
910-
eta = "counting rows"
911-
} else if atomic.LoadInt64(&this.migrationContext.IsPostponingCutOver) > 0 {
912-
eta = "postponing cut-over"
913-
} else if isThrottled, throttleReason := this.migrationContext.IsThrottled(); isThrottled {
914-
eta = fmt.Sprintf("throttled, %s", throttleReason)
915-
} else if progressPct > 100.0 {
916-
eta = "Due"
909+
if progressPct >= 100.0 {
910+
eta = "due"
917911
} else if progressPct >= 1.0 {
918912
elapsedRowCopySeconds := this.migrationContext.ElapsedRowCopyTime().Seconds()
919913
totalExpectedSeconds := elapsedRowCopySeconds * float64(rowsEstimate) / float64(totalRowsCopied)
@@ -922,10 +916,20 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
922916
etaDuration := time.Duration(etaSeconds) * time.Second
923917
eta = base.PrettifyDurationOutput(etaDuration)
924918
} else {
925-
eta = "Due"
919+
eta = "due"
926920
}
927921
}
928922

923+
state := "migrating"
924+
if atomic.LoadInt64(&this.migrationContext.CountingRowsFlag) > 0 && !this.migrationContext.ConcurrentCountTableRows {
925+
state = "counting rows"
926+
} else if atomic.LoadInt64(&this.migrationContext.IsPostponingCutOver) > 0 {
927+
eta = "due"
928+
state = "postponing cut-over"
929+
} else if isThrottled, throttleReason := this.migrationContext.IsThrottled(); isThrottled {
930+
state = fmt.Sprintf("throttled, %s", throttleReason)
931+
}
932+
929933
shouldPrintStatus := false
930934
if rule == HeuristicPrintStatusRule {
931935
if elapsedSeconds <= 60 {
@@ -951,12 +955,13 @@ func (this *Migrator) printStatus(rule PrintStatusRule, writers ...io.Writer) {
951955

952956
currentBinlogCoordinates := *this.eventsStreamer.GetCurrentBinlogCoordinates()
953957

954-
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; ETA: %s",
958+
status := fmt.Sprintf("Copy: %d/%d %.1f%%; Applied: %d; Backlog: %d/%d; Time: %+v(total), %+v(copy); streamer: %+v; State: %s; ETA: %s",
955959
totalRowsCopied, rowsEstimate, progressPct,
956960
atomic.LoadInt64(&this.migrationContext.TotalDMLEventsApplied),
957961
len(this.applyEventsQueue), cap(this.applyEventsQueue),
958962
base.PrettifyDurationOutput(elapsedTime), base.PrettifyDurationOutput(this.migrationContext.ElapsedRowCopyTime()),
959963
currentBinlogCoordinates,
964+
state,
960965
eta,
961966
)
962967
this.applier.WriteChangelog(

0 commit comments

Comments
 (0)