release-26.2: mmaprototype: materialize per-range constraint analysis in snapshot#169876
Merged
trunk-io[bot] merged 1 commit intoMay 7, 2026
Conversation
Add a RangeAnalysis sub-message to RangeSnapshot exposing the most
useful pieces of mmaprototype.rangeAnalyzedConstraints:
- voter_balance / non_voter_balance -- (current count) - (configured
count). Zero means the range has the configured number of voters /
non-voters; positive means surplus, negative means missing. Framed
this way so a fully-conforming range yields the proto3 zero value
and serializes as an empty analysis: {} block;
- unsatisfied_constraint_voter/non_voter_store_ids -- replicas that
satisfy no SpanConfig.Constraints conjunction (MMA's preferred
eviction candidates);
- unsatisfied_voter_constraint_store_ids -- voters that satisfy no
SpanConfig.VoterConstraints conjunction;
- leaseholder_lease_preference_index -- the earliest LeasePreferences
entry matched by the current leaseholder.
These values are derivable from the rest of the snapshot
(SpanConfig + Replicas + per-store StoreAttributes), but offline
recomputation requires reimplementing MMA's constraint-matching logic
(~30 LOC) and lease-preference scoring, which every consumer would
otherwise duplicate. Materializing them keeps the snapshot self-
describing for "is this range conforming?" / "is the lease in the
right region?" diagnostics without coupling consumers to MMA's
internal matcher. The fields are framed so that the typical
fully-conforming range carries no payload at all — every list is
empty, both balances are zero, and the leaseholder lease-preference
index is zero (which doubles as the "no preferences configured"
sentinel) — so the analysis only takes up snapshot space when there is
something noteworthy to report.
The analysis is computed directly from rangeState.replicas and
rangeState.conf rather than reading the rangeState.constraints cache,
which is built lazily by the allocator and may be unpopulated. LEARNER
and VOTER_DEMOTING_LEARNER replicas are excluded from both buckets,
matching the source-side rangeAnalyzedConstraints semantics.
Epic: none
Release note: None
Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
1ee0f87 to
5e25498
Compare
Contributor
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
wenyihu6
approved these changes
May 6, 2026
Member
tbg
added a commit
to 5hubh4m/cockroach
that referenced
this pull request
May 8, 2026
7 already backported via separate release PRs (cockroachdb#169344, cockroachdb#169590, cockroachdb#169711, cockroachdb#169734, cockroachdb#169742, cockroachdb#169761, cockroachdb#169876) but invisible to script because the cherry-picked commits don't reference the original PR number. 7 are unrelated to MMA (admission/AC, sql, kvserver/storage, ci, roachtest/perturbation). 2 are master-and-onward only by intent: cockroachdb#169430 (enable MMA by default in v26.3) and cockroachdb#169669 (retire load_based_lease_rebalancing setting). Net: 0 PRs need backporting to release-26.2. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
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.
Backport 1/1 commits from #169747 on behalf of @tbg.
Add a
RangeAnalysissub-message toRangeSnapshotexposing the most useful pieces ofmmaprototype.rangeAnalyzedConstraints:voter_balance/non_voter_balance—(current count) - (configured count). Zero means the range has the configured number of voters / non-voters; positive means surplus, negative means missing. Framed this way so a fully-conforming range yields the proto3 zero value and serializes as an emptyanalysis: {}block.unsatisfied_constraint_voter/non_voter_store_ids— replicas that satisfy noSpanConfig.Constraintsconjunction (MMA's preferred eviction candidates).unsatisfied_voter_constraint_store_ids— voters that satisfy noSpanConfig.VoterConstraintsconjunction.leaseholder_lease_preference_index— the earliestLeasePreferencesentry matched by the current leaseholder.These values are derivable from the rest of the snapshot (
SpanConfig+Replicas+ per-storeStoreAttributes), but offline recomputation requires reimplementing MMA's constraint-matching logic (~30 LOC) and lease-preference scoring, which every consumer would otherwise duplicate. Materializing them keeps the snapshot self-describing for "is this range conforming?" / "is the lease in the right region?" diagnostics without coupling consumers to MMA's internal matcher. The fields are framed so that the typical fully-conforming range carries no payload at all — every list is empty, both balances are zero, and the leaseholder lease-preference index is zero (which doubles as the "no preferences configured" sentinel) — so the analysis only takes up snapshot space when there is something noteworthy to report.The analysis is computed directly from
rangeState.replicasandrangeState.confrather than reading therangeState.constraintscache, which is built lazily by the allocator and may be unpopulated.LEARNERandVOTER_DEMOTING_LEARNERreplicas are excluded from both buckets, matching the source-siderangeAnalyzedConstraintssemantics.Epic: none
Release note: None
Release justification: