matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.83k stars 2.13k forks source link

slow cleanup in `device_lists_outbound_pokes` #16480

Open richvdh opened 1 year ago

richvdh commented 1 year ago

There is a cleanup job called prune_old_outbound_device_pokes (https://github.com/matrix-org/synapse/blob/v1.93.0/synapse/storage/databases/main/devices.py#L1297-L1388) which periodically attempts to clear out the device_lists_outbound_pokes table a bit.

The SELECT query can sometimes be very slow and IO-intensive. Sometimes it even takes longer than the 1 hour request timeout, meaning that it gets stuck without ever making any progress.

@erikjohnston suggests:

I do kinda want to change this, so we have two tables: the current table, and a duplicate which only holds the latest destination/user -> stream ID

reivilibre commented 1 year ago

matrix.org currently has this patched out as the issue came back.