element-hq / element-hq/synapse
Oldschool /sync `lazy_loaded_members_cache` makes lazy-loading sync non-idempotent
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
I believe I have spotted a bug with the `lazy_loaded_members_cache` cache, which essentially tracks 'what users have we recently sent down to the client' in order to reduce the size of the response body.
The cache is mutated, to mark lazy-loaded member(s) as having been sent down to the client, during the course of building the response, before the response is 'acknowledged' by a subsequent `/sync`.
On many homeservers, there is a 2-minute response cache which would replay the correct response without computation.
But when this response cache is disabled, or after 2 minutes, a repeated `/sync` request would receive a response with the relevant lazy-loaded members omitted even though they should be included.
End result would appear to be a desync in the memberships sent down to the client, though after a period of inactivity (to let the cache expire) and seeing the member again, it would be resent.
Contributor guide
Research direction
Start by tracing the /sync handling and the lazy_loaded_members_cache mutation described in the issue, then compare repeated requests with the homeserver's response cache disabled or expired. Done means repeated /sync requests still include the relevant lazy-loaded members when they should, without causing membership desynchronization.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100