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
throttleReason string
throttleMutex *sync.Mutex
IsPostponingCutOver int64
OriginalTableColumns *sql.ColumnList
OriginalTableUniqueKeys [](*sql.UniqueKey)

View File

@ -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"