gcwork: a wait ends when its telling is delivered, not when it is queued #112
Loading…
Reference in a new issue
No description provided.
Delete branch "telling-delivered"
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?
gcwork: a wait ends when its telling is delivered, not when it is queued
A foreman in a long turn holds the telling of a closed task; a start afresh
drops it, and the wait was already gone, so the foreman never heard. The wait
now stays, as
task@<Seq of the telling>in the waits mark, until the tellinghas a Delivered record (the host's report that the agent took it). While the
telling has neither that nor a Dropped record, Poll queues no second one. A
Dropped record leaves the plain task among the waits and the next poll tells
the session as it is now. A telling for a task no longer among the waits adds
nothing back. Registry.PromptEnd reads the records already written, so no new
event kind or migration.
Mend not taken: putting the task back among the waits when its telling is dropped. It would need the dropping side (the registry) to write the gcwork-owned waits mark, and it could not tell a task the session had meanwhile waited for again, or that #107 dropped as unreadable, from one to restore; leaving the task in the waits until delivery has no such case.
Not covered: a crash between queuing the telling and recording its Seq in the mark tells the task once more, as the old order told it twice when the mark was not cleared.
bd-7@2for a task id, refuses it as no bead's id, keeps that wait with one warning and tells nothing. It matters only for a rollback while a telling is pending.Review for spec-sqh.19, at head
f0c40ccon mainb84db7c. The design holds and does what the ticket asks; four things asked, the first a one-clause change to the query. This comment is complete by itself.What holds, each run by me
go vet ./...,go test -race -count=1 ./..., andGOMAXPROCS=1 go test -count=20 ./internal/gcwork/ ./internal/session/: all pass.bd-7@2, and its next start is told (bd-7@6, two tellings in all);PromptEndisErrNotFound, the session is told once more (bd-7@5) and five further polls tell nothing, so not "each poll";bd-7@,bd-8@x,bd-9@0,bd-10@999) are each told once and rewritten properly;waitcalled again for a task recorded asbd-7@2adds nothing.Purgeremoves a whole ended session with its marks, and of a living one only starts that are not its latest, soMAX(seq)does not fall.Handledsince 0.11.0 and retries the report, so a session's pod older than the server still ends its waits.internal/chatis touched.1.
PromptEndreads every event of the session, on the registry's one connectionThe first query has no bound on
seq, so while a telling is pending it walks the session's whole history, frames included, once per pending telling at every poll; the registry opens one connection (SetMaxOpenConns(1)), so every other call of the server waits behind it. An always-on session's latest start is never purged, so the history only grows. Measured on this branch, events of 2 KB:The record that ends a prompt is always appended after its Stored record. Asked: add
AND seq > ?(the telling's Seq) to the first query, which turns the walk into the events since the telling:All the branch's tests pass with it.
2. The branch that reads
ErrNotFoundas dropped has no test in gcworkpollWaitresets an entry whose Seq names no record and tells again; only the registry's side (PromptEndof seq 999) is tested. Asked: a test ininternal/gcworkon a real registry: tell, start afresh,Purgewith a time after now (which removes the first start with the telling's records),Poll; the session is told once, the mark carries the new Seq, and further polls tell nothing.3. The docs of
StoredandDeliveredsay the opposite of what this change relies oninternal/session/session.go: "Delivered is a prompt the server handed to the session host; what the host did with it is not reported back", and "Stored is a prompt the server holds and has not yet sent on". Neither is true of the code: the only writer of a Delivered record isHandled, on the host's report that the prompt began a turn or went into the running one, and a prompt the host holds is still Stored.PromptEnd's own doc says it rightly. Asked: correct the two constants' docs to what the records mean, one sentence each.4. The body's "Not covered" lacks two things
bd-7@2for a task id, refuses it as no bead's id, and keeps that wait with one warning, telling nothing (run on main: five polls, no telling, the mark unchanged). It matters only for a rollback while a telling is pending.Not asked
Handled(BeganTurn)is reported before the agent answerssession/prompt, so "the agent took it" means the host gave it to the agent. That is as close as the records get.d0d9fb8252cd972c25a6