-
Notifications
You must be signed in to change notification settings - Fork 3k
Fixed context classloader of threads in ThreadPools #3797
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
Conversation
|
@yittg can you please explain what this is doing and why it is the correct behavior? |
|
@rdblue The context of thread in ThreadPool inherited from the parent thread. For the first task of one thread, the parent thread is current thread that executes the task, so the context is consistent with where the task is executed. As of the second and following tasks, the context of the existing thread running the task is still the one that started the thread, which can be different from the one that executed the task. And this can cause the context class loader issue described in #3776 . For example:
This change records the context that executes one task in the wrapper Runnable, and sets it to the target thread before actually running the task. This can make sure the consistency of the context. |
|
@rdblue Do you think this make sense? Or what do you think? |
|
@yittg, I'm skeptical that this is the right approach. The dynamic class loader allows you to specify the classloader to use. It is generally better to specify the correct one instead of relying on the context loader. In this case, it looks like the reader used to load the file's key-value metadata doesn't have the class loader set like the reader used to scan the manifest. I would first try setting the class loader the same way. |
@rdblue It's also my first choice, FYI #3776 (comment), but it's not enough, as described in my comment, you can not pass the correct one to all cases in the dependencies.
IMO, the right way is not to use the static shared thread pool. But it's hard to fix here, the shared pool is involved in too many places. So i choose this quick fix to walk around it. |
|
@rdblue I think it's also ok to set the correct placeholder in iceberg, i can open another PR to address it, then the issue can be fixed in those scenarios not touching the same issue in third-party dependencies. Then we can think about how to fix it thoroughly. What do you think? |
|
@yittg, let's get the fix for manifest file reading in and then address the next issue. I think that we should not be relying on the context classloader when loading dynamically. |
a0cd199 to
9f9b80c
Compare
9f9b80c to
b1c82f1
Compare
|
@rdblue i updated changes with fixed context class loader. looks like ci failed accidentally, |
|
close this one due to prefer #4177 |
Fixes #3776