Skip to content

Allow multiple tablet pools of the same type - #800

Open
absolutejam wants to merge 1 commit into
planetscale:mainfrom
absolutejam:multiple-tabletpool-support
Open

Allow multiple tablet pools of the same type#800
absolutejam wants to merge 1 commit into
planetscale:mainfrom
absolutejam:multiple-tabletpool-support

Conversation

@absolutejam

Copy link
Copy Markdown
Contributor

Removes the external data store requirement for multiple tabletpools.

Also adds --default_pool_names flag which can optionally be supplied to keep backwards compatible behaviour for the specified pools.

@absolutejam

absolutejam commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

I didn't use table driven tests because I didn't see them used elsewhere and the coverage is only rudimentary, but the tests passed for me and I've deployed this fork into our internal Vitess clusters.

In our environments, I have also leveraged the --default_pool_names on our initial replica tablet pool (called default), so that it didn't churn UIDs (notably the PVCs).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates tablet UID generation so multiple tablet pools can share the same (cell, type) without requiring ExternalDatastore, and introduces a compatibility flag (--default_pool_names) to preserve existing tablet UIDs during migrations.

Changes:

  • Add --default_pool_names operator flag and helpers for treating certain pool names as “unnamed” during UID generation.
  • Generate name-aware tablet UIDs for non-default named pools, independent of ExternalDatastore.
  • Add unit tests covering UID behavior for default vs non-default pool names and mixed pools in the same (cell, type).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
pkg/operator/environment/environment.go Adds --default_pool_names flag and helpers to control backward-compatible UID generation.
pkg/controller/vitessshard/reconcile_tablets.go Updates UID generation logic to use pool names (except configured defaults) and adjusts pool-name labeling behavior.
pkg/controller/vitessshard/reconcile_tablets_test.go Adds tests validating UID stability for default pool names and uniqueness across multiple pools.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 303 to 305
if 0 < len(pool.Name) {
labels[planetscalev2.TabletPoolNameLabel] = pool.Name
}
Comment on lines +288 to +290
// If TabletPools has multiple pools within the same (cell,type) pair, we need to add a pool name to the UID generator.
if pool.ExternalDatastore != nil && 0 < len(pool.Name) {
// Pool names listed in --default_pool_names are treated as unnamed to preserve existing tablet UIDs.
if 0 < len(pool.Name) && !environment.IsDefaultPoolName(pool.Name) {
Comment on lines +29 to +30
// tabletsForPool returns the tablet specs belonging to the named pool, using
// the pool-name label that vttabletSpecs stamps on every tablet.
Comment thread pkg/operator/environment/environment.go Outdated
Comment on lines +82 to +84
func SetDefaultPoolNames(names []string) {
defaultPoolNames = names
}

@mattlord mattlord left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, @absolutejam ! ❤️ There are a few things that I think we should try and address before merging (sometimes it can be resolved in a discussion vs code changes).

I think that it's worth guarding against default-pool UID collisions in pkg/controller/vitessshard/reconcile_tablets.go:286. The new --default_pool_names behavior can make two pools in the same (cell,type) both use the legacy unnamed UID path. For example, an unnamed pool plus a default-named pool, or two named pools both listed in --default_pool_names, will generate the same tablet UIDs for the same indexes. That seems like it can make the desired tablet map overwrite one pool with the other, reusing the same pod/PVC/tablet alias identity. I think we should reject or otherwise prevent more than one “legacy UID” pool per (cell,type), and add a regression test for that case.

I think that we should Include the pool name in “same pool” anti-affinity labels in pkg/operator/vttablet/spec.go:67. Named local pools can now represent distinct pools with the same cell/type, but poolLabels() still does not include TabletPoolNameLabel. That means the default anti-affinity that is described as applying to the “same exact pool” still groups separate named pools together. I think we should include the pool name label there when present so scheduling behavior matches the new pool identity model.

We will need to update the API/CRD wording for named local pools
in pkg/apis/planetscale/v2/vitessshard_types.go:147
pkg/apis/planetscale/v2/labels.go:39. The Name field comment still says a pool name requires ExternalDatastore, and the pool-name label comment still says it applies to Vitess-unmanaged keyspaces. Since this PR intentionally supports named local pools, I think we should update those comments and regenerate any CRD descriptions derived from them so users do not think the new configuration is unsupported.

Side note, the DCO is currently failing on the PR. If you click on that failed workflow it will give you precise instructions for how to fix it.

@absolutejam
absolutejam force-pushed the multiple-tabletpool-support branch 4 times, most recently from 65c5463 to 3c031ad Compare July 8, 2026 07:08
@absolutejam

Copy link
Copy Markdown
Contributor Author

Thanks for the thoughtful comments @mattlord - I think adding a guard for UID collisions is the right move.

I've updated the documentation now and restricted --default_pool_name to a single default pool as allowing multiple didn't really provide any benefit other than potentially allowing UID collisions. I also added some additional tests and a run-time guard too.

Signed-off-by: James Booth <james@absolutejam.co.uk>
@absolutejam
absolutejam force-pushed the multiple-tabletpool-support branch from 2a78a15 to fb9f668 Compare July 13, 2026 07:58
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