mux-server can stay alive but stop answering `wezterm cli` / SSH proxy attach under load
Summary
I hit a mux-server failure mode on WezTerm release 20240203-110809-5046fc22 (5046fc225992db6ba2ef8812743fadfdfe4b184a, published 2024-02-03) where the process stayed alive, memory stayed healthy, but the control plane effectively stopped answering:
- local
wezterm cli list --format jsontimed out on the host itself - local
wezterm cli list-clientstimed out on the host itself - new SSH-domain attaches hung at
Checking server version - restarting the mux owner process immediately restored normal behavior
This was not an OOM and did not look like an SSH/auth problem. SSH auth was still succeeding. The mux process was still present. The host had plenty of free memory.
Why this looks like mux-server starvation / backlog rather than a dead process
During the incident, the mux server log showed a long stream of:
reading Pdu from client: decoding a PDU: reading PDU length: Connection reset by peer
and later a burst of:
writing pdu data buffer: Broken pipe
That pattern is consistent with clients timing out and disconnecting first, and the server only later trying to flush responses/notifications into sockets that were already gone.
Code path in the exact release that seems relevant
I checked the exact source for tag 20240203-110809-5046fc22, not current main, and the relevant structure in that release looks like this:
wezterm-mux-server-impl/src/dispatch.rs- each connection subscribes to mux notifications immediately
- per-connection work is funneled through
smol::channel::unbounded::<Item>() - every
MuxNotification::PaneOutputtriggershandler.schedule_pane_push(...)
wezterm-mux-server-impl/src/sessionhandler.rsschedule_pane_push()dispatches a detachedspawn_into_main_thread(...)ListPanesandGetLinesalso go throughspawn_into_main_thread(...)
promise/src/spawn.rsSimpleExecutoris a single unbounded queue feeding main-thread jobs
So in the 2024-02-03 release itself, control-plane requests and render/update pushes are sharing the same single-thread scheduler, and the notification side is unbounded.
Grounded hypothesis
Under sustained PaneOutput activity, render/update jobs can backlog enough to starve early control-plane requests such as:
GetCodecVersionSetClientIdListPanes
That would explain why a brand-new SSH proxy attach can hang at Checking server version even though the mux process is still alive.
Why I think this is distinct from other known issues
I am not talking about:
- client disconnect noise from normal shutdown
- a host OOM event
- a shell startup / stdout corruption issue
This was a live mux process that remained present but stopped servicing wezterm cli requests in a timely way.
I also noticed a later upstream commit, 100b85d (Remove mux-server race condition.), but I am not claiming that fixes this specific hang. I mention it only because it touches nearby mux-server render/update logic.
Rough reproduction shape
I do not have a tiny standalone reproducer yet, but the behavior occurred in this shape:
- Linux host running a live mux with several panes producing steady output.
- Additional automation repeatedly querying pane state via
wezterm cli. - New SSH-domain attach attempted from another client.
- New attach hangs at
Checking server version. - Local
wezterm cli liston the host also times out. - Mux process remains alive until manually restarted.
Requests / possible directions
- Confirm whether eager subscription to all mux notifications before handshake is intentional for short-lived control-plane clients.
- Consider bounding or coalescing per-connection notification queues.
- Consider prioritizing request/response PDUs over
PaneOutput-driven render pushes. - Consider delaying subscription until after successful client registration / initial attach handshake.
Acceptance criteria
A live wezterm-mux-server under output-heavy load should not be able to enter a state where:
- the process remains alive
- local
wezterm cli listtimes out repeatedly - new SSH-domain attaches hang at
Checking server version - recovery requires restarting the mux owner process
Source: wezterm/wezterm