Skip to content

Fix starvation flake in ArteryShutdownSystemMessageAckRaceSpec - #8360

Merged
Aaronontheweb merged 2 commits into
akkadotnet:devfrom
Aaronontheweb:fix/artery-shutdown-spec-starvation
Jul 11, 2026
Merged

Aaronontheweb merged 2 commits into
akkadotnet:devfrom
Aaronontheweb:fix/artery-shutdown-spec-starvation

Conversation

@Aaronontheweb

@Aaronontheweb Aaronontheweb commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Fixes the Windows CI flake that hit #8358's PR validation (ArteryShutdownSystemMessageAckRaceSpec timing out after 10s waiting for Terminated).

Root cause, established by a two-pass concurrency analysis: the spec raced the StreamSupervisor's shutdown window with 8 never-yielding busy-spin workers on the shared .NET ThreadPool — the same pool the supervisor, its children, and the test probe all need. On a 2-core CI agent the workers starve the supervisor's own mailbox processing, and the workers' only exit flag was set after the ExpectMsgAsync<Terminated> they were starving. Many-core Linux boxes hide it with spare cores, which is why it only bites hosted Windows agents. It's an environment-timing flake in the spec, not a product race — supervisor termination itself was verified monotonic and safe.

The rewrite asserts the guard's observable contract and nothing else: a bounded, yielding burst of fresh control-stream materialization attempts races a real system.Terminate(), and the spec asserts zero ERROR logs across the window, with the termination task itself as the completion signal. All the internal-teardown observation (watching the supervisor, hard 10s Terminated expectation) is gone, along with the busy-spin workers. This is deliberately a coarse smoke test — the terminating window may not be hit on every single run — which is the right cost/benefit for a guard whose failure mode is log noise; the spec's remarks say so explicitly.

Touches only the one spec file. Verification: 3x unconstrained and 10x under taskset -c 0,1 (2-core emulation) all green; full Artery suite 193/193; zero warnings.

@Aaronontheweb Aaronontheweb added artery Akka.Remote Artery Protocol tests confirmed bug labels Jul 10, 2026
The spec raced the StreamSupervisor's shutdown window with 8
never-yielding busy-spin Task.Run workers (up to 100k iterations each).
On 2-core CI agents those workers starved the shared ThreadPool badly
enough that the supervisor's own mailbox processing fell behind the
test's 10s Terminated bound -- and the workers' only exit flag was set
after that very expectation, so the starvation fed itself. An
environment-timing flake, not a product regression.

Rewritten as a coarse smoke test of the guard's observable contract:
race a real full ActorSystem.Terminate() (exercising both the
IsTerminating window and the _isShutdown fast-path) against a small
bounded yielding burst of EnqueueControl calls, and assert zero ERROR
logs across the whole shutdown. The burst may not land in the
terminating window on every run; that trade-off is accepted and
documented in the spec remarks. No product-code changes.
@Aaronontheweb
Aaronontheweb force-pushed the fix/artery-shutdown-spec-starvation branch from 0396e17 to e119366 Compare July 10, 2026 20:45
@Aaronontheweb

Copy link
Copy Markdown
Member Author

Reworked per review feedback: dropped the deterministic-gate apparatus (cell surgery, blocking-PostStop gate child, product-code observability hook) in favor of asserting the guard's observable contract — zero ERROR logs while a bounded yielding burst races a real system termination. Now touches only the spec file; net -21 lines vs dev. Same verification matrix: 3x unconstrained + 10x under taskset -c 0,1, all green.

@Aaronontheweb
Aaronontheweb merged commit 2d71eb5 into akkadotnet:dev Jul 11, 2026
11 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/artery-shutdown-spec-starvation branch July 11, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

artery Akka.Remote Artery Protocol confirmed bug tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant