mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
`Persister.prepare_chunk` runs the steps of the previous commits for a chunk: the extremities and state delta, then the sliding sync table changes and sticky events, then the chain cover index. The chain cover step comes last as the only one that writes, so a failure in an earlier step leaves nothing for Python to find. Sliding sync and sticky events now come before the stream orderings are allocated, as nothing there reads them. Each step reads the clock when it needs the time. `_persist_event_batch` dispatches on `rust_event_persistence`: - `shadow`: Rust runs first with its chain cover write rolled back, then Python. The results are compared and Python's are used. The comparison ignores orders Python leaves to chance and the IDs of new chains. Both rejecting the chunk with the same error is a match. - `prepare` and above: Rust's results are used. A `SynapseError` is raised as Python would raise it. Python computes the chunk when Rust cannot resolve state in the room, or on any other Rust error. Trial runs strict by default (`SYNAPSE_TEST_RUST_PERSIST_STRICT`), so a mismatch or Rust error fails the test. Rust's counts and state res stats are recorded by Python once it uses the result. At `prepare`, the `_calculate_state_and_extrem` and `calculate_chain_cover_index_for_events` timings give way to `rust_prepare_chunk`. Python's state resolution and state group caches are not filled, so creating a room costs one more transaction (`RoomsCreateTestCase` counts it) and the first local event after a fork resolves state again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LXMkcZVkcZhi21augBff4a