Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

lib/group: fix race condition in test#39340

Merged
camdencheek merged 2 commits into
mainfrom
cc/fix-flaky-test
Jul 27, 2022
Merged

lib/group: fix race condition in test#39340
camdencheek merged 2 commits into
mainfrom
cc/fix-flaky-test

Conversation

@camdencheek

Copy link
Copy Markdown
Member

This test has a race condition. It can be triggered consistently by
adding a defer func() { time.Sleep(100 * time.Millisecond) }() before
the defer close(synchronizer). Unfortunately, I don't think it's
possible to completely remove the race condition without extending the
API of the group, so in this commit I resort to adding a sleep that
makes hitting the race condition vanishingly unlikely.

Test plan

Tested that the race condition is not hit with an added sleep.

This test has a race condition. It can be triggered consistently by
adding a `defer func() { time.Sleep(100 * time.Millisecond) }()` before
the `defer close(synchronizer)`. Unfortunately, I don't think it's
possible to completely remove the race condition without extending the
API of the group, so in this commit I resort to adding a sleep that
makes hitting the race condition vanishingly unlikely.
@cla-bot cla-bot Bot added the cla-signed label Jul 23, 2022
@camdencheek camdencheek requested a review from unknwon July 23, 2022 16:35

@unknwon unknwon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be great if we add your PR description to as a code comment, so people understand why a sleep is necessary here.

@camdencheek

Copy link
Copy Markdown
Member Author

Would be great if we add your PR description to as a code comment

Done!

@camdencheek camdencheek enabled auto-merge (squash) July 27, 2022 17:58
@camdencheek camdencheek merged commit 124dc27 into main Jul 27, 2022
@camdencheek camdencheek deleted the cc/fix-flaky-test branch July 27, 2022 18:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants