Skip to content

fix(relay): a dropped interactive write no longer holds bulk writes back - #62

Merged
TheAnimatrix merged 2 commits into
mainfrom
relay-egress-cancel
Dec 1, 2026
Merged

TheAnimatrix merged 2 commits into
mainfrom
relay-egress-cancel

Conversation

@TheAnimatrix

Copy link
Copy Markdown
Collaborator

A relay connection's bulk circuits no longer stall for good after an interactive write is cut off mid-wait.

What changed

  • crates/mousse-relay/src/egress.rs: an interactive write counts as waiting until it takes the bucket or its future is dropped. Before, the relay writer's close linger could drop a waiting interactive write; the count was never lowered, so every later bulk write on that relay waited behind an interactive write that no longer existed. Now the count is lowered on drop and the held bulk writes are woken. A waiting interactive write that is not dropped still goes before bulk.

Measurement

A scheduler harness that compiles egress.rs alone (current-thread runtime, paused clock): empty the bucket, start an interactive write, drop it after 10 ms, then time one bulk write, 20 trials.

Bulk writes done within 2,000 ms Median wait
main b757d23 0 of 20 none
this branch 20 of 20 991 ms (the bucket refilling)

Verification

  • egress::tests::a_dropped_interactive_wait_lets_bulk_go_on (new): with no other interactive write waiting, the bulk write finishes once the bucket refills; with one other interactive write still waiting, that one goes first and the bulk write follows. It fails on main's egress.rs (bulk still held after 2 s).
  • egress::tests::the_ceiling_holds_and_interactive_goes_first (unchanged) still passes: the ceiling and interactive-first order hold.
  • Not tested end to end: the close-linger path in server.rs that drops the write. The fix is in the scheduler, so it covers any caller that drops a waiting write.
  • Windows (Rust 1.96.0): cargo fmt --all --check, cargo test --workspace (1,304 passed, 0 failed), cargo check -p mousse-net-core --target wasm32-unknown-unknown and cargo clippy -p mousse-relay --all-targets --all-features -- -D warnings pass.
  • cargo clippy --workspace fails on lints in files this PR does not touch, and main's CI fails the same way: mousse-helper/src/app/paths.rs:1321 (nonminimal_bool, also on Linux CI), plus, on Windows only, mousse-net-io/src/keystore.rs:1624 and mousse-helper/src/app/out.rs:53 (thread_local initializer).

…s bulk writes back

The relay writer's close linger can drop a waiting interactive write.
Its place in the waiting count was never given back, so every later
bulk write on that relay waited for good. The count now leaves on drop
and wakes the held bulk writes; a waiting interactive write still goes
first.
@TheAnimatrix
TheAnimatrix merged commit a15048a into main Dec 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant