Skip to content

allocator: carve out a package boundary#79991

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
irfansharif:220414.allocator
Apr 22, 2022
Merged

allocator: carve out a package boundary#79991
craig[bot] merged 2 commits intocockroachdb:masterfrom
irfansharif:220414.allocator

Conversation

@irfansharif
Copy link
Copy Markdown
Contributor

@irfansharif irfansharif commented Apr 15, 2022

allocator/storepool: carve out package from kvserver

This commit tries to pave the way for the allocator itself to be carved
out (storepool probably being a direct dependency, but ideally through
an interface). This commit shamelessly exports any and everything needed
in order for StorePool to sit outside the kvserver package boundary.
It's unfortunate how tangled up this component is, including in tests
(some of which reach deep into inner mutexes and mutate state). We're
not doing anything to improve the status quo other than moving it and
maybe pointing to the awkwardness.

allocatorimpl: carve out an allocator package

Do the same for kvserver/replicastats, a type that's used as an input
for the allocator at various points (needed to break the dependency
between the allocatorimpl and kvserver). We take the same approach as
the last commit, exporting anything and everything needed to introduce a
hard package boundary.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@irfansharif irfansharif changed the title [wip,dnm] allocator/storepool: carve out package allocator/storepool: carve out package Apr 15, 2022
@irfansharif irfansharif changed the title allocator/storepool: carve out package allocator/storepool: carve out package from kvserver Apr 15, 2022
@irfansharif irfansharif marked this pull request as ready for review April 15, 2022 07:51
@irfansharif irfansharif requested review from a team as code owners April 15, 2022 07:51
@irfansharif irfansharif removed request for a team April 15, 2022 07:51
@irfansharif irfansharif force-pushed the 220414.allocator branch 2 times, most recently from 232c880 to f73578d Compare April 15, 2022 21:38
@irfansharif irfansharif changed the title allocator/storepool: carve out package from kvserver allocator: carve out a package boundary Apr 16, 2022
This commit tries to pave the way for the allocator itself to be carved
out (storepool probably being a direct dependency, but ideally through
an interface). This commit shamelessly exports any and everything needed
in order for StorePool to sit outside the kvserver package boundary.
It's unfortunate how tangled up this component is, including in tests
(some of which reach deep into inner mutexes and mutate state). We're
not doing anything to improve the status quo other than moving it and
maybe pointing to the awkwardness.

Release note: None
Do the same for kvserver/replicastats, a type that's used as an input
for the allocator at various points (needed to break the dependency
between the allocatorimpl and kvserver). We take the same approach as
the last commit, exporting anything and everything needed to introduce a
hard package boundary.

Release note: None
@irfansharif
Copy link
Copy Markdown
Contributor Author

🍺

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 22, 2022

Build succeeded:

@craig craig bot merged commit 11a0a9f into cockroachdb:master Apr 22, 2022
@irfansharif irfansharif deleted the 220414.allocator branch April 22, 2022 16:54
irfansharif added a commit to irfansharif/cockroach that referenced this pull request Oct 14, 2022
Manual reconstruction of cockroachdb#84863, mostly due to merge conflicts from
\cockroachdb#79991 which will not make it to 22.1. Previously, lease preferences
were not considered when selecting a voter to become the leaseholder
after replica rebalancing. Instead, the voter on the store with the
least QPS was selected. This patch introduces a check to try and satisfy
the lease preference from the rebalanced voting set of replicas, if
possible. Among voters satisfying the preference, the one on a store
with the least QPS is selected to be the leaseholder.

When not possible, where none of the voting replicas satisfy the lease
preference, the store rebalancer will pick the miminum QPS store, as
before.

Release note (bug fix, performance improvement): Previously it was
possible for leases to temporarily move outside of explicitly configured
regions. This often happened during load based-rebalancing, something
CRDB continually does across the cluster. Because of this it was also
possible to observe a continual rate of lease thrashing as leases moved
out of configured zones, triggered rebalancing, induce other leases to
move out of configured zone, while the original set moved back, and so
on. This is now fixed.

Release justification: Bug fix.
irfansharif added a commit to irfansharif/cockroach that referenced this pull request Oct 14, 2022
Manual reconstruction of cockroachdb#84863, mostly due to merge conflicts from
\cockroachdb#79991 which will not make it to 22.1. Previously, lease preferences
were not considered when selecting a voter to become the leaseholder
after replica rebalancing. Instead, the voter on the store with the
least QPS was selected. This patch introduces a check to try and satisfy
the lease preference from the rebalanced voting set of replicas, if
possible. Among voters satisfying the preference, the one on a store
with the least QPS is selected to be the leaseholder.

When not possible, where none of the voting replicas satisfy the lease
preference, the store rebalancer will pick the miminum QPS store, as
before.

Release note (bug fix, performance improvement): Previously it was
possible for leases to temporarily move outside of explicitly configured
regions. This often happened during load based-rebalancing, something
CRDB continually does across the cluster. Because of this it was also
possible to observe a continual rate of lease thrashing as leases moved
out of configured zones, triggered rebalancing, induce other leases to
move out of configured zone, while the original set moved back, and so
on. This is now fixed.

Release justification: Bug fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants