-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Step Functions: Lazy Initialization of JVM for JSONata Evaluation #12369
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
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 31m 14s ⏱️ - 1h 21m 15s Results for commit cd9cc09. ± Comparison against base commit 20f989b. This pull request removes 2692 tests.
♻️ This comment has been updated with latest results. |
I'll let @joe4dev and @gregfurman do the actual review, but I can verify that this solves the issue with the entrypoint generation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just one small concern about the global variable assign being racey.
global _eval_jsonata | ||
if _eval_jsonata is None: | ||
# Initialize _eval_jsonata only when invoked for the first time using the Singleton pattern. | ||
_eval_jsonata = _JSONataJVMBridge.get().eval_jsonata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not be locking before assigning this global variable? I'm concerned about a race condition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The singleton class pattern and the installer are thread-safe, and the installation can only occur once, so we should be okay to keep this as it
Motivation
The current implementation starts the JVM during module import, which interferes with unrelated processes like generating entrypoints—especially on Windows machines, where it may break the entrypoint generation process entirely. This PR defers the startup of the JVM until the JSONata evaluation feature is actually needed first, ensuring that other processes remain unaffected by premature JVM initialization.
Changes
* Known Limitation: The first invocation in a state with tight timeouts might trigger a timeout error in the evaluation of the state machine due to the JVM installation overhead. This edge case is rare, does not result in abrupt terminations (the state machine will terminate gracefully), and does not affect future executions. Future refinements to the installer behavior may address this further.