Skip to content

Commit

Permalink
fix: split brain when replica applied the transaction earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizic committed Mar 12, 2024
1 parent e4dc375 commit 52e4624
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ func (app *App) calcActiveNodes(clusterState, clusterStateDcs map[string]*NodeSt
continue
}
sgtids := gtids.ParseGtidSet(sstatus.ExecutedGtidSet)
if !(sstatus.ReplicationState == mysql.ReplicationRunning && isGTIDLessOrEqual(sgtids, mgtids)) {
if !(sstatus.ReplicationState == mysql.ReplicationRunning && isSplitBrained(sgtids, mgtids)) {
app.logger.Errorf("calc active nodes: %s is not replicating or splitbrained, deleting from active...", host)
continue
}
Expand Down
4 changes: 4 additions & 0 deletions internal/app/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ func isGTIDLessOrEqual(slaveGtidSet, masterGtidSet gtids.GTIDSet) bool {
return masterGtidSet.Contain(slaveGtidSet) || masterGtidSet.Equal(slaveGtidSet)
}

func isSplitBrained(firstGtidSet, secondGtidSet gtids.GTIDSet) bool {
return firstGtidSet.Contain(secondGtidSet) || secondGtidSet.Contain(firstGtidSet) || firstGtidSet.Equal(secondGtidSet)
}

func validatePriority(priority *int64) error {
if priority == nil || *priority >= 0 {
return nil
Expand Down

0 comments on commit 52e4624

Please sign in to comment.