Repository navigation
Conversation
…timeout Co-Authored-By: jason.han <hanhuijun@gmail.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
…helper still holds Co-Authored-By: jason.han <hanhuijun@gmail.com>
There was a problem hiding this comment.
Devin Review found 1 finding. Devin automatically fixed it.
Fixed by Devin (1)
- Lost exit status after refused writes — After the grace, unwritable now reports the collected exit status when the process has already been waited; covered by TestSessionRefusedWriteReportsTheCollectedExit.
QA: pass, with one failure in the same area that is also on
|
| Check | Verdict | Base → head | Observed |
|---|---|---|---|
Refused write, engine closed its stdin, OPENSYSML_TOOL_TIMEOUT=20s, CLI |
Pass | 20.1 → 1.7 | Both: standin refused (engine "standin" at … exited during a request (write |1: broken pipe)) |
Same, REPL (%engine all, %action) |
Pass | 20.1 → 2.0 | Same message |
Same, gRPC CheckBehavior with -serve-external-engines standin |
Pass | 20.1 → 1.7 | Same result returned to the client |
Same with OPENSYSML_TOOL_TIMEOUT=500ms |
Pass | 1.8 → 1.8 | Same message |
| Normal analysis (CLI, REPL, gRPC) | Pass | 1.8 → 1.8 | Output identical: standin violated (witnessed) |
| Slow engine answering after 6s, timeout 20s | Pass | 6.1 → 6.2 | Full answer kept, not cut at the 1s grace |
Engine crashes during run |
Pass | 1.8 → 1.8 | exit 11: segmentation fault (stand-in) |
Engine exits at start / after describe / after answering |
Pass | same | did not start (exit 2: …), exited during a request (exit 0), answer kept |
describe never answered, timeout 4s |
Pass | 4.1 → 4.1 | did not answer describe within 4s (OPENSYSML_TOOL_TIMEOUT) |
run past -check-timeout 3s; cancel ignored with 4s grace |
Pass | 3.1 → 3.1; 7.1 → 7.1 | cancelled at deadline; ended after the grace |
| Engine exits with status 7 while a helper holds its output | Pass, no visible change | 5.1 → 5.1 | Both exited during a request (exit 7) once the helper let go; see note 2 |
| Engine stops reading but leaves the pipe open, timeout 5s | Fail on both | 30 (cap) → 30 (cap) | No error; the command never returns |
Every scenario's output is the same on base and head apart from the time taken.
The failure (not introduced here)
An engine that answers describe and then never reads another request, without closing its stdin, hangs the analysis for good on both builds: covers is written into the pipe, nothing refuses it, and nothing bounds the wait. docs/reference/external-engines.md says describe and covers must answer within OPENSYSML_TOOL_TIMEOUT, and only describe does (session.describe wraps its context in the timeout; session.call for covers waits on the caller's context, which has no deadline without -check-timeout).
To reproduce: a manifest entry whose command is a script that reads one line, prints the describe answer and sleeps; then OPENSYSML_TOOL_TIMEOUT=5s sysml -engine all -instantiate Plant::tank -action "Plant::Tank::fill Plant::tank" -check-property Plant::Tank::low tank.sysml.
Two things follow for this change:
- The prompt failure depends on the write being refused. In one of about eight head runs of the closed-stdin case, made while the machine was busy with a test run, the
coverswrite reached the pipe before the stand-in closed it, and that run hung (stopped by hand after 572s; the goroutine dump showssession.callwaiting at its firstselectforcovers). It did not recur in five quiet runs. Base has the same window. - The second commit's case is not reachable this way from the CLI:
coversis written before the engine's exit is collected, so the write succeeds and both builds wait for the helper to release the output (bounded by the timeout). The new unit test covers it by waiting for the exit first.
Past fixes in the touched area
The 32 analysis, engine and subprocess rows of the regression inventory map to these packages, all passing on head: internal/exec/analysis/... (also the session, engine and tool tests under -race, and TestSessionRefusedWrite* 20 times), internal/exec/solve/..., internal/exec/runtime, internal/frontend/repl/..., internal/frontend/grpc/..., cmd/sysml (engine, tool, check, external, pipe and timeout tests), cmd/sysml-grpc/..., tests/grpc/..., client/opensysml/.... go vet and gofmt are clean on internal/exec/analysis.
…write-no-full-timeout
Co-Authored-By: jason.han <hanhuijun@gmail.com>
What and why
When an external analysis engine's pipe refuses a request,
session.unwritablewaits for the reader to report the process's end so the caller gets the real exit rather than a bare pipe error. If the engine has stopped reading its input but keeps its output open, the reader never reports an end, and the wait ran for the session's whole timeout before the request failed.The wait is now bounded by
unwritableGrace(one second, or the session timeout when that is shorter). After it, the session is ended with anEngineExitedErrorcarrying the process's exit status when the exit was already collected (an engine that exited while a helper still holds its output open), and the write's own error otherwise.Part of #2445.
How it was verified
TestSessionRefusedWriteDoesNotWaitTheTimeout, driven by a newstdin-closedmode of the engine stand-in (it answersdescribe, then closes its standard input and keeps its output open). Without the change tosession.gothe test fails after the full one-minute timeout (the refused write took 1m0.001864804s under a one-minute timeout); with it, it passes.TestSessionRefusedWriteReportsTheCollectedExit, driven by a newexit-holding-outputmode (the stand-in exits with status 7 while a helper keeps its standard output open for five seconds). Without the collected-exit branch the request fails with the write error; with it, with exit status 7.go test -count=1 -race -run TestSessionRefusedWrite ./internal/exec/analysis,go test -count=1 ./internal/exec/analysis,go vet ./internal/exec/analysis/...andgofmt -l internal/exec/analysisare clean.make testandmake lintwere not run locally.Checklist
make testandmake lintpass locallychanges/unreleased/<slug>.<section>.md, not as an edit toCHANGELOG.mdmake docs-countsrun if a gate count moved (compliance rows need nothing: the census is counted at docs build)F4,K5) in the body, docs, or changelogImplemented in session Fix issue 2445 before the 0.13.0 cut
Review with Devin · Open in Devin Desktop