element-hq / element-hq/synapse
Event creation rate limiting happens very late in a worker environment
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#16481](https://github.com/matrix-org/synapse/issues/16481).
---
When event persistence happens in a separate worker process to event creation, we don't end up applying the ratelimit until the event reaches the event persister.
This means we end up doing *lots* of work (including calculating the push actions and inserting into `event_push_actions_staging`) for an event that gets thrown away.
There is code to attempt to apply the ratelimiter upfront (https://github.com/matrix-org/synapse/blob/v1.93.0/synapse/handlers/message.py#L1001-L1002), but it doesn't work in a worker environment because the count is never updated.
Contributor guide
Assessment
This issue has not been assessed yet.