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

factoryCreate continues to be called even after draining pool #256

Open
dhensby opened this issue Feb 18, 2019 · 2 comments
Open

factoryCreate continues to be called even after draining pool #256

dhensby opened this issue Feb 18, 2019 · 2 comments
Assignees

Comments

@dhensby
Copy link

dhensby commented Feb 18, 2019

I've been investigating the issue reported in #175 (where a rejected factoryCreate can cause an infinite loop).

I've found that if you call pool.drain() whilst a resource is being acquired the pool will continue to make calls to the factoryCreate function. I believe this is caused by the fact that _dispense doesn't check if the pool has been drained since the initial acquire call was made.

The specific circumstance I'm dealing with is managing a pool of DB connections and if the DB server goes away and you attempt to close the pool, connection attempts still continue to be made.

@sandfox
Copy link
Collaborator

sandfox commented Feb 19, 2019

Pool.drain is designed to allow any previously made calls to pool.acquire to be given a resource, and for that happen _dispense still needs to be able to potentially create resources etc.

@dhensby
Copy link
Author

dhensby commented Feb 19, 2019

I think this issue is exacerbated by the immediate retry to create a resource on factoryCreateFailure because if there's a problem that means the pool needs to be closed whilst an acquire call is attempting to create a resource, there's no way to exit or abort the acquire calls that will never be able to fulfil.

If I understand correctly, it's intentional that you could never break out of the acquire/_dispense loop in the event that resource creation is no longer possible?

edit: This is highly problematic for managing a pool of DB connections because you'd want to be able to close the pool if the DB server goes away, but that's not possible if the pool is stuck in an acquire loop because connections can't be created

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

No branches or pull requests

2 participants