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

Conversation

misalcedo
Copy link

Description

This PR fixes a data race in #1454.
That may have been the reason we saw inconsistent results when testing the parallel gh-ost setup.

In case this PR introduced Go code changes:

  • contributed code is using same conventions as original code
  • script/cibuild returns with no formatting errors, build errors or unit test errors.

@misalcedo misalcedo marked this pull request as ready for review April 9, 2025 19:54
@Copilot Copilot AI review requested due to automatic review settings April 9, 2025 19:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a data race issue by adding proper error handling and synchronization when processing events that update the lowWaterMark.

  • Added error handling for ProcessEventsUntilDrained in the migrator.
  • Wrapped the lowWaterMark update in a mutex block to ensure thread safety.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
go/logic/migrator.go Introduces error handling when processing event draining.
go/logic/coordinator.go Adds mutex locking around lowWaterMark update to avoid a race.
Files not reviewed (1)
  • script/test: Language not supported
Comments suppressed due to low confidence (2)

go/logic/migrator.go:1322

  • The new error handling for ProcessEventsUntilDrained looks good. Ensure that downstream error handling properly addresses this returned error to maintain system stability.
if err := this.trxCoordinator.ProcessEventsUntilDrained(); err != nil {

go/logic/coordinator.go:380

  • The use of a mutex to protect the update of lowWaterMark is a necessary fix; however, please verify that all other accesses to lowWaterMark (both read and write) are consistently synchronized with c.mu to eliminate any data race.
c.mu.Lock()

@meiji163 meiji163 merged commit aa81bbc into meiji163/parallel-repl Apr 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants