nick-boss-tech opened a new pull request, #5091: URL: https://github.com/apache/solr/pull/5091
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-14718 ## What happens today **A failed distributed add can be reported with its document already cleared.** The javabin loader uses one add command for every document in a request. It clears that command after each document ([JavabinLoader.java#L105-L123](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/handler/loader/JavabinLoader.java#L105-L123)). A distributed add queues its request with that same command object ([SolrCmdDistributor.java#L241-L264](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L241-L264)). When the failure is handled, the error still points at the cleared command. The log then prints `cmd=add{,id=(null)}` ([error log](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java#L138-L146), [Req.toString](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/ja va/org/apache/solr/update/SolrCmdDistributor.java#L420-L424)). ## What this change does **The request keeps its own copy of the add command, so the error still names the document.** - `distribAdd` copies the command once per call, before it builds the requests. Each request for each node gets that copy ([copy](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L249-L251), [request](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L262)). - The request body is still built from the loader's command, as before ([body](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L252-L256)). - Nothing else changes: what is sent, the retry rules, and the error handling stay the same. ## Proof **The regression test fails on the base code and passes with the change.** - Test class `SolrCmdDistributorTest`, new test [`testFailedAddKeepsItsDocumentWhenTheCommandIsReused`](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/test/org/apache/solr/update/SolrCmdDistributorTest.java#L547-L575). With the copy removed (base production code, this test kept), the gate's premise step fails exactly 1 test. - With this change: `SolrCmdDistributorTest` 1/1 passes. Gate run on 2026-10-07 at head `29c09959791a`. Module check rc=0. ## Limits **With SOLR-5939 in, each request in a failed merged stream is named against its own document.** - Landing order: SOLR-5939 lands before this change. Without it, a failed merged stream names only one request, the one the client was built with. - SOLR-5939 records a failed stream against each request in it, and each request gets its own retry decision ([stream error](https://github.com/nick-boss-tech/solr/blob/f8d4bdbea518901e255ae119f3e5c43e7804a9bf/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java#L155-L169)). This change gives each request the copy of its own document's command, so the error names that document ([copy](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L249-L251)). - Two paths still name one request. A stream that reports none of its members names only the first request in that stream. The Jetty and JDK clients both report their members ([Jetty](https://github.com/nick-boss-tech/solr/blob/f8d4bdbea518901e255ae119f3e5c43e7804a9bf/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/ConcurrentUpdateJettySolrClient.java#L92), [JDK](https://github.com/nick-boss-tech/solr/blob/f8d4bdbea518901e255ae119f3e5c43e7804a9bf/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateJdkSolrClient.java#L40)). An interrupted stream is reported against the request the client was built with ([interrupt](https://github.com/nick-boss-tech/solr/blob/f8d4bdbea518901e255ae119f3e5c43e7804a9bf/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateBaseSolrClient.java#L379-L380), [runner](https://github.com/nick-boss-tech/solr/blob/f8d4bdbea518901e255ae119f3e5c43e7804a9bf/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Concurr entUpdateBaseSolrClient.java#L301-L305)). - Each add request carries one document to one node ([body](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L253-L256)), and each request has its own retry count ([retry count](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L141), [field](https://github.com/nick-boss-tech/solr/blob/29c09959791aea2ee46f7b697e1590d19a48ef1f/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java#L383)). For adds, the retry count is per document per node. - The ticket also describes a second, separate flaw. A follow-up ticket and PR can be opened on request. Changelog: `changelog/unreleased/SOLR-14718-distributor-error-reports-its-document.yml` ### 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]
