Skip to content

test: fix a race in TestReinit #17902

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 1 commit into from
May 19, 2025
Merged

test: fix a race in TestReinit #17902

merged 1 commit into from
May 19, 2025

Conversation

SasSwart
Copy link
Contributor

closes coder/internal#632

pubsubReinitSpy used to signal that a subscription had happened before it actually had.
This created a slight opportunity for the main goroutine to publish before the actual subscription was listening. The published event was then dropped, leading to a failed test.

@SasSwart SasSwart changed the title test: Fix a race in TestReinit test: fix a race in TestReinit May 19, 2025
@SasSwart SasSwart requested review from johnstcn and spikecurtis May 19, 2025 07:57
@SasSwart SasSwart marked this pull request as ready for review May 19, 2025 07:58
Comment on lines +2707 to 2708
cancel, err = p.Pubsub.Subscribe(event, listener)
p.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

Would it not make more sense to move the subscribe call after we lock the spy's mutex?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think so; the mutex is protecting the expectedEvent and triedToSubscribe, not the underlying pubsub.

@SasSwart SasSwart merged commit c775ea8 into main May 19, 2025
40 checks passed
@SasSwart SasSwart deleted the jjs/internal-632 branch May 19, 2025 09:37
@github-actions github-actions bot locked and limited conversation to collaborators May 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake: TestReinit
3 participants