Error class: DBConnection.ConnectionError

I have audit_log table where the current no. of row is 839782917+ and I am frequently getting error like (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2035ms. whenever this table is involved in the production.

pool_size: 15

Can you please help me solving this issue.

This message can happen if queries are coming in faster than the pool can answer them - for instance, if queries take 1s to complete but the system makes 20 per second.

Increasing the pool size may help with this, but it will also increase the load on the database. Don’t change it without understanding the consequences.

You should also investigate which queries are taking so long. If there’s one particular part of your system that makes long-running queries, consider isolating it with a separate connection pool and put_dynamic_repo.

It’s also worth checking on the slow queries: are there ways to make them faster? Missing indexes? Reordered SQL clauses? EXPLAIN ANALYZE will be useful here, so if you’re on the latest Ecto check out Ecto.Adapters.SQL.explain

1 Like

This means that you have queries to that table that are slow. You can try and find the offending queries as @al2o3cr suggested and then you either isolate them to another Repo with a separate pool and timeout values, or try introduce indexes in the table and measure again. (Or you can just use the timeout to 5 seconds or more.)

In any case, the problem is very specific to your project.