Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: fix race condition in pubsub startup #17088

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
Mar 25, 2025
Merged

Conversation

spikecurtis
Copy link
Contributor

@spikecurtis spikecurtis commented Mar 25, 2025

fixes coder/internal#525

If the context is canceled, the goroutine that is supposed to read from the errCh could exit prematurely, leading to a goroutine leak. Refactors this code so it cannot block.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@spikecurtis spikecurtis marked this pull request as ready for review March 25, 2025 12:37
@spikecurtis spikecurtis requested a review from mafredri March 25, 2025 12:37
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Except for the one question/concern, LGTM 👍🏻

}
errCh <- err // won't block because we are buffered.
sentErrCh = true
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to protect this or is sequential execution guaranteed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It executes sequentially, at least by inspection. There is always a chance they could change the implementation and call-back concurrently, but it didn't seem worth while defending for that.

@spikecurtis spikecurtis merged commit 5f3a53f into main Mar 25, 2025
37 checks passed
Copy link
Contributor Author

Merge activity

  • Mar 25, 8:45 AM EDT: A user merged this pull request with Graphite.

@spikecurtis spikecurtis deleted the spike/internal-525-pubsub branch March 25, 2025 12:45
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 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.

Pubsub goroutine leak
2 participants