nick-boss-tech opened a new pull request, #5073:
URL: https://github.com/apache/solr/pull/5073

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-5754
   
   ## What happens today
   
   **The retry pass reads the errors, then clears the list in a second call. An 
error added in between can be cleared without a retry.**
   
   Before this change, the retry pass copied the live error list and cleared it 
later in the same method. An error added between those two steps was cleared 
unseen. On the paths read in review, that window does not open, so this change 
is hardening, not a fix for a reproduced bug.
   
   ## What this change does
   
   **Errors are read as a snapshot, and the retry pass takes them with one 
atomic drain.**
   
   - `getErrors()` returns a copy taken under the list's lock 
([StreamingSolrClients.java](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java#L61-L66)).
 This is a public behavior change. A caller now gets a snapshot, not the live 
list.
   - `drainErrors()` copies and clears the list in one step under the same lock 
([StreamingSolrClients.java](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java#L68-L75)).
   - The retry pass calls `drainErrors()` 
([SolrCmdDistributor.java](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L107)).
 The later `clearErrors()` call is removed.
   - The `errors` field is package-private and final, so the tests can seed it 
([StreamingSolrClients.java](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java#L51-L52)).
   
   ## Proof
   
   **The combined gate passed on a merged tree. No separate pre-fix proof step 
is recorded for this branch.**
   
   - Combined gate, 2026-10-08, head `7fbe0128d8b0`: GREEN, 26 of 26 tests, on 
a local merge commit of SOLR-5939 and this change, `1ddbf36202d`, whose tree is 
`f2e33340f0ea`.
   - Focused: `TestTolerantUpdateProcessorCloud` 19/19 and 
`TestTolerantUpdateProcessorRandomCloud` 2/2. Module check passed.
   - The live tip `46b919e2d4e8` removes the root `SOLR-5754-TESTING.md` file 
only. No re-gate was run for that removal.
   - 
[StreamingSolrClientsTest](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/test/org/apache/solr/update/StreamingSolrClientsTest.java#L40-L73)
 has `testGetErrorsIsASnapshot` and `testDrainErrorsReturnsAndClears`. No run 
count is recorded for this class. It skips itself when Mockito cannot mock 
([L29-L32](https://github.com/nick-boss-tech/solr/blob/46b919e2d4e8bc287ac913edb789c21509e1b215/solr/core/src/test/org/apache/solr/update/StreamingSolrClientsTest.java#L29-L32)).
   
   ## Limits
   
   **This is hardening. The race is not reproduced, and the tests are 
single-threaded.**
   
   - On the paths read, no runner thread adds an error during the retry window. 
This was checked by reading, not by a run.
   - The tests check snapshot and drain behavior. They do not exercise the 
concurrent window.
   - `clearErrors()` stays public and has no caller in main code. This change 
does not remove it.
   - SOLR-5939 changes the same two files. The textual merge is clean, and the 
proof above covers the merged tree.
   
   Changelog: 
`changelog/unreleased/SOLR-5754-streaming-clients-error-snapshot.yml` (type: 
changed).
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. Nick 
Shanin directed the work and takes responsibility for this contribution.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to