Repository navigation
fix(ipc): serve IPC connections off the main loop with total deadlines (R-28, S-42) - #38
Merged
Merged
Conversation
…s (R-28, S-42)
The main loop read and answered each IPC connection synchronously. The
5 s timeout applied per read call, and writes had none, so a client that
sent a byte every few seconds, or never read its reply, held the
current_thread loop: REST, /live, SOX, the watchdog kick and the
sd_notify watchdog stopped, and with WatchdogSec=10 systemd restarted
the service. A throwaway test on the old path: a 200 ms per-read timeout
was held for 1055 ms by one byte per 150 ms.
- ipc.rs: an accept task (100 ms backoff on error) and one task per
connection; at most 4 at once, a fifth gets Error("busy"). Reading the
frame and writing the reply have a 5 s total deadline each; queueing
the command and getting the engine reply share one 10 s deadline. On a
failure the client gets EngineResponse::Error. A partial length prefix
is an error. Logs name the command (no field values) and are limited
to one line per kind per 10 s with a suppressed count.
- main.rs: only the command reaches the loop, through a bounded channel
(4) and a oneshot; a command whose client already gave up is skipped
and logged; Shutdown waits at most 1 s for its reply to be written.
- dispatch.rs: handle_connection becomes run (command in, reply out).
- sandstar-ipc: MAX_FRAME_SIZE is pub (same value).
- sandstar-cli: 20 s read/write timeout, above the server deadlines.
Behaviour: wire protocol unchanged. A command that cannot reach the
engine within 10 s is now not run and the client is told so (before, it
got no reply and the command ran later). Four slow local clients can keep
the CLI busy for 5 s at a time; the service and REST are unaffected.
Tests: gates.sh fmt, clippy, test (28 suites, 2921 passed, 0 failed),
hal OK; 16 IPC unit tests (total vs per-read deadline, unread reply, full
queue, abandoned command, written ack, oversized/garbage/partial frames,
connection limit and permit release). E2E on Windows TCP IPC: 6 slow
clients, REST /health 24/24 within 6 ms, slow ones closed at 5.0 s, CLI
"busy" while full then OK, poll and shutdown answered. The unix path is
not compiled on this machine; Linux CI covers it.
docs: HARDCODED_LIMITS.md IPC rows updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC
2 of 4 tasks
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
sandstar-cli) were read and answered synchronously inside thecurrent_threadmain loop; the 5 s timeout was per read call and writes had none. A slow client or one that never read its reply stopped REST,/live, SOX and the watchdog notification; withWatchdogSec=10systemd restarted the service (R-28).Error("busy")), total deadlines for read (5 s), queue + engine reply (10 s) and write (5 s),EngineResponse::Erroron failure paths, abandoned commands skipped and logged, rate-limited logs, Shutdown waits ≤ 1 s for its reply, CLI 20 s timeout.Behaviour change
Test plan
bash tools/gates.sh: fmt, clippy, test (2921 passed, 0 failed), hal/health24/24 within 6 ms; slow ones closed at 5.0 s; CLI busy while full, then OK;poll,shutdownansweredDocs:
docs/Progress/HARDCODED_LIMITS.mdIPC rows.🤖 Generated with Claude Code
https://claude.ai/code/session_01QKRNiek8qYRoRt7dcrDDVC