Skip to content

kvserver: co-construct AllocatorSync in NewStore#170638

Merged
trunk-io[bot] merged 2 commits into
cockroachdb:masterfrom
tbg:mma-allocatorsync-newstore
May 26, 2026
Merged

kvserver: co-construct AllocatorSync in NewStore#170638
trunk-io[bot] merged 2 commits into
cockroachdb:masterfrom
tbg:mma-allocatorsync-newstore

Conversation

@tbg

@tbg tbg commented May 20, 2026

Copy link
Copy Markdown
Member

Production code (server.go) pairs MMAllocator with an AllocatorSync on
the StoreConfig. A number of test entry points populate MMAllocator (via
TestStoreConfig) and StorePool but leave AllocatorSync unset. The MMA
store rebalancer worked around this with a buildutil-gated fallback that
lazily constructed an AllocatorSync in test builds and panicked otherwise.

That gate was tripping benchmarks, which are compiled without the crdb_test
tag, producing failures like:

panic: AllocatorSync must be set on StoreConfig outside of test builds

This PR co-constructs AllocatorSync inside NewStore when MMAllocator is
set but AllocatorSync is not, mirroring what server.go already does
explicitly. The fallback in newMMAStoreRebalancer is replaced with a plain
non-nil assertion, and the now-redundant explicit construction in
localtestcluster is dropped.

Verified locally with ./dev bench (which builds with --crdb_test_off,
matching the failing TC RoachprodMicrobenchmarkWeeklyWip configuration):

./dev bench pkg/kv/kvserver -f BenchmarkStoreGetReplica --bench-time=1x

Fixes #170455.
Fixes #170456.

Release note: None
Epic: none

Production code (server.go) pairs MMAllocator with an AllocatorSync on the
StoreConfig. A number of test entry points populate MMAllocator (via
TestStoreConfig) and StorePool but leave AllocatorSync unset. The MMA store
rebalancer worked around this with a buildutil-gated fallback that lazily
constructed an AllocatorSync in test builds and panicked otherwise. That gate
was tripping benchmarks (which are compiled without the crdb_test tag), e.g.
BenchmarkStoreGetReplica and BenchmarkMVCCGCWithForegroundTraffic.

Co-construct AllocatorSync inside NewStore when MMAllocator is set but
AllocatorSync is not, mirroring what server.go already does explicitly. The
fallback in newMMAStoreRebalancer is replaced with a plain non-nil assertion,
and the now-redundant explicit construction in localtestcluster is dropped.

Fixes #170455.
Fixes #170456.

Release note: None
Epic: none

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@trunk-io

trunk-io Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@tbg tbg added the backport-26.2.x Flags PRs that need to be backported to 26.2 label May 20, 2026
@blathers-crl

blathers-crl Bot commented May 20, 2026

Copy link
Copy Markdown

Detected infrastructure failure (matched: self-hosted runner lost communication with the server). Automatically rerunning failed jobs. (run link)

Follow-up to dropping the mmaintegration import from
pkg/testutils/localtestcluster/local_test_cluster.go.

Release note: None
Epic: none

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@tbg tbg requested a review from angeladietz May 20, 2026 15:41
@tbg tbg marked this pull request as ready for review May 21, 2026 08:39
@tbg tbg requested a review from a team as a code owner May 21, 2026 08:39

@angeladietz angeladietz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. out of curiosity, would it also have been an option to just specify the AllocatorSync in all the tests, to make the tests more representative of production code?

@trunk-io trunk-io Bot merged commit 316c635 into cockroachdb:master May 26, 2026
51 of 53 checks passed
@blathers-crl

blathers-crl Bot commented May 26, 2026

Copy link
Copy Markdown

Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.


Issue #170455: branch-release-26.2.


Issue #170456: branch-release-26.2.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl

blathers-crl Bot commented May 26, 2026

Copy link
Copy Markdown

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


merge conflict cherry-picking c09e0f8 to blathers/backport-release-26.2-170638

Backport to branch 26.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@tbg

tbg commented May 27, 2026

Copy link
Copy Markdown
Member Author

LGTM. out of curiosity, would it also have been an option to just specify the AllocatorSync in all the tests, to make the tests more representative of production code?

Yes, I looked at both and was on the fence (because I consider "test-only init paths in prod" a risk generally). But it was tedious to construct an AllocatorSync in ~12 places. Let me take another look though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-26.2.x Flags PRs that need to be backported to 26.2 backport-failed target-release-26.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/kv/kvserver: BenchmarkStoreGetReplica failed pkg/kv/kvserver: BenchmarkMVCCGCWithForegroundTraffic failed

3 participants