Avoid a data race when dealing with the lowwatermark#1530
Merged
meiji163 merged 6 commits intomeiji163/parallel-replfrom Apr 9, 2025
Merged
Avoid a data race when dealing with the lowwatermark#1530meiji163 merged 6 commits intomeiji163/parallel-replfrom
meiji163 merged 6 commits intomeiji163/parallel-replfrom
Conversation
…a race condition.
…ck it in our code.
Contributor
There was a problem hiding this comment.
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
approved these changes
Apr 9, 2025
arthurschreiber
approved these changes
Apr 9, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
script/cibuildreturns with no formatting errors, build errors or unit test errors.