nick-boss-tech opened a new pull request, #5146: URL: https://github.com/apache/solr/pull/5146
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-8939 ## What happens today **A date unique key loses its milliseconds when the coordinator asks the shards for stored fields.** A distributed query sends each hit's unique key back to the shards in the `ids` parameter. For a date key, the code wrote the value with `Date.toString()`, which has no milliseconds. The shard then gets a value that no longer matches the stored key, so a hit can be missing or an error can follow. The ticket reports both symptoms. ## What this change does **Date keys are sent as ISO-8601 text with milliseconds, on the plain and the grouping stored-fields paths.** - A new helper, `QueryComponent.idToString`, formats a `Date` with `Instant.toString()`. Other key types still use `toString()` ([QueryComponent.java L1453-L1462](https://github.com/nick-boss-tech/solr/blob/a855a2d8965c8eae5df171ad9b5148b7e95f7425/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L1453-L1462)). - The plain path calls the helper when it builds the `ids` parameter ([L1443-L1447](https://github.com/nick-boss-tech/solr/blob/a855a2d8965c8eae5df171ad9b5148b7e95f7425/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L1443-L1447)). - The grouping path calls it too ([StoredFieldsShardRequestFactory.java L79](https://github.com/nick-boss-tech/solr/blob/a855a2d8965c8eae5df171ad9b5148b7e95f7425/solr/core/src/java/org/apache/solr/search/grouping/distributed/requestfactory/StoredFieldsShardRequestFactory.java#L79)). ## Proof **The date test fails on the base code and passes with this change.** - `StoredFieldsShardRequestFactoryTest` 2 of 2 pass at `a855a2d8965c8eae5df171ad9b5148b7e95f7425`, recorded 2026-10-06. On the base code, `testDateUniqueKeyIsSentAsIsoWithMilliseconds` fails. The string-key test passes on both. - `QueryComponentIdFormatTest` 2 of 2 pass at this head. It calls the new helper directly, so it does not compile on the base code and gives no failing-before result. - The proof is at unit level. No run with two or more shards was made. ## Limits **The proof is at unit level only: no run uses two or more shards, and a date with zero milliseconds is not tested.** - No run with two or more shards. The plain path is covered through the helper it calls, not by a run through the coordinator. - A date with zero milliseconds is sent without a fraction, for example `2016-03-21T10:15:30Z`. The tests cover a value with milliseconds only. - `idToString` is public because the grouping request factory is in another package. Changelog: [changelog/unreleased/SOLR-8939-date-unique-key-millis.yml](https://github.com/nick-boss-tech/solr/blob/a855a2d8965c8eae5df171ad9b5148b7e95f7425/changelog/unreleased/SOLR-8939-date-unique-key-millis.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]
