From e4ed801df5a08ce67b8777abf27358355baa0d45 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Mon, 13 Jun 2016 18:36:29 +0200 Subject: [PATCH] noting posponing status --- go/base/context.go | 1 + go/logic/migrator.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go/base/context.go b/go/base/context.go index ba0e025..01ed1d6 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -100,6 +100,7 @@ type MigrationContext struct { isThrottled bool throttleReason string throttleMutex *sync.Mutex + IsPostponingCutOver int64 OriginalTableColumns *sql.ColumnList OriginalTableUniqueKeys [](*sql.UniqueKey) diff --git a/go/logic/migrator.go b/go/logic/migrator.go index 86169c3..c4dea8c 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -381,12 +381,14 @@ func (this *Migrator) stopWritesAndCompleteMigration() (err error) { } if base.FileExists(this.migrationContext.PostponeCutOverFlagFile) { // Throttle file defined and exists! + atomic.StoreInt64(&this.migrationContext.IsPostponingCutOver, 1) log.Debugf("Postponing final table swap as flag file exists: %+v", this.migrationContext.PostponeCutOverFlagFile) return true, nil } return false, nil }, ) + atomic.StoreInt64(&this.migrationContext.IsPostponingCutOver, 0) if this.migrationContext.TestOnReplica { return this.stopWritesAndCompleteMigrationOnReplica() @@ -699,7 +701,9 @@ func (this *Migrator) printStatus(writers ...io.Writer) { var etaSeconds float64 = math.MaxFloat64 eta := "N/A" - if isThrottled, throttleReason := this.migrationContext.IsThrottled(); isThrottled { + if atomic.LoadInt64(&this.migrationContext.IsPostponingCutOver) > 0 { + eta = "postponing cut-over" + } else if isThrottled, throttleReason := this.migrationContext.IsThrottled(); isThrottled { eta = fmt.Sprintf("throttled, %s", throttleReason) } else if progressPct > 100.0 { eta = "Due"