-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Functions] Fix classloader leaks #12973
[Functions] Fix classloader leaks #12973
Conversation
...-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/SourcesImpl.java
Outdated
Show resolved
Hide resolved
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
@lhotari the lines that actually changed in pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionCommon.java doesn't seem as much as git is displaying. Is there formatting issue? It is hard to see which lines actually changed. |
@jerrypeng I don't seem to have that issue in the GitHub Web UI. The diff shows the changes. Which diff tool are you using? |
@lhotari I am just using the github Web UI. In FunctionCommon.java is it all that you added was a try / finally that wraps the the existing code in getClassLoaderFromPackage method? |
@jerrypeng Now I see what you mean. Yes the diff is pretty hard to read. Yes, I wrapped with another try catch where the finally block is
|
besides the finally block, I added the lines to set |
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.
@lhotari this LGTM but can you add some unit tests for this?
@jerrypeng Thanks for reviewing. I can add tests, but the barrier for that is that it feels hard to unit test classloader leaks. Can you recommend an approach for this particular case? |
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
adding tests is hard in this case.
I am not sure about how to do it.
hooking into Class loading is hard and also it will probably depend on the JVM/Java version.
We could count the calls to "ClassLoaderUtils.closeClassLoader" using PowerMock, but I am not sure it is worth
* Fix classloader leak in FunctionCommon.getClassLoaderFromPackage * Fix classloader leak in SinksImpl and SourcesImpl * Fix logic for shouldCloseClassLoader (cherry picked from commit cab946b)
* Fix classloader leak in FunctionCommon.getClassLoaderFromPackage * Fix classloader leak in SinksImpl and SourcesImpl * Fix logic for shouldCloseClassLoader (cherry picked from commit cab946b)
* Fix classloader leak in FunctionCommon.getClassLoaderFromPackage * Fix classloader leak in SinksImpl and SourcesImpl * Fix logic for shouldCloseClassLoader (cherry picked from commit cab946b)
* Fix classloader leak in FunctionCommon.getClassLoaderFromPackage * Fix classloader leak in SinksImpl and SourcesImpl * Fix logic for shouldCloseClassLoader
Motivation
While investigating error code 143 problems in DataStax Pulsar Helm Chart CI, I noticed that some classloaders are leaked.
Modifications
Documentation
no-need-doc