Skip to content

fix: atomic load for ActiveHostConfigurationProvider - #11815

Merged
Jacob Viau (jviau) merged 2 commits into
devfrom
u/jviau/config-race
Jun 11, 2026
Merged

Jacob Viau (jviau) merged 2 commits into
devfrom
u/jviau/config-race

Conversation

@jviau

Copy link
Copy Markdown
Contributor

Issue describing the changes in this PR

part of #11787

While investigating the blob client issue above, I also identified a potential enumerable read/write conflict. We do not atomically swap the Data, but instead update it in place. Any config consumers enumerating that Data dictionary at the same time will lead to exceptions. I have verified this exception can be seen occasionally in our logs.

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • 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
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Copilot AI review requested due to automatic review settings June 10, 2026 21:15
@jviau
Jacob Viau (jviau) requested a review from a team as a code owner June 10, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the ActiveHostConfigurationSource configuration provider against concurrent read/write failures by building a fresh configuration dictionary and swapping it into ConfigurationProvider.Data atomically, avoiding “collection was modified” exceptions when consumers enumerate during refresh.

Changes:

  • Refactors ActiveHostConfigurationSource to use a primary constructor and updates ActiveHostConfigurationProvider.Load() to rebuild into a new dictionary and then swap Data in one assignment.
  • Keeps the provider subscribed to ActiveHostChanged and preserves the existing “first key wins” behavior when enumerating underlying configuration.
  • Minor XML doc punctuation fixes in BlobServiceClientProvider.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/WebJobs.Script/Config/ActiveHostConfigurationSource.cs Rebuilds and atomically swaps the provider Data dictionary during Load() to prevent concurrent enumeration exceptions.
src/WebJobs.Script/StorageProvider/BlobServiceClientProvider.cs Updates XML documentation punctuation only.

Comment thread src/WebJobs.Script/Config/ActiveHostConfigurationSource.cs
Comment thread src/WebJobs.Script/Config/ActiveHostConfigurationSource.cs
@jviau
Jacob Viau (jviau) merged commit 4aa07f8 into dev Jun 11, 2026
11 checks passed
@jviau
Jacob Viau (jviau) deleted the u/jviau/config-race branch June 11, 2026 20:02
Jacob Viau (jviau) added a commit that referenced this pull request Jun 12, 2026
* fix: atomic load for ActiveHostConfigurationProvider

* fix: atomic load for CompatEnvironmentVariablesProvider
@v-selvarajbh v-selvarajbh mentioned this pull request Jun 12, 2026
9 tasks
v-selvarajbh added a commit that referenced this pull request Jun 12, 2026
* Update version to 4.1051.200

* Clear release notes

* fix: avoid health check auth for non-expanded requests (#11816)

* fix: atomic load for ActiveHostConfigurationProvider (#11815)

* fix: atomic load for ActiveHostConfigurationProvider

* fix: atomic load for CompatEnvironmentVariablesProvider

---------

Co-authored-by: azure-functions-release[bot] <223311270+azure-functions-release[bot]@users.noreply.github.com>
Co-authored-by: Jacob Viau <javia@microsoft.com>
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