mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 17:47:28 +00:00
`MultiWriterIdGenerator` tracks in memory which IDs this instance has allocated and not finished, and each writer's position, and derives the current token from them. That state now lives in a Rust `StreamIdTracker`, so that Rust code can allocate and finish stream IDs without the GIL. The generator keeps what touches the database or the reactor: loading the start positions, the sequence, the `stream_positions` table and notifying replication. The logic is a line-by-line port. Two changes in form: the in-flight fetches are a counted map (they were a sorted multiset), and the position gauge reads the tracker when scraped instead of being set on each change. The issue 19795 debug line is logged after the lock is released, since logging can take the GIL. One behaviour change, a fix: on restart, the loader sorted the rows past `stream_positions` by their stored ID before negating them. On the backfill stream that visited our own rows furthest first, so our position ended at the nearest of them. The rows are now negated first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHKYPSc37kWqGACn9aKxKL