noting posponing status

This commit is contained in:
Shlomi Noach 2016-06-13 18:36:29 +02:00
parent 29aead6212
commit e4ed801df5
2 changed files with 6 additions and 1 deletions

View File

@ -100,6 +100,7 @@ type MigrationContext struct {
isThrottled bool isThrottled bool
throttleReason string throttleReason string
throttleMutex *sync.Mutex throttleMutex *sync.Mutex
IsPostponingCutOver int64
OriginalTableColumns *sql.ColumnList OriginalTableColumns *sql.ColumnList
OriginalTableUniqueKeys [](*sql.UniqueKey) OriginalTableUniqueKeys [](*sql.UniqueKey)

View File

@ -381,12 +381,14 @@ func (this *Migrator) stopWritesAndCompleteMigration() (err error) {
} }
if base.FileExists(this.migrationContext.PostponeCutOverFlagFile) { if base.FileExists(this.migrationContext.PostponeCutOverFlagFile) {
// Throttle file defined and exists! // 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) log.Debugf("Postponing final table swap as flag file exists: %+v", this.migrationContext.PostponeCutOverFlagFile)
return true, nil return true, nil
} }
return false, nil return false, nil
}, },
) )
atomic.StoreInt64(&this.migrationContext.IsPostponingCutOver, 0)
if this.migrationContext.TestOnReplica { if this.migrationContext.TestOnReplica {
return this.stopWritesAndCompleteMigrationOnReplica() return this.stopWritesAndCompleteMigrationOnReplica()
@ -699,7 +701,9 @@ func (this *Migrator) printStatus(writers ...io.Writer) {
var etaSeconds float64 = math.MaxFloat64 var etaSeconds float64 = math.MaxFloat64
eta := "N/A" 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) eta = fmt.Sprintf("throttled, %s", throttleReason)
} else if progressPct > 100.0 { } else if progressPct > 100.0 {
eta = "Due" eta = "Due"