-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restart only replicas ahead of the master (#113)
* restart only replicas ahead of the master * fix isSlavePermanentlyLost --------- Co-authored-by: Aleksandr Shevchuk <[email protected]>
- Loading branch information
Showing
6 changed files
with
73 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package gtids | ||
|
||
import ( | ||
gomysql "github.com/go-mysql-org/go-mysql/mysql" | ||
"github.com/google/uuid" | ||
) | ||
|
||
func IsSlaveBehindOrEqual(slaveGtidSet, masterGtidSet GTIDSet) bool { | ||
return masterGtidSet.Contain(slaveGtidSet) || masterGtidSet.Equal(slaveGtidSet) | ||
} | ||
|
||
func IsSlaveAhead(slaveGtidSet, masterGtidSet GTIDSet) bool { | ||
return !IsSlaveBehindOrEqual(slaveGtidSet, masterGtidSet) | ||
} | ||
|
||
func IsSplitBrained(slaveGtidSet, masterGtidSet GTIDSet, masterUUID uuid.UUID) bool { | ||
mysqlSlaveGtidSet := slaveGtidSet.(*gomysql.MysqlGTIDSet) | ||
mysqlMasterGtidSet := masterGtidSet.(*gomysql.MysqlGTIDSet) | ||
for _, slaveSet := range mysqlSlaveGtidSet.Sets { | ||
masterSet, ok := mysqlMasterGtidSet.Sets[slaveSet.SID.String()] | ||
if !ok { | ||
return true | ||
} | ||
|
||
if masterSet.Contain(slaveSet) { | ||
continue | ||
} | ||
|
||
if masterSet.SID == masterUUID { | ||
continue | ||
} | ||
|
||
return true | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters