An acp session's pane outlives it after a signal: the view must close on every exit path #95
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Due date
No due date set.
Dependencies
No dependencies set
Reference
mikluko/rexcity!95
Loading…
Reference in a new issue
No description provided.
Delete branch "worker/rexcity-fhi2k"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes rexcity-fhi2k: an acp session's pane outlived its session.
Why the pane stayed
What the evidence shows, and what it does not.
01a1d101…in the gascitypacks tab, labelledreviewer. Rex's id timestamp reads 19:24:49 CET, the start of the reviewer-3 sessiongcg-session-595a8dd6…, whose log ends20:03:36 ━━ adapter exited, code 0 ━━after gc'sclosing the sessions on a signal.~/.rexcity/<city-key>/views/holds no record for that session, and the pane is still inrex window ls. So the record was forgotten while the pane stayed. The reviewer-2 session that ended in the same 0.25 s (…f130061…) lost its pane normally.rpp.Runtime.CloseViewforgot the record first and then closed the pane, andviewPanes(the prune at the next start) closed the pane of a dead wrapper, warned if that failed, and forgot the record anyway. After a single failed Rex call, nothing held the pane's id any more.CloseViewfails before the record is touched. It was not the signal path either: the log shows the wrapper got its SIGTERM and the adapter exited cleanly (the same path closed the 340-odd other sessions).pane not closed: …) goes to its stderr, which gc passes to nobody; nothing under~/.rexcity/<city-key>/or~/.gc/holds it. I did not close the stale pane or call Rex's mutating commands against the live server (only the read-onlywindow ls). The two wrappers closed their panes within 0.25 s of each other, so a conflict between concurrent closes is a guess, not a finding.What changed
rpp.CloseViewcloses the pane first and forgets the record only once it is closed; on failure it returns the error and the record stays.viewPaneskeeps the record of a dead wrapper's view whose pane could not be closed, warns, and the next start tries again.internal/acpbox/box.go) starts closing its pane the moment the adapter exits (beside the drain wait, not after it), tries three times (CloseRetry, 500 ms), and runs the close from a deferred wait too, so a panic in the wrapper's own goroutine still closes it.· pane not closed: …), so the next time the reason can be read..changelog/acp-pane-closes-with-session.md.Left open: a wrapper killed with SIGKILL still leaves its pane until the next start's prune, which now retries until it works.
OpenView's replacement of an old view of the same name (closeStale) still only warns if the old pane will not close.How I checked
go vet ./...,GOOS=darwin GOARCH=arm64 go vet ./...,go test ./...with a failingrexstub first on PATH (no test reaches the live Rex),go test -raceofinternal/acpbox,internal/rpp, andchangelog -base main(valid=true).I undid the change each test is for, saw it fail, and restored it:
TestCloseViewKeepsTheRecordWhileThePaneIsOpen: old CloseView order.TestAStartKeepsTheRecordOfADeadWrappersViewItCouldNotClose: viewPanes withoutcontinue.TestThePaneClosesOnEveryWayTheRunEnds/a SIGQUIT: SIGQUIT out ofsignal.Notify(the test binary dies of it).TestAPaneThatFailsToCloseIsClosedAgainandTestAPaneThatCannotBeClosedIsSaidInTheLog: one attempt only.TestAPaneThatCannotBeClosedIsSaidInTheLog: no log note.TestThePaneClosesAtOnceWhenTheAdapterExits: close started after the drain.The other three cases of
TestThePaneClosesOnEveryWayTheRunEnds(SIGTERM, adapter killed, adapter exits with an error) pass without my change: they guard the paths that already worked. The deferred close on a panic has no test.TestAWordOfMegabytesOnATerminalIsKeptForAReplayInLinearTime(not mine, a 5 s bound) failed once of five-raceruns under load, with 6.6 s.Bead: rexcity-fhi2k
Review of
4341833e3cfor rexcity-fhi2k. Checks of the head: success.Verdict
pass
Findings
view.wait()that closes the pane on a panic inrun's goroutine has no test (the description says so). A case that panics in a hook afteropenViewand checks the fake host's closes would pin it down. Only a panic in that goroutine is covered: one in the renderer's or a relay goroutine still ends the process without runningrun's defers. The description's wording ("the wrapper's own goroutine") is accurate about this.CloseViewtries, each of which can take the city lock wait (10 s) plusCloseTimeout(10 s), before it returns. gc may SIGKILL it first. Since the record now stays when a close fails, the next prune still closes the pane, so nothing is lost. This is a note, not a defect.Verified
rpp.CloseViewused to forget the record beforeclosePane, andviewPanesforgot the record of a dead wrapper's view even when the close failed. Both paths now keep the record until the pane is gone.closePanestill treats a block that is no longer listed as closed, so a pane the user closed by hand does not leave a record behind for ever.viewPanesonly looks at records of the current Rex session, as before.signal.Notify, andwatchSignals' default branch sends it toterminate, which also writes the· quitnote to the log.viewCloserruns the close exactly once (viasync.Once).start()begins it when the adapter exits, alongside the drain. The log note after a failed close is written only onceq.doneshows the renderer has ended, so it races with no other writer of the log.a5f35b2) is a fast-forward with no conflict, and the forge says mergeable.rexstub first on PATH:go vet ./...ok;GOOS=darwin GOARCH=arm64 go vet ./...ok;go test ./...all packages ok;go test -race -count=1 ./internal/acpbox/ ./internal/rpp/ok.changelog -base main(the city's build from PATH):valid=true, exit 0. The fragment.changelog/acp-pane-closes-with-session.mdhas only a### Fixedheading and its bullets, describes the effect for a city, and the change is not breaking. The README's acp box section is updated to match.rex window ls, and the two places that forget a record are named. Locking and the signal path are ruled out with reasons. That Rex failed the close is stated as not proven, and the new log note means the next occurrence can be diagnosed.