Skip to content

Provide insightful information for classloader issues#24973

Merged
wendigo merged 1 commit intotrinodb:masterfrom
wendigo:serafin/debug-class-loader
Feb 10, 2025
Merged

Provide insightful information for classloader issues#24973
wendigo merged 1 commit intotrinodb:masterfrom
wendigo:serafin/debug-class-loader

Conversation

@wendigo
Copy link
Copy Markdown
Contributor

@wendigo wendigo commented Feb 10, 2025

This saves time while diagnosing issue like:

tests               | Caused by: java.lang.ClassNotFoundException: SPI class 'io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder' was not found in the SPI classloader, but was found in the 'delta-lake' plugin classloader
tests               |   at io.trino.server.PluginClassLoader.loadClass(PluginClassLoader.java:108)
tests               |   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
tests               |   ... 79 more
tests               | Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder
tests               |   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
tests               |   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
tests               |   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
tests               |   at io.trino.server.PluginClassLoader.loadClass(PluginClassLoader.java:104)
tests               |   ... 80 more

Description

Additional context and related issues

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.

Comment thread core/trino-main/src/main/java/io/trino/server/PluginClassLoader.java Outdated
Comment thread core/trino-main/src/main/java/io/trino/server/PluginClassLoader.java Outdated
@wendigo wendigo force-pushed the serafin/debug-class-loader branch from be18254 to 98559ce Compare February 10, 2025 12:47
Comment thread core/trino-main/src/main/java/io/trino/server/PluginClassLoader.java Outdated
This saves time while diagnosing issue like:

```
tests               | Caused by: java.lang.ClassNotFoundException: SPI class 'io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder' was not found in the SPI classloader, but was found in the 'delta-lake' plugin classloader
tests               |   at io.trino.server.PluginClassLoader.loadClass(PluginClassLoader.java:108)
tests               |   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
tests               |   ... 79 more
tests               | Caused by: java.lang.ClassNotFoundException: io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder
tests               |   at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
tests               |   at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
tests               |   at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
tests               |   at io.trino.server.PluginClassLoader.loadClass(PluginClassLoader.java:104)
tests               |   ... 80 more
```
@wendigo wendigo force-pushed the serafin/debug-class-loader branch from 98559ce to 4886aa1 Compare February 10, 2025 14:33
@wendigo wendigo merged commit 5a499e6 into trinodb:master Feb 10, 2025
@github-actions github-actions bot added this to the 471 milestone Feb 10, 2025
private boolean hasClassLocally(String name, boolean resolve)
{
try {
super.loadClass(name, resolve);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is potentially problematic. This will have the side effects that the class may get loaded, the caller will throw an exception that may be caught by someone else, and things may start behaving in unexpected ways.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already problematic if the class belong to an SPI_PACKAGES but couldn't be loaded through the SPI class loader. I've faced this issue recently.

@wendigo wendigo deleted the serafin/debug-class-loader branch February 20, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants