Skip to content

Commit

Permalink
bug fix: full gtid replaced with channel gtid
Browse files Browse the repository at this point in the history
  • Loading branch information
noname0443 committed Dec 29, 2023
1 parent b169948 commit 619183f
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions internal/app/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const (
type ReplicationRepairState struct {
LastAttempt time.Time
History map[ReplicationRepairAlgorithmType]int
BeforeRepairGTID *mysql.GTIDExecuted
BeforeRepairGTID string
}

func (app *App) MarkReplicationRunning(node *mysql.Node, channel string) {
Expand All @@ -31,12 +31,12 @@ func (app *App) MarkReplicationRunning(node *mysql.Node, channel string) {
return
}

gtid, err := node.GTIDExecuted()
status, err := node.GetReplicaStatus()
if err != nil {
return
}
if replState.cooldownPassed(app.config.ReplicationRepairCooldown) &&
replState.isGtidExecuted(gtid) {
replState.isGtidExecuted(status.GetExecutedGtidSet()) {
delete(app.replRepairState, key)
}
}
Expand Down Expand Up @@ -148,11 +148,8 @@ func (state *ReplicationRepairState) cooldownPassed(replicationRepairCooldown ti
return state.LastAttempt.Before(cooldown)
}

func (state *ReplicationRepairState) isGtidExecuted(currentGtid *mysql.GTIDExecuted) bool {
if state.BeforeRepairGTID.ExecutedGtidSet == currentGtid.ExecutedGtidSet {
return false
}
return true
func (state *ReplicationRepairState) isGtidExecuted(currentGtid string) bool {
return state.BeforeRepairGTID != currentGtid
}

func (app *App) getOrCreateHostRepairState(stateKey, hostname string) (*ReplicationRepairState, error) {
Expand All @@ -161,11 +158,11 @@ func (app *App) getOrCreateHostRepairState(stateKey, hostname string) (*Replicat
replState = state
} else {
replState = app.createRepairState()
executedGtid, err := app.cluster.Get(hostname).GTIDExecuted()
status, err := app.cluster.Get(hostname).GetReplicaStatus()
if err != nil {
return nil, err
}
replState.BeforeRepairGTID = executedGtid
replState.BeforeRepairGTID = status.GetExecutedGtidSet()
app.replRepairState[stateKey] = replState
}

Expand All @@ -176,7 +173,7 @@ func (app *App) createRepairState() *ReplicationRepairState {
result := ReplicationRepairState{
LastAttempt: time.Now(),
History: make(map[ReplicationRepairAlgorithmType]int),
BeforeRepairGTID: &mysql.GTIDExecuted{},
BeforeRepairGTID: "",
}

for i := range app.getAlgorithmOrder() {
Expand Down

0 comments on commit 619183f

Please sign in to comment.