Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: CI
permissions:
contents: read

on: [pull_request]

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/replica-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: migration tests
permissions:
contents: read

on: [pull_request]

Expand Down
20 changes: 5 additions & 15 deletions go/mysql/binlog_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ func (this *FileBinlogCoordinates) SmallerThan(other BinlogCoordinates) bool {
if !ok || other == nil {
return false
}
if this.LogFile < coord.LogFile {
return true
}
if this.LogFile == coord.LogFile && this.LogPos < coord.LogPos {
return true

fileNumberDist := this.FileNumberDistance(coord)
if fileNumberDist == 0 {
return this.LogPos < coord.LogPos
}
return false
return fileNumberDist > 0
}

// SmallerThanOrEquals returns true if this coordinate is the same or equal to the other one.
Expand All @@ -100,15 +99,6 @@ func (this *FileBinlogCoordinates) SmallerThanOrEquals(other BinlogCoordinates)
return this.LogFile == coord.LogFile && this.LogPos == coord.LogPos // No Type comparison
}

// FileSmallerThan returns true if this coordinate's file is strictly smaller than the other's.
func (this *FileBinlogCoordinates) FileSmallerThan(other BinlogCoordinates) bool {
coord, ok := other.(*FileBinlogCoordinates)
if !ok || other == nil {
return false
}
return this.LogFile < coord.LogFile
}

// FileNumberDistance returns the numeric distance between this coordinate's file number and the other's.
// Effectively it means "how many rotates/FLUSHes would make these coordinates's file reach the other's"
func (this *FileBinlogCoordinates) FileNumberDistance(other *FileBinlogCoordinates) int {
Expand Down
16 changes: 16 additions & 0 deletions go/mysql/binlog_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,19 @@ func TestIsLogPosOverflowBeyond4Bytes(t *testing.T) {
require.True(t, curCoordinates.IsLogPosOverflowBeyond4Bytes(preCoordinates))
}
}

func TestBinlogCoordinates_LogFileZeroPaddedTransition(t *testing.T) {
c1 := FileBinlogCoordinates{LogFile: "mysql-bin.999999", LogPos: 100}
c2 := FileBinlogCoordinates{LogFile: "mysql-bin.1000000", LogPos: 100}

require.True(t, c1.SmallerThan(&c2))
}

func TestBinlogCoordinates_SameLogFileDifferentPosition(t *testing.T) {
c1 := FileBinlogCoordinates{LogFile: "binlog.000001", LogPos: 100}
c2 := FileBinlogCoordinates{LogFile: "binlog.000001", LogPos: 200}

require.True(t, c1.SmallerThan(&c2))
require.False(t, c2.SmallerThan(&c1))
require.False(t, c1.SmallerThan(&c1))
}