dashbitco / nimble_pool

A tiny resource-pool implementation for Elixir
347 stars 20 forks source link

do not override previous resources on check idle verification #26

Closed oliveigah closed 2 years ago

oliveigah commented 2 years ago

The last non idle worker on resource list was being removed incorrectly from the list because of a variable name override.

It ultimately leads to an empty list of workers, that could lead to unexpected behaviours.

The added test simulate a scenario where the only worker would be removed from the resources when the verification cycle executed but the worker is not idle yet.

This led to an empty resources queue and finally the non termination of the pool because the pool has no workers to verify idle.

oliveigah commented 2 years ago

Found this bug when implementing this feature on finch! This bug is very dangerous because the resources queue might be emptied without call terminate_worker/3 callback! I think a new release might be appropriate due to the severity of the bug.

josevalim commented 2 years ago

:green_heart: :blue_heart: :purple_heart: :yellow_heart: :heart: