Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed String() call in favor of variable substitution. (#9829) #9947

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions dm/pkg/binlog/position.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,24 @@ func IsFreshPosition(location1 Location, flavor string, cmpGTID bool) bool {
// 0, true if gSet1 is equal to gSet2
// -1, true if gSet1 is less than gSet2
// but if can't compare gSet1 and gSet2, will returns 0, false.
<<<<<<< HEAD
func CompareGTID(gSet1, gSet2 gtid.Set) (int, bool) {
gSetIsEmpty1 := gSet1 == nil || len(gSet1.String()) == 0
gSetIsEmpty2 := gSet2 == nil || len(gSet2.String()) == 0
=======
var (
emptyMySQLGTIDSet, _ = gmysql.ParseMysqlGTIDSet("")
emptyMariaDBGTIDSet, _ = gmysql.ParseMariadbGTIDSet("")
)

func CheckGTIDSetEmpty(gSet gmysql.GTIDSet) bool {
return gSet == nil || gSet.Equal(emptyMySQLGTIDSet) || gSet.Equal(emptyMariaDBGTIDSet)
}

func CompareGTID(gSet1, gSet2 gmysql.GTIDSet) (int, bool) {
gSetIsEmpty1 := CheckGTIDSetEmpty(gSet1)
gSetIsEmpty2 := CheckGTIDSetEmpty(gSet2)
>>>>>>> 5ec0b15ee1 (Removed String() call in favor of variable substitution. (#9829))

switch {
case gSetIsEmpty1 && gSetIsEmpty2:
Expand Down
6 changes: 6 additions & 0 deletions dm/syncer/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,13 @@ func (cp *RemoteCheckPoint) IsOlderThanTablePoint(table *filter.Table, location
return false
}
oldLocation := point.MySQLLocation()
<<<<<<< HEAD
cp.logCtx.L().Debug("compare table location whether is newer", zap.Stringer("location", location), zap.Stringer("old location", oldLocation))
=======
// if we update enable-gtid = false to true, we need to compare binlog position instead of GTID before we save table point
cmpGTID := cp.cfg.EnableGTID && !(binlog.CheckGTIDSetEmpty(oldLocation.GetGTID()) && binlog.ComparePosition(oldLocation.Position, binlog.MinPosition) > 0)
cp.logCtx.L().Debug("compare table location whether is newer", zap.Stringer("location", location), zap.Stringer("old location", oldLocation), zap.Bool("cmpGTID", cmpGTID))
>>>>>>> 5ec0b15ee1 (Removed String() call in favor of variable substitution. (#9829))

if useLE {
return binlog.CompareLocation(location, oldLocation, cp.cfg.EnableGTID) <= 0
Expand Down
5 changes: 5 additions & 0 deletions dm/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3428,7 +3428,12 @@ func (s *Syncer) adjustGlobalPointGTID(tctx *tcontext.Context) (bool, error) {
// 1. GTID is not enabled
// 2. location already has GTID position
// 3. location is totally new, has no position info
<<<<<<< HEAD
if !s.cfg.EnableGTID || location.GTIDSetStr() != "" || location.Position.Name == "" {
=======
// 4. location is too early thus not a COMMIT location, which happens when it's reset by other logic
if !s.cfg.EnableGTID || !binlog.CheckGTIDSetEmpty(location.GetGTID()) || location.Position.Name == "" || location.Position.Pos == 4 {
>>>>>>> 5ec0b15ee1 (Removed String() call in favor of variable substitution. (#9829))
return false, nil
}
// set enableGTID to false for new streamerController
Expand Down