element-hq / element-hq/synapse

Event creation rate limiting happens very late in a worker environment

Open
#16,481 0 comments 0 reactions 0 assignees View on GitHub
A-Workers O-Occasional S-Minor T-Defect
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.