Skip to content

Conversation

soninaren
Copy link
Member

@soninaren soninaren commented Jan 31, 2024

Issue describing the changes in this PR

With worker indexing enabled all of our worker channels are managed at the webhost level. In such a scenario, if the host becomes unhealthy we restart the script host here

var tIgnore = RestartHostAsync(CancellationToken.None);

However, as part of host restart we do not shutdown the workers started at the webhost level. Once the new host starts up specifically for dotnet-isolated, the request to load the same function is sent again. As the worker has not been restarted it throws an invalidOperation exception with the error. Result: Failure Exception: System.InvalidOperationException: Unable to load Function '[Function name]'. A function with the id '[Function id]' name already exists

Additional PR information

The fix here was to make sure we shutdown the workers started at the webhost level on host shutdown. Except for when we specialize.

resolves #2124

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
  • 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)

Additional information

Additional PR information

@soninaren soninaren requested a review from a team as a code owner January 31, 2024 21:00
@soninaren soninaren force-pushed the nasoni/UnhealthyHostFix branch from a1578da to 65d40fa Compare February 14, 2024 15:10
@soninaren soninaren force-pushed the nasoni/UnhealthyHostFix branch from 65d40fa to cd00d58 Compare February 14, 2024 20:49
@soninaren soninaren merged commit 2c830a0 into dev Feb 15, 2024
@soninaren soninaren deleted the nasoni/UnhealthyHostFix branch February 15, 2024 00:27
/// <summary>
/// Gets or Sets a value indicating whether the host should shutdown webhost worker channels during shutdown.
/// </summary>
public bool ShutdownWebhostWorkerChannelsOnHostShutdown
Copy link
Member

Choose a reason for hiding this comment

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

nit: fix camel casing of Webhost on prop and constants. The codebase uses WebHost

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.

Unable to load Function, a function with the id already exists.
4 participants