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 NPE issue #684

Merged
merged 3 commits into from
Dec 7, 2022
Merged

fix NPE issue #684

merged 3 commits into from
Dec 7, 2022

Conversation

kaibocai
Copy link
Member

@kaibocai kaibocai commented Dec 6, 2022

Issue describing the changes in this PR

resolves #issue_for_this_pr

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • I have added all required tests (Unit tests, E2E tests)

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
MicrosoftTeams-image

before singleton object was initialized in first function load request 
MicrosoftTeams-image (1)

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.

@kaibocai kaibocai merged commit 2d9860c into dev Dec 7, 2022
@kaibocai kaibocai deleted the kaibocai/npe-fix branch December 7, 2022 01:28
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