matrix-org / matrix-org/matrix-rust-sdk
[meta] _Dirty_ cross-process locks
@Hywan is already working on this.
Since Apr 1, 2025.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
[During our work on the event cache store](https://github.com/matrix-org/matrix-rust-sdk/issues/3280), we have worked on [improving the event cache store to introduce `lock` and `lock_unchecked` with the notion of _dirtiness_ (previously: poison)](https://github.com/matrix-org/matrix-rust-sdk/pull/4285). This issue aims at extending this notion to all cross-process locks.
Imagine the following scenario:
- holder A takes the lock for the first time: lock is clean,
- holder A takes the lock for the second time: lock is still clean,
- holder B takes the lock for the first time, it's stolen from holder A: lock is still clean
- holder A takes the lock for the third time, it's stolen from holder B: lock is dirty.
When the lock is obtained, it is either _clean_ or _dirty_. When _dirty_ it indicates that the internal in-memory state should be invalidated and refreshed.
### Tasks
- [x] Introduce _dirtiness_ inside `CrossProcessLock`:
- [x] https://github.com/matrix-org/matrix-rust-sdk/pull/5672
- [x] https://github.com/matrix-org/matrix-rust-sdk/pull/5837
- [x] Update `MediaStore` to use the new _dirtiness_
- [x] https://github.com/matrix-org/matrix-rust-sdk/pull/5855
- [ ] Update OAuth to use the new _dirtiness_
- [x] Update `EventCacheStore` to use the new _dirtiness_
- [x] https://github.com/matrix-org/matrix-rust-sdk/pull/5856
- [x] Update `CryptoStore` to use the new _dirtiness_:
- [x] https://github.com/matrix-org/matrix-rust-sdk/issues/6269
- [x] Ensure it solves https://github.com/matrix-org/matrix-rust-sdk/issues/3313
- [x] Remove the previous “cache invalidation” mechanism in the `CryptoStore`
- [ ] Move the `lease_locks` tables from all stores to a separate database instead of being per store database. The idea is to have all locks in an isolated database to not disturb other databases (and let WAL files being shrunk as expected)
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.
Assessment
This issue has not been assessed yet.