Skip to content

[CORE] Avoid getting duplicate resource files for component discovery#11043

Merged
philo-he merged 2 commits into
apache:mainfrom
philo-he:fix-duplicate-resources
Nov 10, 2025
Merged

[CORE] Avoid getting duplicate resource files for component discovery#11043
philo-he merged 2 commits into
apache:mainfrom
philo-he:fix-duplicate-resources

Conversation

@philo-he

@philo-he philo-he commented Nov 7, 2025

Copy link
Copy Markdown
Member

What changes are proposed in this pull request?

It seems Thread.currentThread().getContextClassLoader() will internally use multiple class loaders that return duplicate resource files.

If Gluten fat JAR with all component files is configured for Spark, or Gluten JAR and separate component JARs are configured together for Spark, e.g., spark.driver.extraClassPath, I assume it should be safe to use the current class's loader to get all component files.

Before the fix:

25/11/06 13:33:05 INFO Discovery: Start discovering components in the current classpath...
25/11/06 13:33:05 INFO Discovery: Discovered component files: org.apache.gluten.backendsapi.velox.VeloxBackend, org.apache.gluten.component.VeloxIcebergComponent, org.apache.gluten.backendsapi.velox.VeloxBackend, org.apache.gluten.component.VeloxIcebergComponent. Duration: 26 ms.
25/11/06 13:33:05 WARN Discovery: Found duplicated component class org.apache.gluten.backendsapi.velox.VeloxBackend in then classpath, ignoring.
25/11/06 13:33:05 WARN Discovery: Found duplicated component class org.apache.gluten.component.VeloxIcebergComponent in then classpath, ignoring.
25/11/06 13:33:05 WARN Component: Excluding runtime-incompatible component: velox-iceberg.
25/11/06 13:33:05 INFO package: Components registered within order: velox

After the fix:

25/11/06 13:12:57 INFO Discovery: Start discovering components in the current classpath...
25/11/06 13:12:57 INFO Discovery: Discovered component files: org.apache.gluten.backendsapi.velox.VeloxBackend, org.apache.gluten.component.VeloxIcebergComponent. Duration: 5 ms.
25/11/06 13:12:57 WARN Component: Excluding runtime-incompatible component: velox-iceberg.
25/11/06 13:12:57 INFO package: Components registered within order: velox

How was this patch tested?

CI.

@github-actions github-actions Bot added the CORE works for Gluten Core label Nov 7, 2025
@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@philo-he

philo-he commented Nov 7, 2025

Copy link
Copy Markdown
Member Author

@liujiayi771, could you take a look?

@philo-he

philo-he commented Nov 7, 2025

Copy link
Copy Markdown
Member Author

@zhztheplayer, please take look and let me know if thread's context class loader is used intentionally. If yes, maybe I can just suppress the warning in this PR.

@github-actions

github-actions Bot commented Nov 7, 2025

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@liujiayi771

liujiayi771 commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Thanks for fixing this confusing warning.

@zhztheplayer zhztheplayer left a comment

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.

👍

final Enumeration<URL> containerUrls;
try {
containerUrls = Thread.currentThread().getContextClassLoader().getResources(container);
containerUrls = ResourceUtil.class.getClassLoader().getResources(container);

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.

👍

The change itself looks reasonable, and I didn't realize context class loader could result in duplicated resources. Will find some time to debug on my end.

@philo-he philo-he merged commit 33b7647 into apache:main Nov 10, 2025
102 of 104 checks passed
@philo-he philo-he deleted the fix-duplicate-resources branch November 10, 2025 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants