DB connection errors

I built an akkoma server on debian 12 a couple of weeks ago, and I haven’t put it into production yet, as I’m still working out my bug. The recent reoccurring one shows as an “Internal Server Error” on Pleroma-fe the logs indicate a db connections issue:

 pleroma: [error] Postgrex.Protocol (#PID<0.1370.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.26623.0> timed out because it queued and checked out the connection for longer than 15000ms#012#012#PID<0.26623.0> was at location:#012#012    :prim_inet.recv0/3#012    (postgrex 0.17.2) lib/postgrex/protocol.ex:3237: Postgrex.Protocol.rows_recv/5#012    (postgrex 0.17.2) lib/postgrex/protocol.ex:2232: Postgrex.Protocol.recv_execute/5#012    (postgrex 0.17.2) lib/postgrex/protocol.ex:2069: Postgrex.Protocol.bind_execute_close/4#012    (db_connection 2.5.0) lib/db_connection/holder.ex:354: DBConnection.Holder.holder_apply/4#012    (db_connection 2.5.0) lib/db_connection.ex:1432: DBConnection.run_execute/5#012    (db_connection 2.5.0) lib/db_connection.ex:1527: DBConnection.run/6#012    (db_connection 2.5.0) lib/db_connection.ex:656: DBConnection.parsed_prepare_execute/5
2023-12-05T10:49:28.805228-06:00 badger pleroma: request_id=F539flsvMBDPeUMAAhHR [error] Internal server error: %DBConnection.ConnectionError{message: "tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)", severity: :error, reason: :error}
2023-12-05T10:49:28.822404-06:00 badger pleroma: [error] #PID<0.26623.0> running Pleroma.Web.Endpoint (connection #PID<0.26557.0>, stream id 8) terminated#012Server: sleepycatz.com:80 (http)#012Request: GET /api/v1/timelines/home?max_id=AcKuS0S5TNbalFkDuS&with_muted=false&limit=20#012** (exit) an exception was raised:#012    ** (DBConnection.ConnectionError) tcp recv: closed (the connection was closed by the pool, possibly due to a timeout or because the pool has been terminated)#012        (ecto_sql 3.10.1) lib/ecto/adapters/sql.ex:913: Ecto.Adapters.SQL.raise_sql_call_error/1#012        (ecto_sql 3.10.1) lib/ecto/adapters/sql.ex:828: Ecto.Adapters.SQL.execute/6#012        (ecto 3.10.3) lib/ecto/repo/queryable.ex:229: Ecto.Repo.Queryable.execute/4#012        (ecto 3.10.3) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3#012        (pleroma 3.10.4-1-gebfb617b) lib/pleroma/pagination.ex:40: Pleroma.Pagination.fetch_paginated/4#012        (pleroma 3.10.4-1-gebfb617b) lib/pleroma/web/activity_pub/activity_pub.ex:536: Pleroma.Web.ActivityPub.ActivityPub.fetch_activities/3#012        (pleroma 3.10.4-1-gebfb617b) lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex:71: Pleroma.Web.MastodonAPI.TimelineController.home/2#012        (pleroma 3.10.4-1-gebfb617b) lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex:5: Pleroma.Web.MastodonAPI.TimelineController.action/2

This error seems to come and go and is not always repeatable. My pool_size is set to 50 in admin-fe and pool_timeout is set to 5 sec. However, I am not sure what the optimal settings are, or if this is directly related to the issue. Any thoughts would be appreciated. Thanks.

Oh, I should note that my HTTP Receive Timeout was set to the Default of 15000ms when this error occurred. I’ve increased it to 25000ms to see if that helps, but as I said, the error only shows up indeterminately - usually after periods of inactivity.

1 Like

you should not touch pool_size unncessarily, it increases the number of connections to postgres which if you’re on a slower server, can clog up your I/O with inbound posts before it can respond to you

1 Like