Skip to content

Commit

Permalink
xenoncli: rebuildme find a not too lagging peer
Browse files Browse the repository at this point in the history
  • Loading branch information
lunsir authored and Toknowledge committed Aug 17, 2018
1 parent fd8a8e7 commit a8f0a74
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cli/callx/callx.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"model"
"os"
"raft"
"strconv"
"strings"
"text/tabwriter"
"time"
Expand Down Expand Up @@ -133,12 +134,13 @@ func FindBestoneForBackup(self string) (string, error) {
if node != leader {
if rsp, err := GetMysqlStatusRPC(node); err == nil {
GTID := rsp.GTID
if GTID.Slave_SQL_Running &&
GTID.Slave_IO_Running &&
node != self {
log.Warning("rebuildme.found.best.slave[%v].leader[%v]",
node, leader)
return node, nil
if GTID.Slave_SQL_Running && GTID.Slave_IO_Running {
if num, _ := strconv.Atoi(GTID.Seconds_Behind_Master); num < 100 &&
node != self {
log.Warning("rebuildme.found.best.slave[%v].leader[%v]",
node, leader)
return node, nil
}
}
}
}
Expand Down

0 comments on commit a8f0a74

Please sign in to comment.