Use plugin class loader for the operations of IcebergPageSource#13078
Use plugin class loader for the operations of IcebergPageSource#13078findepi merged 2 commits intotrinodb:masterfrom
IcebergPageSource#13078Conversation
plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergPageSourceProvider.java
Outdated
Show resolved
Hide resolved
losipiuk
left a comment
There was a problem hiding this comment.
Generally LGTM but should you change the tests which expose the problem you are fixing.
There was a problem hiding this comment.
Do you need to wrap internal method calls or would just this be enough:
Supplier<ConnectorPageSink> positionDeleteSink = () -> {
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
// Make sure we are using the PluginClassLoader when initialising and using the sink instance
return new IcebergPositionDeletePageSink(
split.getPath(),
partitionSpec,
partition,
locationProvider,
fileWriterFactory,
hdfsEnvironment,
hdfsContext,
jsonCodec,
session,
split.getFileFormat(),
table.getStorageProperties(),
split.getFileRecordCount());
};
The alternative mathces what we do in ClassLoaderSafeConnectorPageSourceProvider
There was a problem hiding this comment.
I think it is enough to either do try/catch here or use ClassLoaderSafeConnectorPageSink
There was a problem hiding this comment.
try/catch is used for initialising the IcebergPositionDeletePageSink.
I thought that the ClassLoaderSafeConnectorPageSink wrapper is needed because the page sink is used within the methods of UpdateablePageSource (deleteRows/updateRows).
However, in the meantime I've wrapped the UpdateablePageSource with a class loader safe wrapper, so probably there is no need anymore to do the wrapping for the page sinks as well.
There was a problem hiding this comment.
If you use ClassLoaderSafeConnectorPageSink there is no nee to do this try/catch here it is done inside
There was a problem hiding this comment.
Same here, maybe I am missing something but I think it is enough to use ClassLoaderSafeConnectorPageSink without try/catch above. You can see for example how ClassLoaderSafeConnectorPageSinkProvider is used
There was a problem hiding this comment.
Also I don't understand why here you did this double wrapping and below with IcebergPageSource you didn't
42375b4 to
11ad9f3
Compare
IcebergPageSource
electrum
left a comment
There was a problem hiding this comment.
Let’s change ConfigurationInstantiator to simply use the correct class loader.
Can you please detail this request? In the There are (at the moment) two |
11ad9f3 to
48d56d6
Compare
|
It seems that Iceberg (v2) support has to be considered non-functional without this (and #13112). |
There was a problem hiding this comment.
test with TestClassLoaderSafeWrappers
There was a problem hiding this comment.
remove @ForClassLoaderSafe.
the class is not going to be used in Guice.
There was a problem hiding this comment.
use io.trino.spi.classloader.ThreadContextClassLoader
(add trino-spi as a dep)
Make use of wrapper class `ClassLoaderSafeUpdatablePageSource` in order to hide the aspect related to ensuring the usage of the plugin class loader before calling the `IcebergPageSource` operations.
During the instantiation Configuration captures current thread context class loader. Ensure that the class loader captured corresponds to the plugin class loader.
|
In the context of accepting these changes, do we still need the class loader related changes made into ? |
48d56d6 to
684674a
Compare
Description
The problem of using the App ClassLoader instead of the Plugin ClassLoader was uncovered within: 4753ecc
Since then, there are multiple operations that relate to core SQL functionality on Iceberg connector.
See for reference:
This PR makes use of wrapper classes in order to hide the aspect related to
ensuring the usage of the plugin class loader before calling the
page source operations.
NOTE that this PR fixed the class loader safe handling only for the Iceberg connector. Other connectors need to be eventually handled separately as well.
Fix
Iceberg connector
Basic SQL statements like
DELETEorCREATE TABLE ASare failing on Iceberg due to the fact that engine refuses to make use of the app class loader in situations where it is expected to work with the plugin class loader.This PR ensures that this condition is met for the Iceberg connector operations.
Related issues, pull requests, and links
Relates to the PR: #13036
The mentioned PR tries to handle in a generic fashion the issue of dealing with a class loader safe Connector PageSource.
However, Iceberg deals with an
UpdatablePageSourcewhich would imply usinginstanceofchecks withinClassLoaderSafeConnectorPageSourceProvider.Documentation
(x) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text:
Fixes #13035