Skip to content

Update the shards gauge when shards are released (v3) - #9200

Merged
tim-smart merged 4 commits into
Effect-TS:v3from
Tanner-Scadden:fix/v3-cluster-shards-gauge-on-release
Oct 15, 2026
Merged

tim-smart merged 4 commits into
Effect-TS:v3from
Tanner-Scadden:fix/v3-cluster-shards-gauge-on-release

Conversation

@Tanner-Scadden

@Tanner-Scadden Tanner-Scadden commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ClusterMetrics.shards (effect_cluster_shards) is only updated after the acquisition loop acquires new shards, and set to 0 when shard locks are marked unhealthy. Shards removed from acquiredShards elsewhere don't update it:

  • the acquisition loop, when a shard is no longer assigned to this runner or is being handed off
  • refreshShardLocks, when a lock is lost or a refreshed shard is no longer assigned

So a runner that gives shards away keeps reporting its previous count until it next acquires something. Summed across runners, the gauge can read above the total shard count, and a shard that no runner holds doesn't show up.

This adds a small updateShardsGauge helper that sets the gauge from MutableHashSet.size(acquiredShards), and calls it after each of those removals as well as at the two existing update sites.

Validation

The regression in Sharding.test.ts starts a runner that acquires all 8 shards, then registers a second runner so the hash ring reassigns some of them. It checks the gauge equals the number of shards the first runner still holds. Without the fix it fails with expected 8n to equal 4n. Lint, typecheck, build and docgen pass. All 132 cluster tests pass.

Closes EFF-2195

@changeset-bot

changeset-bot Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4c8ef3d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/cluster Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added 3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3. bug Something isn't working labels Oct 15, 2026
@tim-smart
tim-smart enabled auto-merge (squash) October 15, 2026 08:26
@tim-smart
tim-smart merged commit a524079 into Effect-TS:v3 Oct 15, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3. bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants