Address LanguageWorkerOptions null in FunctionMetadataManager #10550
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 #9859
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-proc
branch to be included in Core Tools and non-Flex deployments.in-proc
branch is not requiredrelease_notes.md
Additional information
This PR reverts a portion of #9264 and uses a different approach to solve stale function metadata. This alternative approach also addresses the null-ref from #9859.
Background
#9264 set out to solve function metadata being calculated and cached with a stale set of worker configs. To address this, the PR allowed for worker configs to be explicitly supplied to the
GetFunctionMetadata
method. When configs were not explicitly supplied, it would get 'fallback' configs from the current service provider. However, that provider is the active host. If this was called too early in the hosts lifetime, the active host would benull
(leading to the null-ref).Examining the issue it is a cache invalidation problem.
GetFunctionMetadata
will get the current value ofLanguageWorkerOptions
, then build and cache the function metadata results. That caching is the problem, as language worker options changes over the lifetime of the functions host.Fix
To address the null ref and after taking a closer look at the root issue, a new approach has been taken. Instead of explicitly supplying the RPC configs (which all 2 instances of that were from the current value of
LanguageWorkerOptions
), we go back to the original approach of getting the current value of those options. With one major difference: we now subscribe to theOnChange
of those options and will invalidate the cache whenever they change. The next call toGetFunctionMetadata
will then re-build and cache the function metadata set.Additional Information
#9264 would get the
LanguageWorkerOptions
from the job host. This PR now gets them from the script host (parent of job host). These options are identical between the two hosts. PR #10369 even sets out to make the job hosts copy of these options a direct forwarding of the script hosts copy.