Skip to content
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

KSQL-12554 | Ensure Deterministic UDF Loading by Avoiding Context ClassLoader Interference #10442

Open
wants to merge 2 commits into
base: 7.1.x
Choose a base branch
from

Conversation

hrishabhg
Copy link
Member

@hrishabhg hrishabhg commented Sep 23, 2024

Description

In the current implementation, although the Thread.setContextClassLoader() method is not explicitly used, there is a possibility that the context class loader could be altered elsewhere, which was affecting the integration tests. This can lead to non-deterministic behavior in the loading of user-defined functions (UDFs) and cause unpredictable test results.

To address this issue, we ensure that the correct class loader is used explicitly for UDF loading without relying on the thread's context class loader. This change prevents unintended interference and guarantees that UDFs are loaded consistently, improving the stability and reliability of the integration tests.

The fix involves using ClassGraph.overrideClassLoaders(loader) to explicitly set the class loader for classpath scanning, thus avoiding any potential conflicts caused by changes to the thread's context class loader.

Testing done

  • Unit/Integration Tests
  • Manual Testing (Local Ksql-Server Setup)
    - All paths leading to UserFunctionLoader
    - All paths leading to UserFunctionLoader.loadClass
    - CustomUDF loading through a custom path

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")
  • Do these changes have compatibility implications for rollback? If so, ensure that the ksql command version is bumped.

@hrishabhg hrishabhg marked this pull request as ready for review September 23, 2024 07:48
@hrishabhg hrishabhg requested a review from a team as a code owner September 23, 2024 07:48
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

@hrishabhg hrishabhg changed the title Fix ClassLoader Issue Ensure Deterministic UDF Loading by Avoiding Context ClassLoader Interference Sep 23, 2024
* Fix classloading by overriding classgraph's override class loaders

* rebased 7.1.x
Copy link
Member

@VedarthConfluent VedarthConfluent left a comment

Choose a reason for hiding this comment

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

Classgraph issue fix lgtm. cp build pr job can be fixed separately

@hrishabhg hrishabhg changed the title Ensure Deterministic UDF Loading by Avoiding Context ClassLoader Interference KSQL-12554 | Ensure Deterministic UDF Loading by Avoiding Context ClassLoader Interference Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants