mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
With the main database on the native Postgres driver, every event load goes through the Rust `EventLoader`. `EventsWorkerStore` sends the events its own lookups miss to `RustStore.load_events`, and `_get_events_from_db` to `reload_events`. Loads from Python, sync and state resolution then coalesce in the shared event cache, and an invalidation during a load stops it caching a stale entry. Python's fetch threads and in-flight map stay only for other databases. - `EventLoader::load` goes through `Cache::get_or_load_many`. The extra redaction events it reads are returned but no longer cached. - `PoolQuerier` checks its connection out before claiming any loads, so readers that hold connections while they wait cannot starve a load. - An unusable event raises `InvalidEventError` or `DatabaseCorruptionError`, as from Python, which some callers catch. - Cancelling a Python caller leaves the load running for the others, and `evt_db_fetch_count` counts only what a caller read itself. - `RustStore` holds the `DatabasePool` weakly and reads its pool per call. Tests: trial makes the loads block, as it does Python's transactions (`_BlockingRustCalls`, renamed from `_BlockingRustSyncHandler`). The cancellation and outage tests get Rust variants. Two tests stop depending on how far requests advance the clock or on which `DatabasePool` object a worker store keeps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VpBQxvqZTUvHCMm3u6CR7J