Repository navigation
[release-2.16] vitessshard: compute Idle when the shard record is missing (#831) - #851
Conversation
…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>
There was a problem hiding this comment.
🟡 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) |
There was a problem hiding this comment.
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.

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:
Idlefrom serving partitions whenGetShardreturnsNoNodeHasMaster/ServingWritesUnknownwithout a shard recordCherry-pick applied cleanly;
reconcile_topo.goon this branch matched the pre-#831 main version. The e2e helper is inserted beforecheckPodStatusWithTimeoutbecausewaitForScheduledRolloutsToFinishdoes not exist on this line.Unit tests passed locally:
TestReconcileTopologyIdleWithoutShardRecord(all 7 subtests)TestReadyForPrimaryHasMasterUnknownNote: DCO-signed replacement for #849 (force-push blocked by repo ruleset).