Skip to content

SOLR-8009: An unrouted id on an implicit-router collection is now sent to every shard - #5141

Open
nick-boss-tech wants to merge 8 commits into
apache:mainfrom
nick-boss-tech:solr-8009-submit
Open

nick-boss-tech wants to merge 8 commits into
apache:mainfrom
nick-boss-tech:solr-8009-submit

Conversation

@nick-boss-tech

@nick-boss-tech nick-boss-tech commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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

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

What happens today

A real-time get with no _route_ finds nothing on an implicit-router collection, even when the document is stored.

On a collection that uses the implicit router, /get?id=<id> with no _route_ and no shards parameter returns no document. The distributed path in RealTimeGetComponent.createSubRequests asks the router for a slice for each id. The implicit router returns no slice when there is no route, and the code skips the id (base code). The Jira report describes a NullPointerException on an older release. On this base the request returns an empty result with no error.

What this change does

An unrouted id on an implicit-router collection is now sent to every shard.

Proof

FullSolrCloudDistribCmdsTest.testRealTimeGetImplicitRouterWithoutRoute fails on the base code and passes with this change.

  • The new test builds a two-shard implicit collection, adds one document to each shard, and checks a get by one id and a get by two ids with no route, checks the titles of the returned documents, and checks that a get routed to the other shard returns nothing (FullSolrCloudDistribCmdsTest.java). On the base commit 14c7aac0d15, the first assertNotNull fails because the get returns nothing.
  • Verified 2026-10-15 at head e600375aaee3: FullSolrCloudDistribCmdsTest 10 of 10; TestRealTimeGet 4 of 4; TestRandomFlRTGCloud 2 of 2; TestAddFieldRealTimeGet 1 of 1. All pass. The class also passes at the previous head 8795661ddc98 with these tests, because a route naming a real shard resolves to that shard there as well; the base-code failure above is what the change is measured against.

A choice to check

An unrouted get on an implicit collection fans out to every shard. The other option was to fail it.

  • Implemented: fan out, so the document is found wherever it is. The cost is one request to each shard for every unrouted get, which is slower than a routed get.
  • Alternative: return a 400 that asks the caller to send _route_ or shards. Callers that now get an empty result would get an error instead.

Was fanning out the right call here, or should an unrouted get fail?

Limits

Duplicate results and compositeId collections with no route are not fixed here, and two cases have no test.

  • An id that sits on more than one shard can come back more than once in a get by several ids. The existing shards form does the same, as SOLR-8954 reports. This change does not fix it.
  • A get by one id whose document sits on two shards is not tested.
  • A compositeId collection with a router field and no _route_ still returns nothing, as before. I can open a follow-up ticket and PR for those on request.
  • A get with a _route_ that names no slice of the collection is not tested. That is the one case where the new no-route condition changes the outcome: without it the id would be sent to every shard.
  • No test covers a shard that has no live replica during the fan-out.

Changelog: changelog/unreleased/SOLR-8009-rtg-implicit-router.yml

AI assistance

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

Hypothetical, unrun regression test; see SOLR-8009-TESTING.md.
…icit router

The fallback fired for any router that returns no target slice. A
compositeId router with a router field also returns null when no
_route_ is given, and there returning no documents is deliberate:
testRTGCompositeRouterWithRouterField pins it. Only the implicit
router has no routing information at all in that case, so only its
unrouted ids are searched on all shards.
@nick-boss-tech
nick-boss-tech marked this pull request as ready for review October 16, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant