element-hq / element-hq/synapse
Admin API /_synapse/admin/v1/statistics/database/rooms fails with HTTP 500
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
### Description
HTTP request to that endpoint fails
### Steps to reproduce
- send `GET /_synapse/admin/v1/statistics/database/rooms` request
- receive `HTTP 500` response with body `{"errcode":"M_UNKNOWN","error":"Internal server error"}`
- check the log to see the details
### Homeserver
another homeserver
### Synapse Version
1.149.1
### Installation Method
Docker (matrixdotorg/synapse)
### Database
PostgreSQL; single; not ported from SQLite; not restored from backup
### Workers
Multiple workers
### Platform
Ubuntu 24.04
Setup method: MDAD
### Configuration
_No response_
### Relevant log output
```shell
2026-03-14 20:51:32,074 - synapse.http.server - 147 - ERROR - GET-9328 - Failed handle request via 'LargestRoomsStatistics':
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/synapse/http/server.py", line 335, in _async_render_wrapper
callback_return = await self._async_render(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/synapse/http/server.py", line 576, in _async_render
callback_return = await raw_callback_return
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/synapse/rest/admin/statistics.py", line 125, in on_GET
room_sizes = await self.stats_controller.get_room_db_size_estimate()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/synapse/storage/controllers/stats.py", line 101, in get_room_db_size_estimate
await self.stores.main.db_pool.runInteraction(
...<10 lines>...
)
File "/usr/local/lib/python3.13/site-packages/synapse/storage/database.py", line 1015, in runInteraction
return await delay_cancellation(_runInteraction())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py", line 1187, in __iter__
yield self
File "/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py", line 1853, in _inlineCallbacks
result = context.run(
cast(Failure, result).throwExceptionIntoGenerator, gen
)
File "/usr/local/lib/python3.13/site-packages/twisted/python/failure.py", line 467, in throwExceptionIntoGenerator
return g.throw(self.value.with_traceback(self.tb))
~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/synapse/storage/database.py", line 981, in _runInteraction
result: R = await self.runWithConnection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<11 lines>...
)
^
File "/usr/local/lib/python3.13/site-packages/synapse/storage/database.py", line 1117, in runWithConnection
return await make_deferred_yieldable(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self._db_pool.runWithConnection(inner_func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/twisted/internet/defer.py", line 1187, in __iter__
yield self
File "/usr/local/lib/python3.13/site-packages/twisted/python/threadpool.py", line 269, in inContext
result = inContext.theWork() # type: ignore[attr-defined]
File "/usr/local/lib/python3.13/site-packages/twisted/python/threadpool.py", line 285, in
inContext.theWork = lambda: context.call( # type: ignore[attr-defined]
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ctx, func, *args, **kw
^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/twisted/python/context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/twisted/python/context.py", line 82, in callWithContext
return func(*args, **kw)
File "/usr/local/lib/python3.13/site-packages/twisted/enterprise/adbapi.py", line 282, in _runWithConnection
result = func(conn, *args, **kw)
File "/usr/local/lib/python3.13/site-packages/synapse/storage/database.py", line 1110, in inner_func
return func(db_conn, *args, **kwargs)
File "/usr/local/lib/python3.13/site-packages/synapse/storage/database.py", line 819, in new_transaction
r = func(cursor, *args, **kwargs)
File "/usr/local/lib/python3.13/site-packages/synapse/storage/controllers/stats.py", line 98, in get_room_db_size_estimate_txn
for room_id, freq in zip(vals, freqs):
~~~^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable
```
### Anything else that would be useful to know?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.