Expose shard id in CLUSTER SHARDS respone #2568
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem Statement
Currently, we use slot ranges to uniquely identify the shards in the cluster, which has been working, but with the split ranges, it gets ugly and present few unnecessary challenges to maintain our own shardId in Valkey control plane and client library.
Example:
shardId:0-999_2001-3999_4501-5460
one might argue that , It's possible to get the shard id using
CLUSTER MYSHARDID
, but this needs to be executed on each node in the cluster, which is unnecessary overhead.Proposed Solution
This change exposes an existing, persistent (in nodes.conf) unique shard Id for each shard in the cluster as part of the
CLUSTER SHARDS
command response.This has several key benefits ..
Simplified and More Robust Client-Side Logic: Clients can now use the shard_id to build a more resilient and accurate internal representation of the cluster topology. This simplifies the logic required to handle MOVED redirections and other cluster state changes, as clients can reliably map slots to a consistent shard identity.
Improved Observability and Control Plane: Management and monitoring tools can leverage the shard_id to track shard-level performance metrics, configuration history, and health status over time, regardless of which node is the current primary.
Alternatives you've considered:
CLUSTER SLOTS
response, since it is tagged for deprecation in favor ofCLUSTER SHARDS