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

Fix reaper exhausting the queue #188

Closed
wants to merge 1 commit into from

Conversation

albus522
Copy link
Contributor

@albus522 albus522 commented Aug 7, 2024

After max queue size connections have been reaped, no new connections are allowed to be created.

I'm am not sure how intended the 0 pool size behavior is. The tests make a lot of use of it but it seems counter to normal use.

After max queue size connections have been reaped, no new connections are allowed to be created.
@@ -178,6 +178,8 @@ def reap_idle_connections(idle_seconds, reap_start_time, &reap_block)
while idle_connections?(idle_seconds, reap_start_time)
conn, _last_checked_out = @que.shift
reap_block.call(conn)
# Decrement created unless this is a no create stack
@created -= 1 unless @max == 0
Copy link
Owner

Choose a reason for hiding this comment

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

Does this need a mutex or synchronization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method operates within a mutex block, so it's clear here.

However, looking over how this is currently setup, there could be resource contention issues with the reaper trying to close connections when something else decides it wants a connection from the pool. I think I'll take a quick stab at trying to improve that in another PR. This one is nice and simple and fixes an actual bug.

@albus522
Copy link
Contributor Author

albus522 commented Aug 8, 2024

Merged as part of #189

@albus522 albus522 closed this Aug 8, 2024
@albus522 albus522 deleted the fix-reaper-queue-exhaustion branch August 8, 2024 23:29
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