You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(id-sync): do not hold replica lock while waiting on peer transfer #12636
In pkgs/id/crates/id-sync/src/federation/exchange_net.rs, ExchangeProtocol::session acquires self.replica.lock() at line 700, writes the hello reply at 711, then waits for the remote transfer frame at lines 713–717. The same mutex guard remains live while receiving and processing the transfer and sending the reply (through line 744). The only bound on this wait is the 30-second TIMEOUT around the session in accept (lines 751–754).
A remote peer can complete a valid hello exchange and then stop sending. During that interval, the replica-wide mutex is held, so other sessions for the same ExchangeProtocol cannot read/update the replica and may themselves time out waiting for the lock. This turns one stalled stream into up to 30 seconds of avoidable federation unavailability.
Why it matters
The timeout prevents indefinite lock retention, but serializing unrelated sessions behind a peer-controlled network wait makes a single slow or malicious peer able to delay legitimate synchronization.
Acceptance criteria
Do not hold the replica mutex across a peer-controlled read/write wait.
Preserve the exchange invariant that both offers are computed from pre-transfer inventories and that received versions are admitted in the defined order.
Add a regression test with one session stalled after hello and another healthy session, demonstrating that the healthy session can make progress (or is rejected promptly by a documented bounded-concurrency policy rather than waiting on the replica lock).
Keep the per-session timeout and ensure timed-out streams release resources.
The requested lock-release fix is in merged PR #12641 (merge commit b52a270). Its two regressions cover progress of a second healthy exchange while one peer stalls and exclude versions admitted after the hello-time snapshot from that session offer. PR body reports the focused tests plus substrate_transport_path, substrate_sync_path, and federation_b09 passing. Closing as implemented.
Activity
developing-today commentedon Nov 22, 2026
CODE-4649
id-sync: offer only hello-time versions from a resumed exchange
dezren39 commentedon Nov 23, 2026
The requested lock-release fix is in merged PR #12641 (merge commit b52a270). Its two regressions cover progress of a second healthy exchange while one peer stalls and exclude versions admitted after the hello-time snapshot from that session offer. PR body reports the focused tests plus substrate_transport_path, substrate_sync_path, and federation_b09 passing. Closing as implemented.
dezren39 commentedon Nov 23, 2026
Closed as implemented.