Repository navigation
Quarantine workflow instances that repeatedly fail to load - #1452
Open
danielgerlag wants to merge 1 commit into
Open
danielgerlag wants to merge 1 commit into
danielgerlag wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1451
What and why
If
GetWorkflowInstancethrows for a runnable instance (for example its storedDatano longer deserializes), the instance is polled, fails, and is polled again every poll interval forever. Each attempt takes a lock, does a database read and logs two errors.This change counts consecutive load failures per instance in
WorkflowConsumer. AfterMaxWorkflowLoadAttempts(default 5) the instance is quarantined on that node:RunnablePollerstops re-queuing it except once per greylist TTL (5 minutes)A successful load clears the count. Only failures from
GetWorkflowInstanceare counted, so exceptions while running steps keep the existing retry behavior.Design choices
Suspended. Changing status without loading the instance would need a new persistence method onIPersistenceProvider, which every provider (and third party providers) would have to implement. This keeps the fix inside core with no provider changes.WorkflowOptions.UseMaxWorkflowLoadAttempts(int), following the existingUse...style.InternalsVisibleToforWorkflowCore.UnitTestsso the consumer can be tested directly.docs/error-handling.md.How it was tested
New
WorkflowConsumerFixture(6 tests) drivesProcessItemwith a fake persistence provider that throws on load. With the oldWorkflowConsumer.csrestored, 3 of them fail: the load was attempted 20 times out of 20 instead of stopping at the limit. With the fix all 6 pass.dotnet build WorkflowCore.sln: succeeded, 0 errorsWorkflowCore.UnitTests: 68 tests per framework. All pass on net6.0 and net8.0. On net10.0should_run_pre_middlewares(SyncWorkflowRunnerTests) failed once; it also failed onmasterbefore any change (net8.0 run), so it looks flaky and unrelated.WorkflowCore.IntegrationTests: 45/45 on net6.0, net8.0 and net10.0Limits
Runnable. Nothing outside the logs shows it is quarantined; no lifecycle event is published.