Skip to content

cluster: add seed_static_route for deterministic static routing - #77

Open
Damon6666 wants to merge 3 commits into
DeepLink-org:mainfrom
Damon6666:fix/static-route-seeding
Open

Damon6666 wants to merge 3 commits into
DeepLink-org:mainfrom
Damon6666:fix/static-route-seeding

Conversation

@Damon6666

Copy link
Copy Markdown

Problem

In large static deployments (10k+ named actors across shards), named-actor resolution depends on gossip convergence. Nodes reachable only via statically configured routes never join gossip membership, so SWIM probes against them fail and the resolver filters those routes out — surfacing as No healthy instances errors from resolve() under load. We hit this reliably when scaling a named-actor workload to 10k actors across 2 ActorSystem processes.

Solution

Add an explicit, opt-in seeding API that registers path -> addr directly, bypassing gossip convergence:

  • NamingBackend::seed_static_route(path, addr) — new trait method with a default no-op implementation (backward compatible for other backends)
  • GossipBackend / GossipCluster implementation — derives a synthetic NodeId from the address hash and inserts an Online ClusterNode plus a named-actor instance, so resolve() succeeds without gossip round-trips; delivery is by path, so the synthetic id does not need to match the peer's real node id
  • ActorSystem::seed_static_route(path, addr) — public entry point:
system.seed_static_route("shops/worker_1", "127.0.0.1:12100").await?;

Callers with static topologies seed routes at startup (and may refresh periodically) for deterministic delivery.

Evidence

Validated in a 2-process, 10,101-actor deployment (single desktop, WSL2):

  • 9,999 cross-process named-actor letters over ~13 hours: 0 send errors, 0 unresolved routes, 0 lost letters (every delivery reconciled against a precomputed ground truth)
  • Pre-fix runs intermittently failed resolve() with No healthy instances as soon as SWIM marked the statically-known nodes unhealthy
  • No changes required to existing gossip behavior; seeding is purely additive

Notes

  • The trait-level default keeps non-gossip backends source-compatible.
  • Happy to adjust naming/placement (e.g. cluster/ vs system/) to maintainers' preference.

In large static deployments (10k+ named actors across shards), named-actor
resolution currently depends on gossip convergence. Nodes reached only via
statically configured routes never appear in gossip membership, so SWIM
probes against them fail and the route gets filtered out, surfacing as
"No healthy instances" errors during resolve() under load.

Add an explicit seeding API that registers a path->addr route directly,
bypassing gossip convergence:

- NamingBackend::seed_static_route (default no-op, backward compatible)
- GossipBackend/GossipCluster implementation: derives a synthetic NodeId
  from the address hash and inserts an Online ClusterNode plus a named
  actor instance, so resolve() succeeds without gossip round-trips
- ActorSystem::seed_static_route(path, addr) public entry point

Callers with static topologies can seed routes at startup (and refresh
periodically) for deterministic delivery.

Validated in a 2-process, 10,101-actor deployment: 9,999 cross-process
named-actor letters over 13 hours with 0 send_err and 0 unresolved
routes; pre-fix runs intermittently failed resolve with "No healthy
instances".
@codecov-commenter

codecov-commenter commented Oct 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/pulsing-actor/src/cluster/gossip.rs 96.15% 1 Missing ⚠️
crates/pulsing-actor/src/cluster/naming.rs 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
...rates/pulsing-actor/src/cluster/backends/gossip.rs 80.64% <100.00%> (+0.64%) ⬆️
crates/pulsing-actor/src/system/resolve.rs 65.21% <100.00%> (+1.03%) ⬆️
crates/pulsing-actor/src/cluster/gossip.rs 69.46% <96.15%> (+0.76%) ⬆️
crates/pulsing-actor/src/cluster/naming.rs 0.00% <0.00%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Cover the seed_static_route path added in this PR: bad-addr rejection,
named-instance registration, resolve() success without gossip
round-trips, idempotent re-seeding, and multiple names per address
(the N-shops-per-shard shape).
@Damon6666

Copy link
Copy Markdown
Author

Added unit tests for the new seed_static_route path (5 tests, all passing locally via cargo test -p pulsing-actor --test unit static_route):

  • rejects malformed addresses
  • registers a resolvable named instance without any gossip round-trip
  • re-seeding is idempotent (refresh path keeps the route usable)
  • multiple names per address (the N-shops-per-shard deployment shape)
  • resolve() succeeds against a node that never joined gossip — the exact failure mode this PR fixes

Pushed as c5cb4f5 — Codecov should pick up the new coverage on the next report.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants