Ecto: Connection Error

Hi all,

We have been recently getting following errors in our production app.

[application=db_connection module=DBConnection.Connection function=disconnect/2 line=166 ] Postgrex.Protocol (#PID<0.488.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.8901.100> exited: killed

What could be the reasons for these kind of errors. Is there any way to find cause or more information ? How to debug these kind of issues?


Looking in deps/db_connection/lib/db_connection/connection.ex you can find that this comes from one of the handle_info({:DOWN …}, …) functions, which means that, indeed, the client process running in the pool is going down. That is also hinted at by the “exited: killed”.

First stop would be to look in the app’s directory on disk and look for erl_crash.dump files, or crash entries in the log files directly. This should hopefully point you in the direction of the code that is running into trouble.

Perhaps it is hitting some limit (memory, file handles, etc…), but the crash logs should help shed light on whatever it is.

Thanks @aseigo
We drilled down more into the problem and we found out that few queries were taking lot of time and blocking the connections. This was causing timeout on other queries as well. Today our server crashed because of many queries were piling up and all were timing out and all of those processes killed eventually causing a crash :frowning:

Unfortunately it wasn’t showing the timeout error. Now, we cleaned some un-needed data and added indexes. The queries are working fine and we dont see the db connection issues any more.

It would have been more helpful if the appropriate error was shown.

There was no crash as such. Can we find crash logs for each process when it exits? If yes, that will be great.

Enable the Erlang-built-in “SASL” logger, but only do it as you need it as you will get utterly overwhelmed with output as it logs every OTP up/down/crash/etc… states.