← Back to Pull requests

SOLR-6973: A partial update with no signature fields no longer gets an empty signature, which can delete unrelated documents #5079

Open
nick-boss-tech opened this pull request with 65 lines diff across 3 files
View on GitHub
nick-boss-tech nick-boss-tech commented on Oct 09, 2026 20:31 UTC
Author

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

https://issues.apache.org/jira/browse/SOLR-6973

What happens today

With overwriteDupes, a partial update with no signature fields can delete unrelated documents.

With a fields list, the processor's loop throws only if a signature field is present in the partial update. A partial update that sets other fields passes the loop with an empty signature. The processor writes that signature to signatureField and sets updateTerm to it (SignatureUpdateProcessorFactory.java). updateDocuments deletes every document that matches updateTerm (DirectUpdateHandler2.java).

What this change does

A partial update with no signature fields skips the signature step.

It goes to the next processor unchanged. Partial updates with a signature field still fail, and requests without fields still reject partial updates (SignatureUpdateProcessorFactory.java).

Behavior change: a partial update that creates a new document now stores it without signatureField. The old code gave it the shared empty signature, which caused the collision.

Proof

The new test fails on the base code and passes with this change.

The test is SignatureUpdateProcessorFactoryTest.java. It checks that signatureField is absent and updateTerm is null. On the base production code, the same class ran 7 tests with 1 failure. The failure is the new test: the base code sets both values it checks for absence.

With this change, the focused SignatureUpdateProcessorFactoryTest ran 7 of 7, verified 2026-10-09 at head 51fcd05e695. The head includes a review fix that decides the partial-update outcome before the signature class is constructed; the same 7 tests and the same base failure were re-verified at that head. The core module checks also pass.

A choice to check

The update passes through. The other option is to reject it.

The no-fields setup already rejects partial updates with an error. This change passes them through, so the update works and no signature is stored. Rejecting would make the failure visible but would stop the update. Was pass-through the right call?

Limits

The reporter's 5% symptom is not shown to come from this path.

The ticket comments suggest shard routing. This change removes one collision path. It does not show that the path explains the report. The effect on new documents was checked by reading only. A follow-up submission is planned if the shard-routing path is confirmed as the cause of the reported symptom.

Changelog: changelog/unreleased/SOLR-6973-signature-partial-update.yml

AI assistance

AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution.

Diff: 65 lines (+58 / -7) across 3 files Reviewer: janhoy Review duration: 71807m
All Vouch review confidence checks passed
Residual risk 0.07 = Change Risk (0.38) × (1 − Review Confidence (0.82)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.38 · 65 lines diff across 3 files
0.38
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.76 · 2 substantive comment(s)
0.76
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
81%
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.251
Real PR Conversation Timeline
5 items
Copilot Copilot commented on code on Oct 09, 2026 23:59 UTC
Code Review
solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java:1
@@ -188,6 +188,12 @@ public void processAdd(AddUpdateCommand cmd) throws IOException {
           }
         }
 
+        if (isPartialUpdate) {
+          // none of the signature fields are in the partial update, so there is nothing to sign;
+          // an empty signature would overwrite or delete unrelated documents
+          if (next != null) next.processAdd(cmd);
+          return;

This guard is reached only after newInstance(signatureClass, ...) and sig.init(params), so a partial update that contains none of the configured signature fields still constructs and initializes the configured Signature implementation. A custom implementation can perform expensive work or throw from init, which contradicts the stated pass-through behavior; determine that no signature field is present and return to next before constructing/initializing sig.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 09, 2026 23:59 UTC
Reviewer

<!-- ccr-overview-v2 -->

🟡 Changes recommended

Determine whether a signature field is present before constructing and initializing the signature implementation.

<details open>
<summary><strong>1 open finding</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Avoid constructing signature when no signature fields are present · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    This pull request prevents partial updates without signature fields from generating an empty deduplication signature.

    Changes:

  • Bypasses signature generation for unaffected partial updates.

  • Adds regression coverage.

  • Adds a SOLR-6973 changelog entry.
  • | File | Description |
    |---|---|
    | solr/​core/​src/​test/​org/​apache/​solr/​update/​processor/​SignatureUpdateProcessorFactoryTest.java | Verifies pass-through behavior without a signature or update term. |
    | solr/​core/​src/​java/​org/​apache/​solr/​update/​processor/​SignatureUpdateProcessorFactory.java | Skips signature assignment for eligible partial updates. |
    | changelog/​unreleased/​SOLR-6973-signature-partial-update.yml | Documents the fix. |
    </details>

    🧠 Review effort: Lite

    ---

    💡 <a href="/apache/solr/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    nick-boss-tech nick-boss-tech commented on code on Oct 10, 2026 00:07 UTC
    Code Review
    solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java:1
    @@ -188,6 +188,12 @@ public void processAdd(AddUpdateCommand cmd) throws IOException {
               }
             }
     
    +        if (isPartialUpdate) {
    +          // none of the signature fields are in the partial update, so there is nothing to sign;
    +          // an empty signature would overwrite or delete unrelated documents
    +          if (next != null) next.processAdd(cmd);
    +          return;

    Done.

    janhoy janhoy approved these changes on Oct 10, 2026 11:01 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    nick-boss-tech nick-boss-tech
    Labels
    risk: low confidence: 81.9% 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: 38.0% (MEDIUM) · Higher = larger blast radius
    38.0%
    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: 81.9% · Lower = rushed or shallow review
    81.9%
    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: 6.9% · Safe to merge
    6.9%
    Repository