NormalizeLoop: fix normalize race#4168
Merged
Merged
Conversation
Contributor
🔄 Flaky Test DetectedAnalysis: e2e TestGenericBQ failed with "UNEXPECTED TIMEOUT" waiting for inherited table rows to appear in BigQuery, a timing-dependent polling assertion in a slow external-service e2e test. ✅ Automatically retrying the workflow |
Contributor
🔄 Flaky Test DetectedAnalysis: TestApiPg/TestResyncFailed failed during teardown due to a race condition where the replication slot was still held by an active PID when the test tried to drop it — a timing issue unrelated to the test logic itself. ✅ Automatically retrying the workflow |
serprex
approved these changes
Apr 13, 2026
Contributor
|
LGTM |
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.
There's a race condition in normalizeLoop with the LastChan signaling mechanism.
The race:
normalizeLoopis insidestartNormalizeprocessing batch 346normRequests.Update(347)— this stores value 347, creates a new channel, and closes the old channelstartNormalizefor 346 returns, normalizeLoop goes back to the topnormalizeRequests.Wait()returns the new (unclosed) channel created in step 2normalizeLoopblocks on<-ch— but this channel will only be closed by the nextUpdate()(batch 348)Check for pending work via Load() before calling Wait(). Only block on the channel if there's genuinely nothing to process.