Skip to content

Avoid a data race when dealing with the lowwatermark #1530

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

Merged
merged 6 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions go/logic/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@

switch binlogEvent := ev.Event.(type) {
case *replication.GTIDEvent:
c.mu.Lock()
if c.lowWaterMark == 0 && binlogEvent.SequenceNumber > 0 {
c.lowWaterMark = binlogEvent.SequenceNumber - 1
}
c.mu.Unlock()
case *replication.RotateEvent:
c.currentCoordinatesMutex.Lock()
c.currentCoordinates.LogFile = string(binlogEvent.NextLogName)
Expand Down Expand Up @@ -433,6 +435,7 @@
}
}
}
return nil

Check failure on line 438 in go/logic/coordinator.go

View workflow job for this annotation

GitHub Actions / lint

unreachable: unreachable code (govet)
}

func (c *Coordinator) InitializeWorkers(count int) {
Expand Down
4 changes: 3 additions & 1 deletion go/logic/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,9 @@ func (this *Migrator) executeWriteFuncs() error {

// We give higher priority to event processing.
// ProcessEventsUntilDrained will process all events in the queue, and then return once no more events are available.
this.trxCoordinator.ProcessEventsUntilDrained()
if err := this.trxCoordinator.ProcessEventsUntilDrained(); err != nil {
return this.migrationContext.Log.Errore(err)
}

this.throttler.throttle(nil)

Expand Down
2 changes: 1 addition & 1 deletion script/test
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ script/build
cd .gopath/src/github.com/github/gh-ost

echo "Running unit tests"
go test -v -p 1 -covermode=atomic ./go/...
go test -v -p 1 -covermode=atomic -race ./go/...
Loading