Repository navigation
Don't cache LibrarySearcher's index wrappers in thread-locals - #9894
Merged
Merged
Conversation
The key and range wrappers for the loaded features index were cached in per-runtime ThreadLocals. Their values stay in every thread that used the runtime after it is torn down, and since StringWrapper is a JRuby class, a pooled thread keeps the class loader that loaded JRuby alive. The wrappers are only used while holding the searcher's lock, so they are now plain fields.
headius
approved these changes
Oct 27, 2026
headius
left a comment
Member
There was a problem hiding this comment.
Good comments to hopefully keep future edits from breaking this synchronization invariant. Approved.
7 of 8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #9781, against
jruby-10.0for the 10.0 LTS line.LibrarySearchercached its key and range wrappers for the loaded features index in per-runtimeThreadLocals. Their values stay in every thread that used the runtime after it is torn down.StringWrapperis a JRuby class, so a pooled thread keeps the class loader that loaded JRuby alive until itsThreadLocalMaphappens to expunge the stale entry.tearDown()can't clear them, becauseThreadLocal.remove()only removes the calling thread's value.They've been thread-locals since 0e7f4d4, before the index was locked; ced903e made all their accessors
synchronizedthree weeks later. The wrappers are only used inside thesynchronizedwithKeyWrapperandwithRangeWrapper, so they are now plain fields. Accesses are serialized by the searcher's lock, as before. A nested call on the same thread shares the wrapper, just as it shared the thread-local one.rake spec:jipasses (974 examples, 0 failures, 9 pending).rake spec:ruby:fasthas 1 failure and 4 errors, all IPv6 socket specs that fail the same way on unmodifiedjruby-10.0, because my machine has no IPv6 network.