Skip to content

fix: prevent connIO from panicking in race between Close and Enqueue #10948

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
Dec 1, 2023

Conversation

spikecurtis
Copy link
Contributor

Spotted during a code read. ConnIO unlocks the mutex before attempting to write to the response channel, which could allow another goroutine to call Close() and close the channel, causing a panic.

Fix is to hold the mutex. This won't cause a deadlock because the select{} has a default case, so we won't block even if the receiver isn't keeping up.

Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

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

Nice spot!

Copy link
Contributor Author

spikecurtis commented Dec 1, 2023

Merge activity

@spikecurtis spikecurtis force-pushed the spike/pg-coord-run-peer-cleanup branch from 05d874f to 484a54c Compare December 1, 2023 06:02
Base automatically changed from spike/pg-coord-run-peer-cleanup to main December 1, 2023 06:13
@spikecurtis spikecurtis force-pushed the spike/connio-close-enqueue-race branch from 4d79026 to 76686f2 Compare December 1, 2023 06:13
@spikecurtis spikecurtis merged commit 812fb95 into main Dec 1, 2023
@spikecurtis spikecurtis deleted the spike/connio-close-enqueue-race branch December 1, 2023 06:23
@github-actions github-actions bot locked and limited conversation to collaborators Dec 1, 2023
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.

2 participants