nick-boss-tech commented on PR #5108: URL: https://github.com/apache/solr/pull/5108#issuecomment-6429047710
> multi-sharded queries in the reverse direction **TL/DR:** This branch already handles this by reversing the effective sort at both the shards and the coordinator. “First N in reversed order” gives us “last N before the cursor in the original order.” But to be sure I added 2 regression tests. They pass. **Details:** 🤖 *AI text below* 🤖 *(reviewed by Nick Shanin)* @HoustonPutman The follow-up uses the inverse sort for both shard collection and the coordinator's merge queue, so taking the first `rows` under that comparator selects the last `rows` before the cursor in the requested order. [SearchHandler installs the inverse sort](https://github.com/nick-boss-tech/solr/blob/495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java#L455-L465), and [mergeIds uses it for the queue](https://github.com/nick-boss-tech/solr/blob/495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L992-L1020). For an ascending sort, a boundary of 10 and rows=3, shard candidates `[9,6,3]` and `[8,7,5]` merge to `[9,8,7]`. Shards retain that reverse collection order for merging. After selection, [the coordinator reverses the response positions](https://github.com/nick-boss-tech/solr/blob/495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java#L1294-L1371) to present `[7,8,9]` and derive the previous/next cursors from the first/last documents in that order. I added [two deterministic two-shard regressions](https://github.com/nick-boss-tech/solr/blob/495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd/solr/core/src/test/org/apache/solr/cloud/DistribCursorPagingTest.java#L192-L293) for this case, including equal primary sort values across shards. They verify actual shard placement, exact selected IDs, cursor boundaries and round trips, with both single-pass and two-phase fetching. Both pass on seeds `5108C0DE` and `17786C0DE`. As a negative check, restoring only the coordinator's original merge comparator makes both tests select wrong document sets while shard sorting and final response reversal remain intact. Restoring only the coordinator's original unique-key comparison makes the tied test select the wrong set too. The tested head is `495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd`. The cursor/ordering suites pass 18 tests and SolrJ's QueryResponseTest passes 7, all without failures, errors or skips. Error Prone compilation, tidy, and `:solr:core:check :solr:solrj:check -x test` also pass on Linux aarch64 with JDK 21. The additions since the previously offered head are test-only. [Full follow-up diff from your current PR head](https://github.com/nick-boss-tech/solr/compare/32f80171030ca1108cd20292f50232d2729ed930...495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd); [new regression tests since the earlier offer](https://github.com/nick-boss-tech/solr/compare/fde070281383f113a331a9ec5ccde173b66fac3c...495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd). To take the tested continuation onto your PR branch: ```sh git switch cursor-mark-reverse git fetch https://github.com/nick-boss-tech/solr.git solr-17786-reverse-cursor-submit git merge --ff-only 495d3fbdbe07bfb474b43d77b89f8c033bbeb8fd ``` -- 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]
