matrix-org / matrix-org/matrix-rust-sdk
Joining and leaving room might be racy with data loss
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
With #1022 we introduced rooms in less than fully synced state, that we are returning immediately from the leave and join for developer convenience. However, they are checking and conditionally change the database representation of the rooms in a potentially racy manner: if in between we ask for the room and process its new state, a sync-response about the room is received and processed, we might overwrite those processed data with our rather old state.
For a proper fix, this needs a way to ensure that get_or_create_with is locking on that room and any other writes don't happen concurrently ...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace the room handling around get_or_create_with, join, leave, and sync-response processing. Start by finding where the room database representation is read and conditionally changed; inspect existing concurrency tests if present. Done means concurrent room updates cannot overwrite newer processed state with stale join or leave data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100