Skip to content

[release-2.16] vitessshard: compute Idle when the shard record is missing (#831) - #851

Merged
mcrauwel merged 2 commits into
release-2.16from
cursor/backport-831-release-2.16-dco-e2b2
Oct 26, 2026
Merged

mcrauwel merged 2 commits into
release-2.16from
cursor/backport-831-release-2.16-dco-e2b2

Conversation

@mcrauwel

@mcrauwel mcrauwel commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Backport of #831 onto release-2.16 (operator v2.16.* / Vitess v23).

Fixes #830 for the v2.16 release line.

This is the full #831 change, including the review follow-ups:

  • compute Idle from serving partitions when GetShard returns NoNode
  • leave HasMaster / ServingWrites Unknown without a shard record
  • require a readable keyspace record before trusting a missing shard record
  • observe every enumerated cell (CellInfo first) before declaring a record-less shard idle

Cherry-pick applied cleanly; reconcile_topo.go on this branch matched the pre-#831 main version. The e2e helper is inserted before checkPodStatusWithTimeout because waitForScheduledRolloutsToFinish does not exist on this line.

Unit tests passed locally:

  • TestReconcileTopologyIdleWithoutShardRecord (all 7 subtests)
  • TestReadyForPrimaryHasMasterUnknown

Note: DCO-signed replacement for #849 (force-push blocked by repo ruleset).

…sing

Backport of #831 onto release-2.16 so a missing shard record after
Reshard complete still computes Idle from serving partitions.

Signed-off-by: Matthias Crauwels <matthias.crauwels@planetscale.com>
@mcrauwel
mcrauwel marked this pull request as ready for review October 22, 2026 15:35
@mattlord
mattlord requested review from arthurschreiber, mattlord and mhamza15 and a balanced review from Copilot October 22, 2026 15:37

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.

🟡 Changes recommended

A deployed cell disappearing from topology enumeration can allow shard deletion without verifying that cell’s serving references.

1 open issue
What changed in this PR

Backports the shard-cleanup fix to release-2.16 so obsolete shards can become idle after Reshard complete removes their topology records.

Changes:

  • Compute idleness from serving topology when a shard record is missing, while keeping primary-related status unknown.
  • Require readable keyspace and cell information before allowing cleanup.
  • Add regression tests and delay end-to-end cleanup until the controller observes the missing record.
File Description
test/​endtoend/​utils.sh Adds a shard-status polling helper.
test/​endtoend/​upgrade_test.sh Waits for missing-record observation before removing old partitioning.
pkg/​controller/​vitessshardreplication/​init_shard_primary_test.go Tests that unknown primary status blocks initialization.
pkg/​controller/​vitessshard/​reconcile_topo.go Adds missing-record idleness checks against serving topology.
pkg/​controller/​vitessshard/​reconcile_topo_test.go Tests cleanup, repeated reconciliations, and topology-read failures.

Review effort: Balanced

// first. Only a cell that exists but has no SrvKeyspace for this keyspace
// counts as not serving.
func shardServingCells(ctx context.Context, ts *topo.Server, keyspace, shard string) ([]string, error) {
cells, err := ts.GetCellInfoNames(ctx)

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.

This is valid, but it is not specific to this backport: the code is identical on main and release-2.17, and the path where the shard record still exists has the same gap via GetShardServingCells, which predates #831. I reproduced it on both paths with memorytopo. To keep this backport identical to #831, the fix will go to main first and then be backported. Tracking it in #863.

@mattlord mattlord changed the title [release-2.16] vitessshard: compute Idle when the shard record is missing [release-2.16] vitessshard: compute Idle when the shard record is missing (#831) Oct 22, 2026
@mcrauwel
mcrauwel merged commit 91dcf37 into release-2.16 Oct 26, 2026
11 checks passed
@mcrauwel
mcrauwel deleted the cursor/backport-831-release-2.16-dco-e2b2 branch October 26, 2026 08:12
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.

4 participants