-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 the race condition of reflection scanning classes #9167
Fix the race condition of reflection scanning classes #9167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
} | ||
} | ||
|
||
/** | ||
* Due to the multi-threading issue in org.reflections.vfs.ZipDir, we need to put a lock before calling the | ||
* reflection related methods. | ||
* | ||
* @return | ||
*/ | ||
public static Object getReflectionLock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer needed i think or change the synchronize block above to also acquire via this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to wrap the setup of swagger. Added runWithLock()
as @klsince suggested, and deprecated this one
} | ||
} | ||
|
||
/** | ||
* Due to the multi-threading issue in org.reflections.vfs.ZipDir, we need to put a lock before calling the | ||
* reflection related methods. | ||
* | ||
* @return | ||
*/ | ||
public static Object getReflectionLock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instead of return lock, may do
runWithLock(Runnable r) {
sync(lock) {
r.run()
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
1882325
to
ba9d4e4
Compare
Codecov Report
@@ Coverage Diff @@
## master #9167 +/- ##
============================================
- Coverage 69.99% 69.97% -0.03%
- Complexity 4682 4757 +75
============================================
Files 1848 1847 -1
Lines 98572 98541 -31
Branches 14967 14963 -4
============================================
- Hits 68999 68951 -48
- Misses 24723 24753 +30
+ Partials 4850 4837 -13
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
we need to cherry-pick this back to release 0.11 branch |
In #5446, we introduced reflection lock to solve the race condition of reflection library scanning the same jar from multiple threads (more details can be found in #5531).
Some new added reflection-based modules (
SegmentLoader
,Tuner
) didn't protect the reflection with lock. This PR enhances thePinotReflectionUtils
to support more use cases, and move the new modules to use it.