mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-14 18:18:02 +00:00
Fixes #19561 `GET /_synapse/admin/v1/statistics/database/rooms` returns a 500 when `pg_stats` has no common `room_id` values for one of the tables it checks. This happens in two cases: - The table is empty or not yet analyzed, so `pg_stats` has no row for it. - No value is more common than the others, so `most_common_vals` is `NULL`. `event_edges.room_id` hits this on servers where all rows were written after schema 72 stopped filling the column. The change skips the table in both cases, since it adds nothing to the estimate. Thanks to @christianarielli for finding the cause and suggesting the fix. They're credited as co-author on the commit. The new test runs only on Postgres, as the endpoint doesn't support SQLite. It creates a room, runs `ANALYZE` while `event_push_actions` is empty and `event_edges.room_id` is all `NULL`, and checks for a 200 with the room listed. I ran it against Postgres 17. `event_edges.room_id` isn't written any more, so dropping that table from the list might make sense. I left that out to keep this PR small. ### Pull Request Checklist <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> * [x] Pull request is based on the develop branch * [x] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Use markdown where necessary, mostly for `code blocks`. - End with either a period (.) or an exclamation mark (!). - Start with a capital letter. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. * [x] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters)) --------- Co-authored-by: Christian Arielli <903609+christianarielli@users.noreply.github.com> Co-authored-by: Eric Eastwood <erice@element.io>