Commit Graph

486 Commits

Author SHA1 Message Date
Ivan Enderlin
7d31912f0d chore: Run rumdl check --fix. 2026-05-18 15:05:52 +02:00
Damir Jelić
e5a50089c2 chore: Migrate changelogs to towncrier fragments 2026-05-15 11:15:38 +02:00
Damir Jelić
2a8d75e43f chore: Add the changelog fragment directories 2026-05-14 15:56:14 +02:00
Damir Jelić
8fb918e062 chore: Update our changelogs so towncrier knows where to insert changelogs 2026-05-14 15:56:14 +02:00
Stefan Ceriu
2497f0ebd3 chore(stores): switch from pause/resume semantics to close and reopen ones 2026-05-12 17:25:48 +03:00
Stefan Ceriu
3f6887a69e chore(doc): update the documentation around pausing an resuming stores 2026-05-12 17:25:48 +03:00
Stefan Ceriu
e46cd9870d feat(client): expose a client pause/resume mechanism throughout the SDK
This patch exposes the pause/resume mechanism for SDK stores all the way up to
the FFI `Client`, so apps can temporarily release SQLite resources when moving
to the background and re-acquire them on resume.

The main use case is iOS backgrounding, where keeping SQLite file descriptors and
locks open can contribute to `0xdead10cc` terminations by the operating system.
2026-05-12 17:25:48 +03:00
Stefan Ceriu
8e8e0ebef9 chore(tests): add pause/resume mechanism tests for all the stores 2026-05-12 17:25:48 +03:00
Stefan Ceriu
40d57cb717 feat(stores): implement pause/resume support in the crypto, event cache, state and media SQLite stores
This patch implements the main pause/resume logic in the underlying SDK stores.
The in memory stores no-op trough the default trait implementations.

The main change are limited to the sqlite crate:
- a new type called `SqliteConnections` has been introduced which now holds a
store's read connection pools as well as the always on write connection. This
lives as an optional on each store's level and gets set to None whenever the
store is paused
- during the pausing phase `SqliteConnections` (through its `pause_connections`
method) does the following:
    - closes the read pool, directly dropping idle connections
    - waits for in flight writes to finish
    - tries a best effort WAL checkpoint
    - drops the write connection on a blocking thread
    - and waits for in-flight read connections to drain
    - this is all best effort with an eventual timeout
- resuming connections is also shared between the stores through
`SqliteConnections` and consists in building a new pool with the previous
configuration and creating a new write connection

