atagen

matrix-rust-sdk

public
Star0
Watch0

Commit 20345c614cc1

tarball

atagen <boss@atagen.co>2026-10-25 10:49 UTC

1 file changed+9-0
event-cache: restart an event-focused cache once per generation

Two clears in quick succession spawned two restarts, and the second ran start_from on a chunk the first had already refilled for the same generation, so subscribers saw every focused event twice. A restart now synchronises the generation first and stops when the chunk is already filled.
Modified file: crates/matrix-sdk/src/event_cache/caches/event_focused/mod.rs+9 additions
@@ -631,6 +631,15 @@ impl EventFocusedCache {
631631 let cache = self.clone();
632632 matrix_sdk_common::executor::spawn(async move {
633633 let mut inner = cache.inner.write().await;
634+ {
635+ let invalidation_lock = inner.invalidation_lock.clone();
636+ let _guard = invalidation_lock.lock().unwrap();
637+ inner.synchronize_generation();
638+ }
639+ // Another restart already refilled this generation after back-to-back clears.
640+ if inner.chunk.events().next().is_some() {
641+ return;
642+ }
634643 let Some((num_context_events, thread_mode)) = inner.context else {
635644 return;
636645 };