reading and reporting replication lag before waiting on initial replication event

This commit is contained in:
Shlomi Noach 2016-11-02 12:48:35 +01:00
parent aeb904395f
commit 88ffb75b8c
2 changed files with 12 additions and 1 deletions

View File

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

View File

@ -291,7 +291,8 @@ func (this *Migrator) Migrate() (err error) {
return err 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 <-this.ghostTableMigrated
log.Debugf("ghost table migrated") log.Debugf("ghost table migrated")
// Yay! We now know the Ghost and Changelog tables are good to examine! // Yay! We now know the Ghost and Changelog tables are good to examine!