Ecto pool checkout timeout when all clients are idle

Hello everyone, we’re having a lot of errors this one:

** (stop) exited in:, {:checkout, #Reference<0.3901815582.1345585154.173724>, true}, 5000)
    ** (EXIT) time out
    (stdlib) gen_server.erl:223:
    (poolboy) /app/deps/poolboy/src/poolboy.erl:63: :poolboy.checkout/3
    (db_connection) lib/db_connection/poolboy.ex:41: DBConnection.Poolboy.checkout/2
    (db_connection) lib/db_connection.ex:928: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:750:
    (db_connection) lib/db_connection.ex:644: DBConnection.execute/4
    (ecto) lib/ecto/adapters/postgres/connection.ex:98: Ecto.Adapters.Postgres.Connection.execute/4
    (ecto) lib/ecto/adapters/sql.ex:256: Ecto.Adapters.SQL.sql_call/6
Function: #Function<7.52749505/0 in>
    Args: []

the last function can be that one, a Repo.preload or almost anything else.

I’ve tried to increase the pool size from 10 to 20 but it quickly starts throwing these errors again.

The problem is that looking at pgAdmin all the clients from the ecto connections are Idle with wait Client: ClientRead, is it possible to see at runtime what each connection is doing? So at least I can check if there is anything that’s blocking and keeping the connection checked out?

Not sure if related but it reminds me of something I’ve had trouble with some weeks ago.

Try and ensure you use at least Erlang 21.0.2 and see if the errors are still there.

I’ve actually had that issue in the past, but no right now I’m running on 21.2.5, I’ve enabled the remote shell so I can later check directly with the processes what’s going on

@alex88 - if you’re using the latest ecto/db_connection, please make sure your config is not referencing the DBConnection.Poolboy as it is not available anymore. It was replaced by the DBConnection.ConnectionPool.

Basically you can simply remove the :pool option, from your config, as it will fallback on DBConnection.ConnectionPool, by default. You can still configure your pool size via :pool_size, of course.