Fix stale second-pass IDs and missing-workflow NREs - #1444
Open
danielgerlag wants to merge 2 commits into
Open
Conversation
Clear QueueConsumer _secondPasses when an item finishes so completed or purged workflows are not reprocessed. Skip WorkflowConsumer and IndexConsumer processing when GetWorkflowInstance returns null, which happens with Redis deleteCompleted and after WorkflowPurger cleanup. Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com>
Co-authored-by: Daniel Gerlag <danielgerlag@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/fix-stale-second-passes-null-workflow-a70f
branch
from
September 8, 2026 00:43
ce2f6b9 to
d4e4440
Compare
|
Rebased onto current |
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 #1417
Fixes #1376
Describe the change
Queue items for completed, terminated, or persistence-deleted workflows could still be processed. That produced two related failures:
#1417:QueueConsumer._secondPasseskept a workflow id afterExecuteItemfinished. A later second pass then tried to process a purged/terminated instance (Sequence contains no elements/ missing instance).#1376: With RedisdeleteCompleted/removeComplete: true,WorkflowConsumercould dequeue a deleted id.GetWorkflowInstancereturned null andEnrich/StatusthrewNullReferenceException.Describe your implementation or design
Smallest consumer-side change; no persistence, Redis, or
deleteCompletedbehavior changes.QueueConsumer.ExecuteItemfinally, clear_secondPassesalongside_activeTasks.Remove.GetWorkflowInstance, if the instance is null, log a warning with the item id and return. Applied inWorkflowConsumerandIndexConsumer(same fetch-then-enrich pattern; index consumer also usesEnableSecondPasses).finallyinWorkflowConsumer.Tests
QueueConsumerTests.ExecuteItem_ShouldClearSecondPasses_AfterProcessing: duplicate in-flight item is tracked in_secondPasses, then removed after execute.WorkflowConsumerTests.ProcessItem_WhenWorkflowInstanceIsNull_DoesNotThrow: missing instance does not NRE; executor is not called; greylist and lock are still released.Breaking change
No. Missing instances are now skipped instead of throwing.
Additional context
This does not change how completed workflows are deleted. It only makes consumers tolerant of a queue item whose instance is already gone, and stops leftover second-pass ids from sticking around after execute.