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

Fix Nashorn out of memory issue in adaptive script execution #5202

Merged
merged 5 commits into from
Nov 28, 2023

Conversation

shanggeeth
Copy link
Contributor

@shanggeeth shanggeeth commented Nov 21, 2023

Purpose

Adaptive authentication scripts are executed using Nashorn Script Engine.
Instantiating a Nashorn Script Engine for each script execution results in memory growth and eventually OOM error due to a JDK bug[1].

This PR addresses the above issue with the following solution,

  • Adds Nashorn Script Engine as a thread local variable to limit the number of Nashorn Script Engine instances created to a maximum of number of worker threads.
  • Add a flag to use Nashorn engine as a thread local variable vs initialize Nashorn engine in each script execution
[AdaptiveAuth]
"LimitScriptEngineCreation"= true

Related Issue:

[1] https://bugs.openjdk.org/browse/JDK-8229011

@shanggeeth shanggeeth marked this pull request as draft November 22, 2023 04:53
@shanggeeth shanggeeth requested a review from pulasthi7 November 24, 2023 08:46
@shanggeeth shanggeeth marked this pull request as ready for review November 24, 2023 08:46
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/6978647255

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/6978647255
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/6978647255

@shanggeeth shanggeeth changed the title Introduce Thread Local ScriptEngine Wrapper Fix Nashorn out of memory issue in adaptive script execution Nov 27, 2023
@shanggeeth
Copy link
Contributor Author

Add more description to the PR

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/7007869150

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/7007869150
Status: cancelled

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/7013814295

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/7013814295
Status: failure

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/7018309887

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/7018309887
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/7018309887

@shanggeeth shanggeeth merged commit d49f442 into wso2:master Nov 28, 2023
2 checks passed
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.

4 participants