Skip to content

cluster: runners joining one after another move the same shard several times #10060

Closed

Description

@heyimcarlos

Base: effect 4.0.6 (effect/cluster, SqlMessageStorage + SqlRunnerStorage on PostgreSQL advisory locks). main has the same code.

What happens. Each runner recomputes assignments on every change to the healthy runner set. When N runners join
a few seconds apart (a rolling deploy, an autoscaler adding runners one by one), each join produces a new hash ring,
and a shard can move from A to B, then from B to C, within one scale event. Each move drains the shard's entities on
the old owner and replays them on the new one.

Repro. Handoff.test.ts: one runner with 24 shards; three more runners join 1.5 s apart. Track each shard's
owner. On 4.0.6, 9 shards move twice. Expected: each shard moves at most once.

Proposed fix (implemented on a fork, PR available). ShardingConfig.assignmentSettleWindow (default 0, the current behavior). After a runner joins,
recompute once the healthy set has been unchanged for the window, and at most four windows after the first change.
A runner leaving recomputes at once, so its shards are not left unowned. A runner with no assignments yet computes at
once.


Runnable repro (real runner processes, fails on 4.0.6 and on main at 837e906): https://github.com/heyimcarlos/effect-cluster-repro, issue 5 in the README table.

Activity

  1. self-assigned this
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions