jointakahe / takahe

An ActivityPub/Fediverse server
BSD 3-Clause "New" or "Revised" License
1.12k stars 86 forks source link

Connection to database issues after upgrading to 0.10 #653

Closed tobru closed 10 months ago

tobru commented 10 months ago

After upgrading to 0.10.0 I have issues with too many connections to the database:

connection failed: remaining connection slots are reserved for non-replication superuser connections

With 0.9 that wasn't an issue.

How can I help to debug that one?

tobru commented 10 months ago

Downgrading to 0.9 is hard, because of some backwards-incompatible schema changes. When starting 0.9:

django.db.utils.ProgrammingError: column users_domain.state_ready does not exist
LINE 1: SELECT "users_domain"."state_ready", "users_domain"."state_c...

For now, I leave stator stopped, looks like that the connections issues are coming from there.

tobru commented 10 months ago

OK, by tuning TAKAHE_STATOR_CONCURRENCY and TAKAHE_STATOR_CONCURRENCY_PER_MODEL I could get around it. The DB only allows 25 concurrent connections. That might have been enough in the past, but now it seems it needs more.

I'm closing this issue, it's not a bug.

andrewgodwin commented 10 months ago

Yeah, the new Stator is considerably more efficient at connecting to the DB in parallel than before, so it'll use more connections unless you turn it down (I dropped the defaults already, but probably not enough for everyone)