mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 15:37:49 +00:00
At `full`, `Persister.persist_chunk` takes the chunk's stream orderings from the events or backfill stream tracker, which Python's `_stream_id_gen` and `_backfill_id_gen` share. It runs `nextval` in autocommit after prepare, as late as `get_next_mult` does, and sets each event's stream ordering, received time and instance before the write transaction. Backfilled events take theirs negated. The orderings come back unfinished in `PersistEffects.stream_ids`. `_persist_events_and_state_updates` skips `get_next_mult` when Rust takes them. Its post-transaction block (metrics, MSC4293 `room_ban_redactions`, the extremities prefill) moves to `_after_persisting_events`, which both paths call. At `full` it runs after the effects are applied and before the orderings are finished, as it ran inside `get_next_mult`. So a ban that redacts a user's events is recorded before other workers see it. `finish_rust_persist_stream_ids` finishes the orderings as `get_next_mult` does on exit: it tells replication, and on success moves `stream_positions` on. If the transaction fails, Rust finishes them. If the apply or the follow-ups raise, Python finishes them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LXMkcZVkcZhi21augBff4a