make the test loop less race'y#22637
Open
Tofel wants to merge 1 commit into
Open
Conversation
Contributor
|
✅ No conflicts with other open PRs targeting |
|
mchain0
approved these changes
May 26, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Risk Rating: LOW
This PR updates a concurrency-sensitive test loop in TestLogEventProvider_ScheduleReadJobs to avoid a race between a non-blocking select { default: ... } branch and async goroutine preemption, which could previously cause the test to exit early and leave scheduled reads unconsumed.
Changes:
- Replaced the busy-wait
selectloop (withdefault+runtime.Gosched()) with a blocking loop that continues until all expected IDs have been observed. - Removed the now-unneeded
runtimeimport from the test file.
Areas requiring scrupulous human review:
- None beyond confirming this test’s new termination condition matches the intended assertion semantics (it now exits only once all expected IDs are seen, or fails via timeout/context).
jmank88
approved these changes
May 27, 2026
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.





Suspect
Race between Go async preemption and the test's default branch. The select could pick
default(reads buffer empty), and beforep.CurrentPartitionIdx()was called — a function-call safe point — the goroutine could be preempted. During that suspension,scheduleReadJobsfired all 3 ticks (30ms), incrementingcurrentPartitionIdxto 3 and sending items to reads. On resume, the test loadedpartitionIdx = 3, broke immediately, and never ran another select — leaving items in reads unconsumed and got empty.Fix
Replaced the racy busy-wait
defaultcase with a blocking loop that exits only when all expected IDs appear inreads.