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
queen(actors): PgLink made safe - node incarnations, a fenced lease on its own thread, mail acknowledged after it is handled #1714
Part of #1712 (item 6: PgLink fencing and node incarnations).
Problem
createPgLink has no caller yet, and there is no TRIOS_ACTOR_NODE at the deployed head. Before it gets one, the six defects that reading queen-actors-pg.ts and queen-actors.ts found are each reproduced by a failing test on actors-next (b7aaf6b):
Mail rows are deleted before they are handled, so delivery is at most once. With three lost read answers, 11 of 20 messages were lost (pglive).
Pid generations restart after a process restart. A restarted node handed out its old pid, and mail written for the old process reached the new one (memory net and pglive).
The heartbeat shares the event loop with the actors. A 25 s synchronous turn gave a false node-down (pglive, child process).
A node its peers consider dead keeps running and sending. 12 messages arrived after its peer saw it down, and its actors were still alive. It also came back up when its lease came free (pglive, and the memory net).
Any node-down resolves every pending spawnOn to null, whatever node it targeted (memory net).
Mail to a dead node never expires: 5 rows were still there after the TTL (pglive).
A start claims the next incarnation in one transaction.
The lease is renewed by a worker thread with its own connection, and only while the loop turns.
Every write (renewal, send, acknowledgement, expiry) is fenced in SQL by the incarnation and the lease.
Mail is read, handled, then acknowledged, with dedupe by row id.
Each heartbeat reads every lease through peer_change/peer_up, and expires mail for incarnations that are over.
The node fences itself on must_fence.
queen-actors.ts:
Pids carry the incarnation.
A node-down ends only what waited on that incarnation (lost_with).
A fenced system stops every actor quietly, and from then on sends and starts nothing.
queen-actors-net.ts: the memory net plays the store's part (incarnations, expiry, self-fence).
pg-migrate.ts (QUEEN_ACTORS_SQL): incarnation on queen_actor_node; to_inc, from_node and from_inc on queen_actor_mail. These are additive, IF NOT EXISTS.
These are pure fixes: the link has no caller, and a node without a link (the reviewer in production) keeps section 1's pids and code path.
Acceptance
Every defect test above is green, and the api suite has no new failure.
A chaos benchmark runs the same script before and after: mail lost when delivery is killed mid-batch, duplicate handling, pid reuse across restart, false node-down under a held loop, a frozen node (SIGSTOP) still writing after its peers saw it down, and per-message latency. The numbers are posted on Queen moves to the actor model: the rule in every AGENTS.md, an MVP, a benchmark, then the swap t27#7851 and in the PR.
Merged into actors-next by #1724 (f319b5b). The spec is gHashTag/t27#8278 (merged). The benchmark is in the PR and on gHashTag/t27#7851. This issue stays open, like the other lanes' issues, until actors-next lands.
Shipped: #1724 merged into actors-next, which went into queen as 56c5df7 via #1730 (2026-10-10 13:38Z). Every new behaviour is behind a flag that is off. Closes fires only on the default branch main, so this is closed by hand. Ledger: #1729.
Activity
fix(queen): PgLink made safe before its first caller - node incarnati…
Merge pull request #1724 from gHashTag/queen-pglink-fencing
gHashTag commentedon Oct 9, 2026
Merged into actors-next by #1724 (f319b5b). The spec is gHashTag/t27#8278 (merged). The benchmark is in the PR and on gHashTag/t27#7851. This issue stays open, like the other lanes' issues, until actors-next lands.
gHashTag commentedon Oct 10, 2026
Shipped: #1724 merged into
actors-next, which went intoqueenas 56c5df7 via #1730 (2026-10-10 13:38Z). Every new behaviour is behind a flag that is off.Closesfires only on the default branchmain, so this is closed by hand. Ledger: #1729.