matrix-org / matrix-org/matrix-rust-sdk

Joining and leaving room might be racy with data loss

Open
#1,041 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.