Skip to content

release-26.2: mmaprototype: materialize per-range constraint analysis in snapshot#169876

Merged
trunk-io[bot] merged 1 commit into
cockroachdb:release-26.2from
tbg:blathers/backport-release-26.2-169747
May 7, 2026
Merged

release-26.2: mmaprototype: materialize per-range constraint analysis in snapshot#169876
trunk-io[bot] merged 1 commit into
cockroachdb:release-26.2from
tbg:blathers/backport-release-26.2-169747

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented May 6, 2026

Backport 1/1 commits from #169747 on behalf of @tbg.


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


Release justification:

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>
@tbg tbg requested a review from a team as a code owner May 6, 2026 23:44
@tbg tbg force-pushed the blathers/backport-release-26.2-169747 branch from 1ee0f87 to 5e25498 Compare May 6, 2026 23:44
@tbg tbg requested a review from a team as a code owner May 6, 2026 23:44
@blathers-crl blathers-crl Bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels May 6, 2026
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented May 6, 2026

😎 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.

@blathers-crl blathers-crl Bot requested a review from wenyihu6 May 6, 2026 23:44
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented May 6, 2026

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.

@blathers-crl blathers-crl Bot added backport Label PR's that are backports to older release branches T-admission-control Admission Control labels May 6, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@trunk-io trunk-io Bot merged commit 79c9415 into cockroachdb:release-26.2 May 7, 2026
21 of 22 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-admission-control Admission Control target-release-26.2.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants