Merge pull request #306 from github/check-lag-on-starting

reading and reporting replication lag before waiting on initial repli…
This commit is contained in:
Shlomi Noach 2016-11-08 10:36:31 +01:00 committed by GitHub
commit 2771232589
2 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import (
"reflect"
"strings"
"sync/atomic"
"time"
"github.com/github/gh-ost/go/base"
"github.com/github/gh-ost/go/mysql"
@ -690,3 +691,12 @@ func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.Connect
visitedKeys := mysql.NewInstanceKeyMap()
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster)
}
func (this *Inspector) getReplicationLag() (replicationLag time.Duration, err error) {
replicationLagQuery := this.migrationContext.GetReplicationLagQuery()
replicationLag, err = mysql.GetReplicationLag(
this.migrationContext.InspectorConnectionConfig,
replicationLagQuery,
)
return replicationLag, err
}

View File

@ -291,7 +291,8 @@ func (this *Migrator) Migrate() (err error) {
return err
}
log.Infof("Waiting for ghost table to be migrated")
initialLag, _ := this.inspector.getReplicationLag()
log.Infof("Waiting for ghost table to be migrated. Current lag is %+v", initialLag)
<-this.ghostTableMigrated
log.Debugf("ghost table migrated")
// Yay! We now know the Ghost and Changelog tables are good to examine!