SOLR-18277: Restore parent shard state on failed split #4959
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 509 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4959"
general
weight: 0.35
sigram
🤖 AI text below 🤖 (posted on behalf of Nick Shanin)
https://issues.apache.org/jira/browse/SOLR-18277
What happens today
When a shard split fails, the failed-split cleanup in
SplitShardCmdre-reads the cluster state when it starts (its first step is aforceUpdateCollection), but that read cannot see a shard-state switch that is queued at the Overseer and not yet applied. With a replication factor of 1, the split command queues the switch itself (parentINACTIVE, sub-shardsACTIVE) before creating the replica cores, and the failure comes later in the same call, so the switch can be applied after cleanup has taken its read. Cleanup can then leave the parentINACTIVEwhile its sub-shards are deleted, leaving the shard range with no active shard. With a replication factor above 1 the switch is queued later by the Overseer, a second way for a switch to be in flight when cleanup reads.What this change does
ACTIVE, in the cleanup state update it builds, unless its guard sees a committed switch (parentINACTIVE, every sub-shardACTIVE) in the state it read. A switch queued at the Overseer but not yet applied at that read is therefore rolled back rather than missed.Proof
Verified at head 17c0e644812: tidy, Error Prone compile, and
:solr:core:check -x testpass.SplitShardCmdCleanupTest: 5 of 5 pass.ShardSplitTest: the whole class is nightly-gated, so a plain run skips all 11 tests. With-Dtests.nightly=true, all 11 tests pass with 0 failures.A pre-fix comparison splits by test class.
SplitShardCmdCleanupTestdoes not compile against the base production code, because it calls the cleanup helper this PR adds, so that class has no fail-on-base run. The evidence for the fix in that class istestFixedCleanupRestoresParentAfterQueuedSuccessSwitch: it replays the Overseer queue order deterministically, applying the queued switch after the state cleanup read, and asserts the parent is restored toACTIVE. It cannot run on base for the same reason.ShardSplitTestis different: the only change this PR makes to it is removing the two@AwaitsFixannotations, so it compiles and runs against base production code. In three nightly runs oftestSplitAfterFailedSplitandtestSplitAfterFailedSplit2against base production code, both tests passed every time; the failure the ticket reports is a race, and it did not reproduce in those three attempts. At this head, the same two methods were also run nightly with five iterations each (10 executions) and all passed. Those repeated runs are a regression check, not evidence for the fix: the race did not reproduce on base either, so clean runs at head do not separate fixed from unfixed; they show only that the change does not make the two tests fail.This PR removes
@AwaitsFixfrom bothShardSplitTest.testSplitAfterFailedSplitandShardSplitTest.testSplitAfterFailedSplit2; both tests execute in the nightly run above. This was a class-only run, not the full Solr nightly suite.Limits
In the stale-snapshot case this cleanup rolls back a switch queued by a split that then failed: the parent goes back to
ACTIVE, the children go back toCONSTRUCTION, and the children are then deleted, so updates routed to the children while they wereACTIVEare lost with them. Base code is worse in the same case, because the parent is leftINACTIVEwith its children deleted. The size of the rollback window was not measured. The cleanup message is now sent every time as well: base sent theupdateshardstateupdate only when something in the state it read needed changing, while this change sends the parent asACTIVEwhenever the cleanup's guard does not fire, including when the parent was never deactivated.AI assistance
AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution.