Skip to content
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

Fixed write to closed channel in dispatcher #87

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

korotin
Copy link
Collaborator

@korotin korotin commented Nov 26, 2024

Dispatcher may panic with send on closed channel when pool is closing while new jobs are being added.

Write tries to send on bufferHasElements, which may be being closed in Close() at the same moment. To avoid that, I decided to never close bufferHasElements which may seem dirty, but should work fine since bufferHasElements will be removed by GC anyway.

I added test case to reproduce the issue as well.

@korotin korotin force-pushed the fix-dispatcher-closed-channel branch from 0e1af5c to 05bba89 Compare November 27, 2024 07:40
@korotin
Copy link
Collaborator Author

korotin commented Nov 27, 2024

Fixed failing tests.

Have no idea how i missed that(

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 92.30769% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.32%. Comparing base (fc408b5) to head (05bba89).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
internal/dispatcher/dispatcher.go 92.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #87      +/-   ##
==========================================
- Coverage   95.52%   95.32%   -0.21%     
==========================================
  Files          14       14              
  Lines         849      855       +6     
==========================================
+ Hits          811      815       +4     
- Misses         34       36       +2     
  Partials        4        4              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alitto alitto self-requested a review November 27, 2024 14:53
Copy link
Owner

@alitto alitto left a comment

Choose a reason for hiding this comment

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

Great catch @korotin, thank you! 🙌
Will ship it in a new patch version

@alitto alitto merged commit d455993 into alitto:main Nov 27, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants