elixir-ecto / db_connection

Database connection behaviour
http://hexdocs.pm/db_connection/DBConnection.html
309 stars 112 forks source link

Fix race condition where we checkin a connection after timeout #191

Closed fishcakez closed 5 years ago

fishcakez commented 5 years ago

It was possible for a deadline timeout to arrive at the connection pool and for the deadline to be current in the holder but the client to checkin the connection holder before the pool deleted the holder for disconnect. This leads to an ETS-TRANSFER message with the deleted holder being handled by the pool and added to the queue. Therefore we check holders exist before checking in, and crash if we get in a inconsistent due to a future bug.