Skip to content

SOLR-17982: setForcedDistrib & SearchHandler refactor#3931

Merged
dsmiley merged 1 commit intoapache:mainfrom
dsmiley:SOLR-17982-refactorSearchHandlerForcedDistrib
Dec 17, 2025
Merged

SOLR-17982: setForcedDistrib & SearchHandler refactor#3931
dsmiley merged 1 commit intoapache:mainfrom
dsmiley:SOLR-17982-refactorSearchHandlerForcedDistrib

Conversation

@dsmiley
Copy link
Contributor

@dsmiley dsmiley commented Dec 9, 2025

Provide an internal API to force distributed search (even when one shard). Also, refactor/reorganize SearchHandler for clarity & extensibility.

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

(split off from SOLR-17319 / #3418 )
CC @ercsonusharma

Provide an internal API to force distributed search (even when one shard).
Also, refactor/reorganize SearchHandler for clarity & extensibility.
Copy link
Contributor Author

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no test here but one will show up in #3418

}

@Override
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this up high and moved some other methods to read in a more natural ordering in breadth-first way from top to bottom.

boolean isZkAware = req.getCoreContainer().isZooKeeperAware();
boolean isDistrib = req.getParams().getBool(DISTRIB, isZkAware);
protected boolean isDistrib(SolrQueryRequest req, ResponseBuilder rb) {
boolean theDefault = req.getCoreContainer().isZooKeeperAware() || rb.isForcedDistrib();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change allows a component using setForcedDistrib to also be a condition for distrib becoming true, which is relevant in standalone. But as I look at this again... I now question the decision. Arguably, it's nicer to keep the story of standalone consistent to be distrib is by default false in standalone mode and not in SolrCloud. No exceptions. Such components which can only work in a distributed mode could throw an exception 400, saying distrib must be enabled (since that's how standalone mode works). To better support that, isDistrib could be initialized first thing in handleRequestBody. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it as it is here. It's an invisible matter to a user -- conceptually the request remains not distributed in the sense that no other server is involved processing the request.

}
}

private void processComponents(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method method was way too long and clearly had 2 implementations

final ModifiableSolrParams params = new ModifiableSolrParams(p);

// TODO: look into why passing true causes fails
params.set("distrib", "false");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think an explicit value should have been passed to the control client. I made this change to help the tests in the other PR work when standalone was being tested, in which distrib has a different default based on setForcedDistrib

true makes no sense here to me -- I don't get the TODO above it.

But if we don't accept the change in the first rev of this PR that changes the default distrib value, then maybe we don't need this either. This could go in the other PR.

@dsmiley
Copy link
Contributor Author

dsmiley commented Dec 14, 2025

I'm going to merge this in a couple days or so. I tagged you @cpoerschke as I thought you might find the extensibility in SearchHandler interesting/useful (as you have worked on this in the past maybe) but a refactoring like this is hard to review.

@dsmiley dsmiley merged commit 5c9cab2 into apache:main Dec 17, 2025
5 checks passed
@dsmiley dsmiley deleted the SOLR-17982-refactorSearchHandlerForcedDistrib branch December 17, 2025 04:56
dsmiley added a commit that referenced this pull request Dec 17, 2025
Provide an internal API to force distributed search (even when one shard).
Also, refactor/reorganize SearchHandler for clarity & extensibility.

(cherry picked from commit 5c9cab2)
dsmiley added a commit that referenced this pull request Dec 18, 2025
Provide an internal API to force distributed search (even when one shard).

(cherry picked from commit 5c9cab2)
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