element-hq / element-hq/synapse

Race condition with room creation means room directory lacks read-after-write consistency in monolith mode

Open
#15,526 0 comments 0 reactions 0 assignees View on GitHub
A-Create-Room A-Room-Directory S-Minor T-Defect X-Regression Z-Read-After-Write
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#15526](https://github.com/matrix-org/synapse/issues/15526).

---

It's possible to query the room directory after the room creation and not see the room.

### Reproduction steps

1. Using monolith Synapse
1. Create a public room called `foo` with `/createRoom`
1. Immediately after seeing a successful create room response, search the room directory for the room (`/publicRooms` with `{ filter: { generic_search_term: 'foo' } }`)
- It's important to use search because it [bypasses the cache](https://github.com/matrix-org/synapse/blob/0e8aa2a1b28dfce374294450a015d18884c89d36/synapse/handlers/room_list.py#L98-L109)
1. Notice that the room is missing from the response ❌

If you give the homeserver some time, the room will show up.

### Notes

This regressed in https://github.com/matrix-org/synapse/pull/15229 where I guess the timing changed just enough for this to be possible. You can see the full bisect, investigation and context for how I noticed in https://github.com/matrix-org/matrix-public-archive/pull/208#discussion_r1183294630

It seems like we're `await`'ing everywhere so not sure why this would happen. And seems weird that it would happen in monolith mode since there is not replication lag and we're awaiting everything.

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.