Skip to content

De-flake Cluster.Hosting tests: stop hosts that fail to start, 60 s to join - #8620

Merged
Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/cluster-hosting-createhost-join-timeout
Sep 24, 2026
Merged

Aaronontheweb merged 1 commit into
akkadotnet:devfrom
Aaronontheweb:fix/cluster-hosting-createhost-join-timeout

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Member

Akka.Cluster.Hosting.Tests.ClusterSingletonSpecs.SeparateProxyWithManagerNameTest ("WithSingletonProxy should work with manager name") failed on a 2-vCPU Windows agent with a TaskCanceledException from TestHelper.CreateHost (seen in an AOT-stack #8613 build, which doesn't touch hosting).

Cause

  • CreateHost waited 30 s for MemberUp. The second (proxy) host needed about 29 s after startup to be let into the cluster, and its own MemberUp came after that.
  • The whole process was starved. The first node's heartbeats ran 5.8–7.3 s late for the entire test.
  • No message was lost; each join step just took 5–12 s. The only extra cost came from retry-unsuccessful-join-after (10 s) restarting the join, which dead-lettered the first Welcome (about 2.5 s).
  • The test and the hosting start path have no blocking calls that would explain it.

A leak found along the way

When CreateHost threw after StartAsync, the caller never got the host, so nothing ever stopped it. Its ActorSystem kept gossiping and heartbeating through every later test in the assembly.

Change (TestHelper.CreateHost only)

  • The cluster-formation wait goes from 30 s to 60 s, about twice what this run needed. CreateHost is a static helper outside the TestKit, so there's no timefactor to scale it with.
  • On any failure after the host is built, CreateHost stops it (best effort, 10 s, logged to the test output) and disposes it before rethrowing.

This covers every test that uses CreateHost: all of ClusterSingletonSpecs and ClusterShardingSpecs.

Verification (local)

  • ClusterSingletonSpecs and ClusterShardingSpecs pass, 9/9.

… s for it to join

ClusterSingletonSpecs.SeparateProxyWithManagerNameTest failed on a 2-vCPU
Windows agent with TaskCanceledException from CreateHost: the second (proxy)
host needed ~29 s from start to MemberUp against a 30 s budget, on a machine
whose heartbeats were already 6-7 s late. Nothing was lost - every join hop
just took 5-12 s.

- The cluster-formation wait goes from 30 s to 60 s.
- When CreateHost throws after StartAsync, the caller never receives the
  host, so it was never stopped: its ActorSystem kept gossiping and
  heartbeating through the rest of the assembly. CreateHost now stops (10 s,
  best effort, logged) and disposes it before rethrowing.

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb Aaronontheweb left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Aaronontheweb
Aaronontheweb merged commit 95dd7e7 into akkadotnet:dev Sep 24, 2026
15 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/cluster-hosting-createhost-join-timeout branch September 24, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant