elixir-ecto / db_connection

Database connection behaviour

Home Page:http://hexdocs.pm/db_connection/DBConnection.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Keep alive pings don't seem to work when there are a lot of idle connections

cdegroot opened this issue · comments

It smells like these pings are run round-robin, not in parallel and only once per idle_interval, If you have a short wait_timeout and a bunch of idle connections, this means that connections can get lost (we use TLS, which makes losing connections quite expensive).

The expectation is that each connection keeps its own timer and keeps itself, as it were, independent of other connections.

Yes, I can confirm that's how it works currently. I think we can improve this by making the current detection recursive. Instead of only pinging a single connection, we will ping all connections unused in the idle interval. Here is the code to be made recursive:

https://github.com/elixir-ecto/db_connection/blob/master/lib/db_connection/connection_pool.ex#L122-L131

Here is where you can add a new test:

https://github.com/elixir-ecto/db_connection/blob/d78589549ca45ef5962bcf8a48fa32510121464a/integration_test/cases/idle_test.exs

I know the tests are very cryptic (IMO, the hardest part of maintaining this lib), so if help is necessary to write the test, please let me know.

Ping. Any news here?

From whom? Nothing from me in any case :)

I may have gotten the wrong impression but given you mentioned you were looking for ways to help, I was under the impression that you would send a pull request to address the current behaviour?

Ping?

Well, it was also summer when you joined the discussion. :) So if summer was not a blocker for "evaluating" the project back then, I was hoping it would not get in the way of supporting the project, especially when you recognized there are areas for contributions.

Closing this in favor #206.