Pleroma: instable à cause des connections PostgreSQL

My YunoHost server / Mon serveur Yunohost

Hardware: / Matériel Kimsufi KS7
YunoHost version: 4.2.8
I have access to my server / J’ai accès à mon serveur : Through SSH
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue / Description du problème

I have pleroma installed, using the pleroma_ynh package, on its own subdomain.
Since yesterday, Pleroma crashes, resulting in a 502 code when accessing the page.
It can be restarted but does not last long.
Checking the logs, here’s what I get

J’ai installé Pleroma avec le paquet pleroma_ynh.
Depuis hier, Pleroma plante, avec pour résultat un code 502 quand j’accède à la page.
Il peut être redémarré, mais ne tient pas longtemps.
En regardans les logs, voilà ce que j’ai:

I swapped my domain name with domain.ext in the logs. The initial domain name is correct in the logs (matching my server).
J’ai remplacé mon nom de domaine par domain.ext dans les logs. La version initiale est correcte (correspond à mon serveur).

Sep 14 02:42:59 domain.ext pleroma[19278]: ** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 1719ms. This means requests 
Sep 14 02:42:59 domain.ext pleroma[19278]:   1. Ensuring your database is available and that you can connect to it
Sep 14 02:42:59 domain.ext pleroma[19278]:   2. Tracking down slow queries and making sure they are running fast enough
Sep 14 02:42:59 domain.ext pleroma[19278]:   3. Increasing the pool_size (albeit it increases resource consumption)
Sep 14 02:42:59 domain.ext pleroma[19278]:   4. Allowing requests to wait longer by increasing :queue_target and :queue_interval
Sep 14 02:42:59 domain.ext pleroma[19278]: See DBConnection.start_link/2 for more information
Sep 14 02:42:59 domain.ext pleroma[19278]:     (db_connection 2.4.0) lib/db_connection.ex:784: DBConnection.run/3
Sep 14 02:42:59 domain.ext pleroma[19278]:     (stdlib 3.12.1) gen_server.erl:637: :gen_server.try_dispatch/4
Sep 14 02:42:59 domain.ext pleroma[19278]:     (stdlib 3.12.1) gen_server.erl:711: :gen_server.handle_msg/6
Sep 14 02:42:59 domain.ext pleroma[19278]:     (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Sep 14 02:42:59 domain.ext pleroma[19278]: Last message: :poll
Sep 14 02:42:59 domain.ext pleroma[19278]: State: %Oban.Queue.Producer.State{circuit: :enabled, conf: %Oban.Config{circuit_backoff: 30000, crontab: [{%Oban.Crontab.Cron{da
Sep 14 02:42:59 domain.ext pleroma[19278]: 02:42:59.557 [error] GenServer {Oban.Registry, {Oban, {:producer, "token_expiration"}}} terminating

This seems to be a PostgreSQL connection issue. So I checked the Postgres logs:
Ça semble être un problème de connexion à PostgreSQL, J’ai donc vérifié les logs de Postgres:

2021-09-14 02:42:51.225 EDT [21223] pleroma@pleroma LOG:  could not send data to client: Broken pipe
2021-09-14 02:42:51.225 EDT [21223] pleroma@pleroma FATAL:  connection to client lost
2021-09-14 02:42:53.219 EDT [21171] pleroma@pleroma ERROR:  canceling statement due to user request
2021-09-14 02:42:53.219 EDT [21171] pleroma@pleroma STATEMENT:  INSERT INTO "objects" ("data","inserted_at","updated_at") VALUES ($1,$2,$3) RETURNING "id"
2021-09-14 02:42:53.220 EDT [21171] pleroma@pleroma LOG:  could not send data to client: Broken pipe
2021-09-14 02:42:53.220 EDT [21171] pleroma@pleroma FATAL:  connection to client lost
2021-09-14 02:43:12.478 EDT [21226] pleroma@pleroma ERROR:  canceling statement due to user request
2021-09-14 02:43:12.478 EDT [21226] pleroma@pleroma STATEMENT:  INSERT INTO "objects" ("data","inserted_at","updated_at") VALUES ($1,$2,$3) RETURNING "id"
2021-09-14 02:43:12.478 EDT [21226] pleroma@pleroma LOG:  could not send data to client: Broken pipe
2021-09-14 02:43:12.478 EDT [21226] pleroma@pleroma FATAL:  connection to client lost

Note that this is not a very loaded instance. I’m the only user, but it’s connected to the federation, if that matters much.

Notez que cette instance est peu chargée. J’en suis le seul utilisateur mais elle est connectée à la fédération, si ça a une importance.

I didn’t know what else to check, but the Pleroma log suggests to investigate pgSQL settings.
I tried to use pgbench, but I’m really not familiar with the tool, and frankly I don’t know what I’m doing with itnor what to do with the results:

Je ne savais pas quoi vérifier d’autre, mais les logs de Pleroma proposent de regarder les réglages de pgSQL.
J’ai essayé d’utiliser pgbench, mais je ne connais pas l’outil, et franchement je ne sais pas trop ce que je fais, ni comment je dois comprendre les résultats.

pgbench  -c 10  -j 2  -t  10000  -U pleroma pleroma
Password:
starting vacuum...end.
transaction type: <builtin: TPC-B (sort of)>
scaling factor: 1
query mode: simple
number of clients: 10
number of threads: 2
number of transactions per client: 10000
number of transactions actually processed: 100000/100000
latency average = 98.194 ms
tps = 101.838812 (including connections establishing)
tps = 101.839197 (excluding connections establishing)

Any suggestion would be appreciated!

Toute suggestion sera bienvenue!

Thank you!
Merci!