Fix slot-range parsing during migration and add rebalance planning logic#92
Open
ysqyang wants to merge 1 commit intovalkey-io:mainfrom
Open
Fix slot-range parsing during migration and add rebalance planning logic#92ysqyang wants to merge 1 commit intovalkey-io:mainfrom
ysqyang wants to merge 1 commit intovalkey-io:mainfrom
Conversation
34325d0 to
78cb392
Compare
ede2f24 to
e728115
Compare
e728115 to
7c7182f
Compare
Two independent but related changes for scale-out support: 1. Skip migrating/importing entries (e.g. "[5461->-abc123]") in parseSlotsRanges to prevent parse errors when CLUSTER NODES output contains in-progress slot migrations. Adds unit tests. 2. Introduce BuildRebalanceMove which computes a single, deterministic slot move to incrementally rebalance a cluster after scale-out. Calculates per-primary slot targets (16384 / shards), identifies the most-loaded source and least-loaded destination, and returns a bounded SlotMove. Returns one move per call so each reconcile loop stays fast and restartable. Includes unit tests. Signed-off-by: yang.qiu <yang.qiu@reddit.com>
7c7182f to
82a27d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
parseSlotsRangesto skip[slot->-nodeid]/[slot-<-nodeid]entries that Valkey appends toCLUSTER NODESoutput during active slot migrations, which previously caused parse errors.BuildRebalanceMove— a deterministic, incremental slot rebalance planner that computes a single slot migration from an overloaded primary to an underloaded (or empty) one. This is the planning layer for scale-out support; execution is wired in a follow-up PR.Test plan
parseSlotsRanges: normal ranges, migrating/importing entries, empty input, migration-only inputBuildRebalanceMove: scale-out (2→3 shards), balanced cluster (no-op), mismatched shard count, extra empty shards, zero max-slots, slot extraction from ranges