# Conflicts:
#	crates/matrix-sdk-sqlite/src/crypto_store.rs
#	crates/matrix-sdk-sqlite/src/event_cache_store.rs
#	crates/matrix-sdk-sqlite/src/media_store.rs
#	crates/matrix-sdk-sqlite/src/state_store.rs
2026-05-12 17:25:48 +03:00
Stefan Ceriu
a0fbcd407b feat(stores): add pause and resume trait definitions and default implementations for all the stores 2026-05-12 17:25:48 +03:00
Damir Jelić
08222e300b Merge branch 'release-0.16' into main 2026-05-08 16:30:55 +02:00
Damir Jelić
ed148665d2 chore: Release matrix-sdk version 0.16.1 2026-05-08 15:57:42 +02:00
Damir Jelić
cf099deb27 chore: Release matrix-sdk version 0.17.0 2026-05-08 14:05:41 +02:00
Jorge Martín
51072bbe3a perf: Parallelize creating stores to make session restoration faster 2026-05-07 12:09:27 +02:00
Hubert Chathi
c1274cea14 Add support for pushing secrets and receiving secret pushes (#6164)
see MSC4385

Pushing secrets allow devices to send secrets to other devices without waiting for a secret request.
2026-04-07 12:26:17 +01:00
Michael Goldenberg
5b0c6bbafc doc: update change logs
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-03-31 17:34:11 +02:00
Michael Goldenberg
ee9a05defe refactor(sqlite): remove old crypto store generation key-value
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-03-31 17:34:11 +02:00
Jorge Martín
5d2eab119d feat: Improve getting homeserver capabilities
This extracts the `/capabilities` logic to its own `HomeserverCapabilities` component in the SDK that can be manually asked to fetch, cache locally and return these capabilities.
2026-03-31 15:25:37 +02:00
Benjamin Bouvier
816530c89c feat(event cache): make EventCacheError cloneable
This makes it possible to share futures which output is a result that
has the error type set to `EventCacheError`. See also
https://github.com/matrix-org/matrix-rust-sdk/pull/6304 for usage.
2026-03-17 15:47:39 +01:00
mgoldenberg
4ec9124ce1 Allow storing the same Event in multiple LinkedChunks of the same Room (#6200)
# Overview

There are scenarios in which it is sensible to have an event exist in
the same room more than once. Notably, this is true in the context of a
thread, where an event exists in the main timeline of a room, as well as
in a thread of that same room.

Support for this behavior has been implemented in the
`SQLiteEventCacheStore` in #6065; however, this was never implemented
for the `IndexeddbEventCacheStore` or the `MemoryStore`. This pull
request extends this behavior to both of those stores.

# Changes

## Integration Tests
First, `test_event_chunks_allows_same_event_in_room_and_thread` was
moved from `matrix_sdk_sqlite::event_cache_store` to
`matrix_sdk_base::event_cache::store::integration_tests`. Then, a few
additional integration tests were added to ensure that behavior is
consistent across implementations of `EventCacheStore`.

## `IndexeddbEventCacheStore`
In order to accommodate the behavioral changes specified by the
integration tests, it was necessary to modify the schema in the
IndexedDB implementation of `EventCacheStore`. Namely, the events object
store was cleared and removed and then replaced with a nearly identical
one, the only difference being the removal of a uniqueness constraint on
one of the indices.

The remaining changes mostly involved updating the behavior of top-level
`EventCacheStore` functions - e.g., filtering out events where they were
duplicated or removing positioning information where it was not
relevant.

## `MemoryStore`
The changes to `MemoryStore` mostly involved updating the behavior of
top-level `EventCacheStore` function - e.g., filtering out events where
they were duplicated or removing positioning information where it was
not relevant.

That being said, it also involved some breaking changes to
`RelationalLinkedChunk`.

1. `RelationalLinkedChunk::items` - this function returned an `Iterator`
that did not contain information about the `LinkedChunkId`, so this
information was added to the items in the `Iterator`.
2. `RelationalLinkedChunk::save_item` - this function did not update the
item in all linked chunks of the provided `Room`. It now does this, but
requires that the provided `Item` be `Clone`.

(1) could probably have been a new function, but I thought a nicer
interface was worth the breaking change. (2) could probably be prevented
by re-organizing `RelationalLinkedChunk`'s internal data structures to
remove the `Clone` requirement, but that seemed like it could turn into
a large refactoring project, so I opted for something simpler albeit
somewhat crude.

In both cases, I'm open to suggestions and would be happy to revisit if
something else is preferred.

---
Closes #6094.

- [x] I've documented the public API Changes in the appropriate
`CHANGELOG.md` files.
- [x] I've read [the `CONTRIBUTING.md`
file](https://github.com/matrix-org/matrix-rust-sdk/blob/main/CONTRIBUTING.md),
notably the sections about Pull requests, Commit message format, and AI
policy.
- [ ] This PR was made with the help of AI.

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>

---------

Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-03-10 14:55:02 +01:00
Benjamin Bouvier
8dbb6e5c1d refactor(event cache): rename Gap::prev_token to token
As it is now used for both a previous batch token (backwards pagination)
or a next batch token (forwards pagination).
2026-03-04 12:13:22 +01:00
Kévin Commaille
81286ad1e7 Upgrade Ruma after breaking change about EventId constructors
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-04 10:30:25 +00:00
Kévin Commaille
029148ef6e refactor(sqlite): Get rid of the DATABASE_VERSION constants
They are error prone because they need to be bumped for every migration
otherwise the new migration will not happen because we exit early.

So instead we get rid of the early returns and log each individual
upgrade separately. It makes more noise when creating a new database,
but since it is logged at the DEBUG level it is not much of a problem.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-03-03 15:26:42 +01:00
Richard van der Hoff
c23dd1ec0a update changelogs 2026-03-03 12:37:15 +00:00
Skye Elliot
fadfd98bee feat(crypto): Add get_all_rooms_pending_key_bundle to store trait
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-02-25 16:02:41 +00:00
Skye Elliot
640fa4854f feat(sqlite): Add query_many helper trait method
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-02-25 16:02:35 +00:00
Richard van der Hoff
8ac5d42fbe crypto: add rooms_pending_key_bundles interface to crypto store
Add a place to store details about rooms where we are waiting for a key bundle
2026-02-25 14:23:14 +00:00
Ivan Enderlin
a8e4630f56 chore(sqlite): Update deadpool to 0.13 and deadpool-sync to 0.2.
These releases include our patch to fix a panic (see
https://github.com/deadpool-rs/deadpool/pull/461).
2026-02-24 16:26:45 +01:00
Ivan Enderlin
c017ce0928 feat(sqlite): SqliteCryptoStore has 1 write connection.
Similarly to #5382 and #5744, this patch introduces a write-only
connection in `SqliteCryptoStore`. The idea is to get many read-only
connections, and a single write-only connection behind a lock, so that
there is a single writer at a time.

This patch renames the `acquire` method to `read`, and it introduces a
new `write` connection.
2026-02-23 14:31:13 +01:00
Kévin Commaille
fd5c1d847e Remove once_cell dependency
Use the types that were stabilized in the standard library instead.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2026-02-23 10:10:14 +00:00
Ivan Enderlin
2ff33cd354 Merge pull request #6061 from mgoldenberg/consolidate-event-cache-store-tests
Consolidate integration tests for `EventCacheStore`
2026-02-05 09:20:04 +01:00
Ivan Enderlin
3ff9b55077 chore: Add more default-features = false to more deps. 2026-02-05 09:02:29 +01:00
Michael Goldenberg
f2abc555e2 doc(event-cache): update relevant change logs
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-02-03 12:14:47 -05:00
Michael Goldenberg
d6293c75a9 test(event-cache): move test_linked_chunk_exists_before_referenced to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-02-03 11:47:05 -05:00
Michael Goldenberg
78d681f24f style(event-cache): fmt
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-31 15:42:56 -05:00
Michael Goldenberg
709d4cb80d Merge branch 'main' into test-merge-consolidate-event-cache-store-tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-31 15:07:52 -05:00
Michael Goldenberg
1b4e6aa0e7 feat(event-cache): ensure chunks exist before referenced in sqlite store
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-30 22:36:22 -05:00
Ivan Enderlin
b203b43bb2 doc(sqlite): Add #6091 in the CHANGELOG.md. 2026-01-30 15:08:39 +01:00
Ivan Enderlin
09a1bf8ec2 fix(sqlite): Replace unwrap when using interact.
This patch replaces the `interact(…).unwrap()` by a proper error.

So far, `interact()` was only returning `InteractError::Panic`
despites `InteractError::Aborted` exists. With
https://github.com/deadpool-rs/deadpool/pull/461, we now get
`InteractError::Aborted` when the SDK is shutdown, sometimes. This
results in hitting the `unwrap` and having a panic again. This patch
solves the problem by changing the `unwrap` to a proper error. Note: in
case of `InteractError::Panic`, we continue to panic.

This patch makes sense with or without the merge of the PR on
`deadpool`.
2026-01-30 15:08:39 +01:00
Benjamin Bouvier
e601c1d9b4 test: test that one can store the same event in multiple linked chunks 2026-01-27 16:02:20 +01:00
Benjamin Bouvier
2a968661e7 feat(sqlite): allow storing the same events in multiple linked chunks 2026-01-27 16:02:20 +01:00
Skye Elliot
3924463c6d fix: Correctly store rooms with downloaded keys in SQLite and IndexedDB. (#6044)
While https://github.com/matrix-org/matrix-rust-sdk/pull/6017 is mostly
functional, there are two issues:

- I did not process `changes.room_key_bundles_fully_downloaded` in
`matrix-sdk-sqlite`, meaning any updates made via `Changes` would not be
persisted;
- I used a non-encrypting `JsValue` serialisation for the same field in
`matrix-sdk-indexeddb`, which causes errors when passed to the
decryption-enabled deserializer.

Solutions:

- Process the aforementioned changes such that keys are added to SQLite;
- Use a non-encrypting deserialiser, since this is effectively a
hash-set, and the contents aren't sensitive.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2026-01-26 14:12:54 +00:00
Michael Goldenberg
3c42e1b4b9 test(event-cache): move test_load_previous_chunk to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 18:57:43 -05:00
Michael Goldenberg
12af5c4444 test(event-cache): move test_load_last_chunk_with_cycle to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 18:48:11 -05:00
Michael Goldenberg
3738091689 test(event-cache): move test_load_last_chunk to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 18:44:46 -05:00
Michael Goldenberg
750f59e4ea test(event-cache): move test_filter_duplicate_events_no_events to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 18:41:52 -05:00
Michael Goldenberg
e60b204cda test(event-cache): move test_linked_chunk_multiple_rooms to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 18:38:19 -05:00
Michael Goldenberg
0443615683 test(event-cache): copy test_linked_chunk_clear to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 17:54:18 -05:00
Michael Goldenberg
d93238d086 test(event-cache): move test_linked_chunk_start_end_reattach_items to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 17:51:44 -05:00
Michael Goldenberg
fe1ab18474 test(event-cache): move test_linked_chunk_detach_last_items to integration tests
Signed-off-by: Michael Goldenberg <m@mgoldenberg.net>
2026-01-25 17:49:17 -05:00