Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-16158: Remove server jars from solr-core #1179

Merged
merged 7 commits into from Nov 29, 2022

Conversation

HoustonPutman
Copy link
Contributor

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

  • Move SolrJettyRunner to test framework. Solr-core now no longer has jetty server deps.
    This is a slight back-compat concern, but I'm not sure the SolrJettyRunner is used widely enough for it to warrant keeping this from 9x
  • server/lib/ext now contains the following jars:
    • logging
    • metrics
    • Shared server & core dependencies
  • The web-app is now setup so that "server" jars can be used by the Solr webapp. We no longer have to duplicate these jetty "server" jars between server/lib and WEB-INF/lib.
    This is also a slight back-compat concern, but we are already changing our jetty xml files for the jetty 10 upgrade, so this change is likely ok too.
  • The solr-core & solr-server dependencies now just work, and shouldn't require special setup.

Most of the files are just changing the location of SolrJettyRunner. If you want to see the actual changes here, then just look at the */build.gradle and solr/server/contexts/solr-jetty-context.xml files.

- Move SolrJettyRunner to test framework.
  Solr-core now no longer has jetty server deps.
- server/lib/ext now contains the following jars:
  - logging
  - metrics
  - Shared server & core dependencies
- The web-app is now setup so that "server" jars can be used
  by the Solr webapp. We no longer have to duplicate these
  jetty "server" jars between server/lib and WEB-INF/lib.
- The solr-core & solr-server dependencies now just work, and
  shouldn't require special setup.
Copy link
Contributor

@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.

Nice improvement!

RE back-combat: As long as we mention this in the upgrade notes somewhere -- fine with me.

Comment on lines +9 to +11
<Call name="addServerClassMatcher">
<Arg>
<New id="removeServerClasses" class="org.eclipse.jetty.webapp.ClassMatcher">
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this about?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea agree - would be good to add a comment to why this is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah will definitely add a comment. But here's the gist:

https://www.eclipse.org/jetty/documentation/jetty-9/index.html#jetty-classloading

Jetty protects access to certain "server" classes. You can see the defaults if you scroll down to the "Setting Server Classes" section in the documentation link above. (Annoyingly the same documentation doesn't exist for Jetty 10 or 11, although the functionality is the same, other than a method signature) This means that the webapp cannot use these classes unless they are also provided in the WEB-INF/lib directory as well, meaning that we have to duplicate these jars using the default settings.

However when we add this set of serverClassMatchers, which all start with -, it removes these classes from the protected "server" class definition. This allows us to use the same jars between the jetty server and our webapp.

The documentation doesn't actually give any good reasons why these classes should be protected, or maybe I just missed it. So we can always go back to duplicating the jars, but I think this is probably a better way forward.

Obviously we need some pretty extensive testing to make sure that the setParentLoaderPriority​(true) option doesn't mess with any of our class loader stuff. So far the integration tests, docker tests and unit tests all work so far. But we will definitely need to do some more.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for that explanation; please add a summary as a comment in the XML.
I definitely prefer a solution (like this) that avoids duplicate JARs; I didn't know we were doing that (yuck!).

RE classpath separation (Jetty vs web app), note there is a nasty line in bin/solr when SOLR_SSL_ENABLED:

SOLR_JETTY_CONFIG+=("--module=https" "--lib=$DEFAULT_SERVER_DIR/solr-webapp/webapp/WEB-INF/lib/*")

I recall the original introduction of this was by @markrmiller when I did git history analysis some time ago. I feel we should either not do that, or just give up on the separation -- this is a single-web app server so why separate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RE classpath separation (Jetty vs web app), note there is a nasty line in bin/solr when SOLR_SSL_ENABLED:

I have a sneaking suspicion that isn't necessary, at least anymore. We should try to tackle that in a separate PR though. Would like to not have to test SSL at the same time 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

The doc exist here for jetty 10: https://www.eclipse.org/jetty/documentation/jetty-10/old_docs/index.html#jetty-classloading The note for old docs is "The old Jetty documentation refers to old Jetty versions, and it is currently being ported to the current Jetty version."

Copy link
Contributor

@risdenk risdenk left a comment

Choose a reason for hiding this comment

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

Overall looks good - some minor comments.

solr/server/build.gradle Show resolved Hide resolved
Comment on lines +9 to +11
<Call name="addServerClassMatcher">
<Arg>
<New id="removeServerClasses" class="org.eclipse.jetty.webapp.ClassMatcher">
Copy link
Contributor

Choose a reason for hiding this comment

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

Yea agree - would be good to add a comment to why this is needed?

solr/core/build.gradle Show resolved Hide resolved
Move TestJettySolrRunner to the test-framework module.
@HoustonPutman
Copy link
Contributor Author

Note: the jetty-server jar is in lib/ext even though Solr core/SolrJ should not need it. We can hunt that down in a separate issue though if need be.

Copy link
Contributor

@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.

I think this PR is ready except fixing conflicts & adding a CHANGES.txt.

@HoustonPutman
Copy link
Contributor Author

@dsmiley @risdenk can I get a quick check on my upgrade notes? 1fea79b

Copy link
Contributor

@risdenk risdenk left a comment

Choose a reason for hiding this comment

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

Looks great thanks @HoustonPutman

@dsmiley
Copy link
Contributor

dsmiley commented Nov 29, 2022

The CHANGES.txt text speaks of duplicated JARs but does not mention any. If this was actually a problem in 9.1 (I forget?) then okay -- could you list at least one there? If that was not a released problem (e.g. happened after 9.1) then don't mention it; keep it in the commit notes, though.

@HoustonPutman
Copy link
Contributor Author

Ok listed 2, and expanded a bit in both sections.

@HoustonPutman HoustonPutman merged commit a18f5b3 into apache:main Nov 29, 2022
@HoustonPutman HoustonPutman deleted the remove-server-jars-from-core branch November 29, 2022 23:54
HoustonPutman added a commit that referenced this pull request Nov 30, 2022
- Move SolrJettyRunner to test framework.
  Solr-core now no longer has jetty server deps.
- server/lib/ext now contains the following jars:
  - logging
  - metrics
  - Shared server & core dependencies
- The web-app is now setup so that "server" jars can be used
  by the Solr webapp. We no longer have to duplicate these
  jetty "server" jars between server/lib and WEB-INF/lib.
- The solr-core & solr-server dependencies now just work, and
  shouldn't require special setup.

(cherry picked from commit a18f5b3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants