element-hq / element-hq/synapse
Synapse should close idle database connections
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#5728](https://github.com/matrix-org/synapse/issues/5728).
---
It seems the database connection pooling doesn't shut down idle database connections:
```
SELECT application_name, datname, usename, state, age(now(), query_start), wait_event_type, wait_event, query FROM pg_stat_activity WHERE now() - interval '10s' > query_start ORDER BY age;
application_name | datname | usename | state | age | wait_event_type | wait_event | query
------------------+---------+----------------+-------+-----------------+-----------------+------------+--------
synapse-media | matrix | matrix-synapse | idle | 00:00:14.840869 | Client | ClientRead | COMMIT
synapse-event | matrix | matrix-synapse | idle | 00:08:34.818956 | Client | ClientRead | COMMIT
synapse-event | matrix | matrix-synapse | idle | 00:08:34.836956 | Client | ClientRead | COMMIT
synapse-cl-rdr | matrix | matrix-synapse | idle | 00:08:34.837199 | Client | ClientRead | COMMIT
synapse-cl-rdr | matrix | matrix-synapse | idle | 00:08:40.64963 | Client | ClientRead | COMMIT
(5 rows)
```
Because every Postgres process uses 150MB RSS at me, it would the helpful if Synapse could close the database connections when not needed.
Contributor guide
Assessment
This issue has not been assessed yet.