matrix-org / matrix-org/matrix-rust-sdk
`MemoryStore` allows duplicate `ChunkIdentifier`'s
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
MemoryStore currently relies on RelationalLinkedChunk::apply_updates to manage Update's to its internal data. This function, in turn, relies on RelationalLinkedChunk::insert_chunk when adding new chunks, which does not check whether the given ChunkIdentifier exists already.
To confirm this behavior, one can add the following integration test to EventCacheStoreIntegrationTests.
impl EventCacheStoreIntegrationTests for DynEventCacheStore {
async fn test_linked_chunk_identifiers_are_unique(&self) {
self.handle_linked_chunk_updates(
LinkedChunkId::Room(room_id!("!r0:matrix.org")),
vec![
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(0), next: None },
Update::NewItemsChunk { previous: None, new: ChunkIdentifier::new(0), next: None },
],
)
.await
.unwrap_err();
}
// -- snip --
}
My guess is that this behavior is not desirable. It also happens to be inconsistent with other implementations of EventCacheStore.
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
Start with RelationalLinkedChunk::apply_updates and insert_chunk in crates/matrix-sdk-common/src/linked_chunk/relational.rs, then review EventCacheStoreIntegrationTests and the other EventCacheStore implementations. Run the proposed uniqueness integration test; done means duplicate ChunkIdentifier updates are rejected consistently with those implementations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100