Repository navigation
prowld: stop handling requests while a client's replies back up - #708
Merged
Merged
Conversation
prowld kept reading and answering a client's requests even while earlier replies were still unsent. A client that sent many requests without reading the replies made PID 1 queue up to IPC_OUT_MAX (8 MiB) for it, after which further replies were dropped and the client was left waiting for them. jemalloc keeps that memory: in a test guest, 200 pipelined "list" requests left PID 1 at 45 MB instead of 2.7 MB. Once more than IPC_OUT_HIWAT (1 MiB) is queued for a client, stop dispatching its requests until the queue drains below that again. The requests are still read into the receive buffer, so a client that is blocked writing a batch of requests can get to its replies; reading stops only when the receive buffer is full (IPC_MSG_MAX). Resuming after the queue drains shares ipc_resume_client() with the end of a service action. Tested in a bhyve guest with this prowld as PID 1, also with malloc.conf junk:true,abort:true: 200 pipelined "list" requests left unread for 8 seconds all got their replies, with PID 1 at about 4.8 MB. Half-closed and slow-reading clients, actions pipelined with "list", and the existing IPC load tests pass. AI-Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lucas Holt <luke@foolishgames.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prowld kept reading and answering a client's requests even while that client's earlier replies were still unsent. A client that pipelined requests without reading the replies made PID 1 queue up to
IPC_OUT_MAX(8 MiB) for it. After that, further replies were silently dropped, and the client waited for them until its own timeout. jemalloc keeps the memory afterwards: in a test guest, 200 pipelinedlistrequests left PID 1 at 45 MB for the rest of the boot.This change adds a high-water mark,
IPC_OUT_HIWAT(1 MiB):out_held), its requests are no longer dispatched. Dispatch resumes when the queue drains below the mark, inipc_write_ready().IPC_MSG_MAX) stops reading, using the sameNOTE_LOWAThold that service actions use. Stopping reads any earlier deadlocked test clients that write a batch of requests before reading: they were blocked inwrite()while prowld waited for them to read.ipc_resume_client().A client can still stall itself, but only by sending more than 64 KiB of requests while leaving more than 1 MiB of replies unread. prowlctl sends one request at a time, and the socket is root:wheel 0660.
Testing
In a bhyve guest with each binary as PID 1, running 190 jobs (the shipped units, the rc.d scripts and test units):
junk:true,abort:truelistrequests, unread for 8 s (×3)listlist/show/graph, check/resync actions, before and after the loadThe first two versions of this change hung in these tests:
The version here passed 17/17 checks on both branch runs.
The build is clean with
-Werror, andcheckstyle9.plis clean.Review notes
No allocations change. Per
AI_POLICY.md, the parts to audit are the state transitions:out_heldis set inipc_send(), cleared inipc_write_ready()and reset inipc_close_client().ipc_read_client(), which runs before the receive buffer grows, so a full buffer is never treated as an oversized frame.ipc_write_ready(), which now waits until held requests are handled and no action is running.AI-Assisted-by: Claude Opus 5.5
🤖 Generated with Claude Code