fix(workers): bound the heartbeat skip by heartbeat age on the monotonic clock; deadline covers the enqueue; a reply that wins the timeout race is returned (WRK-001, WRK-003, WRK-004, WRK-005, #253)
This commit is contained in:
@@ -647,6 +647,21 @@ Pending command handling:
|
||||
Timeouts should not assume the COM call stopped. A timed-out command may still
|
||||
finish inside the worker.
|
||||
|
||||
The command timeout is one deadline for the whole call, the outbound enqueue
|
||||
included. The outbound channel is bounded, and a write loop parked in a pipe
|
||||
write the worker is not draining leaves it full; an enqueue bound only to the
|
||||
caller's token then waited indefinitely for a caller with no deadline. The
|
||||
common case (room in the channel) is a non-allocating `TryWrite`; only a full
|
||||
channel waits, under the deadline, and the reply wait gets what is left of it.
|
||||
An enqueue that runs out of time fails the command as `CommandTimeout` with no
|
||||
`WorkerCancel`, because the worker never saw it.
|
||||
|
||||
When the deadline fires, the timeout arm owns the outcome only if it removes the
|
||||
pending entry. If the read loop removed it first (the reply landed right at the
|
||||
deadline), the caller gets that reply, which is what the metrics already counted,
|
||||
instead of a `CommandTimeout` that would make it retry a write the worker
|
||||
performed.
|
||||
|
||||
On timeout **and on caller cancellation** the client also forwards a
|
||||
`WorkerCancel` carrying the abandoned correlation id, best-effort: the gateway
|
||||
has stopped waiting, but the worker has not stopped working, and the worker owns
|
||||
|
||||
Reference in New Issue
Block a user