Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue describing the changes in this PR
resolves #issue_for_this_pr
Pull request checklist
release_notes.md
Additional information
The root cause is that in java worker we are initialize some singleton in the first function load request, this customer has multiple functions in one function app, when there are multiple function load requests, for ex A & warmup trigger coming almost at same time, let's say A is the first request java worker take to process, before java worker start initialize the singleton object in function A load request (as it's the first load request that we set the atomic flag in it ), it switch to processing warmup trigger load request in a different thread and finished it and return to host, then host send function warmup trigger invocation while function load request A is still be processing by another thread in java worker and the single objects haven't been fully initialized yet. So the invocation of warmup trigger gives the null pointer exception.
Warmup trigger function is load and invoked
before singleton object was initialized in first function load request
Why this issue is not happening before we adding the middleware feature.
The reason is that before the middleware feature, we don't really care about which function load request finish first. Once there is one function load request finish, then we can start invocation request without any issue.
But once we add middleware feature, we need the first function load request (because the first function load request will initialize the singleton to be used in invocation request in that onetime logic block) to finish before sending invocations. The first function load request is doing extra work by executing onetime logics to initialize singleton, if the onetime logics block is not synchronized, there is an chance that the first function load request won't be the first one to finish.