← Back to Pull requests

SOLR-18277: Restore parent shard state on failed split #4959

Closed
unknown closed this pull request without merging on Oct 05, 2026 10:46 UTC
View on GitHub
unknown unknown commented on Sep 29, 2026 06:26 UTC
Author

🤖 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 SplitShardCmd re-reads the cluster state when it starts (its first step is a forceUpdateCollection), 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 (parent INACTIVE, sub-shards ACTIVE) 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 parent INACTIVE while 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


  • The failed-split cleanup helper now always includes the parent shard, set to ACTIVE, in the cleanup state update it builds, unless its guard sees a committed switch (parent INACTIVE, every sub-shard ACTIVE) 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.

  • Add focused unit coverage and the required SOLR-18277 changelog entry.
  • Proof


    Verified at head 17c0e644812: tidy, Error Prone compile, and :solr:core:check -x test pass.

  • 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. SplitShardCmdCleanupTest does 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 is testFixedCleanupRestoresParentAfterQueuedSuccessSwitch: it replays the Overseer queue order deterministically, applying the queued switch after the state cleanup read, and asserts the parent is restored to ACTIVE. It cannot run on base for the same reason. ShardSplitTest is different: the only change this PR makes to it is removing the two @AwaitsFix annotations, so it compiles and runs against base production code. In three nightly runs of testSplitAfterFailedSplit and testSplitAfterFailedSplit2 against 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 @AwaitsFix from both ShardSplitTest.testSplitAfterFailedSplit and ShardSplitTest.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 to CONSTRUCTION, and the children are then deleted, so updates routed to the children while they were ACTIVE are lost with them. Base code is worse in the same case, because the parent is left INACTIVE with its children deleted. The size of the rollback window was not measured. The cleanup message is now sent every time as well: base sent the updateshardstate update only when something in the state it read needed changing, while this change sends the parent as ACTIVE whenever 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.

    Diff: 509 lines (+381 / -128) across 6 files Reviewer: sigram Review duration: 8899m
    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
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.8% · Safe to merge
    18.8%
    Repository