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

Fix classloading deadlock in analysis factories / AnalysisSPILoader initialization #11718

Merged
merged 1 commit into from Aug 25, 2022

Conversation

uschindler
Copy link
Contributor

This fixes #11701 (LUCENE-10665).

@uschindler uschindler added this to the 9.4.0 milestone Aug 24, 2022
@uschindler uschindler self-assigned this Aug 24, 2022
@uschindler
Copy link
Contributor Author

This fix is more or less a copy of the SPI loader code we use in Codec, PostingsFormat, DocValuesFormat,...

The general issue is: Nowhere in Java you should have a static initializer in a superclass that initializes instances of subclasses. This will deadlock if two threads load different subclasses at same time.

See discussions in older issues about this. We had the same issue also with TermsEnum that @danmuzi found.

The problem was not yet visible in Elasticsearch as the analysis factories are not used there in the same way like codecs components. We should still fix this, the issue #11701 was marked as critical.

Copy link
Member

@rmuir rmuir left a comment

Choose a reason for hiding this comment

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

one of these days i hope we can have a static tool to fail the build on cyclic classloading. seems like it should be possible to detect. for now, +1 to the fix, it looks consistent with the other SPIs to me after a quick check.

@uschindler uschindler merged commit 1d54299 into apache:main Aug 25, 2022
asfgit pushed a commit that referenced this pull request Aug 25, 2022
@msokolov msokolov added this to the 9.4.0 milestone Sep 1, 2022
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.

Deadlock in AnalysisSPILoader [LUCENE-10665]
4 participants