Skip to content

Improve service self recovery - #6785

Merged
dkurepa merged 3 commits into
dotnet:mainfrom
dkurepa:dkurepa/RecreateReplicasOnConsumerFailures
Oct 21, 2026
Merged

dkurepa merged 3 commits into
dotnet:mainfrom
dkurepa:dkurepa/RecreateReplicasOnConsumerFailures

Conversation

@dkurepa

@dkurepa dkurepa commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

This PR does two things:

  • Makes sure we don't kill a WorkItemConsumer if comes from something other than the service cancellation token
  • Adds a WorkItemConsumer health check that the ACA will ping every 10 sec, checking if all consumers are still running. If any of them are not, we send an "Unhealthy" response. If this happens 3 times in a row a replica is restarted with a fresh healthy one

…token has been cancelled, add self healing to replicas
Copilot AI balanced review requested due to automatic review settings October 19, 2026 10:54

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.

🟡 Changes recommended

The health check references missing consumer properties, preventing compilation.

1 open issue
What changed in this PR

Improves PCS recovery from consumer timeouts and unexpected consumer exits.

Changes:

  • Keeps consumers running after cancellations unrelated to host shutdown.
  • Adds consumer health checks and a restart-triggering liveness probe.
  • Adds recovery tests and documents probe behavior.
File Description
test/​Maestro/​Maestro.WorkItems.Tests/​WorkItemConsumerTests.cs Tests timeout recovery and shutdown handling.
test/​Maestro/​Maestro.WorkItems.Tests/​WorkItemConsumerHealthCheckTests.cs Tests consumer health states and endpoints.
src/​Maestro/​Maestro.WorkItems/​WorkItemConsumerHealthCheck.cs Detects consumers that are no longer running.
src/​Maestro/​Maestro.WorkItems/​WorkItemConsumer.cs Limits cancellation exits to host shutdown.
src/​Maestro/​Maestro.WorkItems/​WorkItemConfiguration.cs Registers consumer liveness checks.
src/​Maestro/​Maestro.Services.Common/​ServiceDefaultsExtensions.cs Shares the liveness-check tag.
eng/​service-templates/​ProductConstructionService/​container-app.bicep Adds the periodic liveness probe.
docs/​DevGuide.md Documents probes and detection limits.

Review effort: Balanced


string[] stoppedConsumers = _consumers
.Where(consumer => consumer.ExecuteTask is null || consumer.ExecuteTask.IsCompleted)
.Select(consumer => $"{consumer.ConsumerId} ({consumer.QueueName})")
Comment thread src/Maestro/Maestro.WorkItems/WorkItemConsumer.cs Outdated
@premun
premun enabled auto-merge (squash) October 21, 2026 11:43
@dkurepa
dkurepa disabled auto-merge October 21, 2026 11:45
@dkurepa
dkurepa enabled auto-merge (squash) October 21, 2026 11:46
@dkurepa
dkurepa merged commit 9e78c6b into dotnet:main Oct 21, 2026
14 of 15 checks passed
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.

3 participants