perf(worker): alarm poll loop parks until a subscription activates instead of ticking (MXA-011, #258)
ci / windows-x86 (push) Successful in 3m10s
ci / java (push) Failing after 11m14s
ci / portable (push) Failing after 19m30s

The poll loop skipped the STA hop while unsubscribed but its timer still woke
every interval (a Task.Delay timer plus a thread-pool continuation per tick on
every idle worker). It now parks on a semaphore while IsSubscribed is false and
is released by the handler's new SubscriptionActivated event; a subscribe that
races the park is kept by the semaphore count. While subscribed it never parks,
so failover polling and probes (MXA-001) are unchanged, and shutdown cancels a
parked loop like a sleeping one, so the MXA-003 join and grace bound hold. The
failure run resets when the loop parks.
This commit is contained in:
Joseph Doherty
2026-12-03 13:10:35 -05:00
parent a38578d0e2
commit bb63c8ba72
7 changed files with 193 additions and 8 deletions
+13
View File
@@ -1083,6 +1083,19 @@ the STA more than 75 s without pumping *should* fault — that is the ceiling's
contract). The flag is named generically so any future non-dispatcher STA work
reuses it.
The poll loop runs only while the handler has an alarm subscription (MXA-011).
It starts with the session but parks on a semaphore while
`IAlarmCommandHandler.IsSubscribed` is false, so a session that never subscribes
to alarms — or has unsubscribed — takes no timer, thread-pool or STA wake-ups at
the poll rate. A successful `Subscribe` raises `SubscriptionActivated`, which
releases the semaphore; the loop then resumes ticking at `AlarmPollInterval`.
While subscribed it never parks, so the failover consumer still sees every
`PollOnce` it counts primary failures and failback probes on (MXA-001). Shutdown
cancels a parked loop the same way as a sleeping one, so the graceful-shutdown
join and its grace bound (MXA-003) are unchanged. The consecutive-failure count
below resets when the loop parks, so a new subscription does not inherit an
earlier one's failure run.
A `PollOnce` that throws does not fault the session on the first failure. The
poll loop counts consecutive failures and records the alarm-poll fault
(`MxaccessEventConversionFailed`) only when the count reaches