You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tasks: a parent reads 'owed' before 'outstanding' and spends one empty turn when its last two parts land together #192
Found by the #176 lane (PR #187) while chasing the load flakes; named there, not changed, because #172 and #175 owned the file at the time.
What happened
internal/session/task_run.godeliverTaskNote documents its own ordering law: "the queue, then the fact, then the wake, and never in any other order" — so that a waiter which sees a child no longer outstanding is guaranteed to also see a note owed. But runTaskChild reads the two facts in the opposite order:
owed is read first, so a delivery that lands between the two reads is seen as "not outstanding, nothing owed" — and the parent takes a turn with nothing to say. Captured during #187's work as two byte-identical parent requests: a divided parent whose last two parts land together spends one wasted model turn (real money, and a confusing blank exchange in the room).
The mechanism
Read in the order the delivery law promises: outstanding first, then owed — or better, one method on the child that answers both under one lock, so the two reads cannot be split by a delivery. State the law at the read site the way deliverTaskNote states it at the write site.
Audit the other readers of the pair (taskNewsOwed / childrenOutstanding call sites) for the same inversion.
Acceptance
A test lands the last two parts of a division at the same instant, many times over, and the parent never takes a turn with an empty request; it fails deterministically on today's dev (inject the delivery between the reads, or loop with a race detector).
runTaskChild and any other reader of the pair read them in law order or through one locked method; a comment names the law.
Drafted with CodeAF · reviewed and owned by the author
Activity
a parked parent reads its two facts as one, so a delivery is never se…
a parked parent reads its two facts as one, so a delivery is never se…
a parked parent reads its two facts as one, so a delivery is never se…