Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn about unfinished handlers #488

Merged
merged 13 commits into from
Sep 3, 2024
Merged

Conversation

roxblnfk
Copy link
Collaborator

@roxblnfk roxblnfk commented Aug 16, 2024

What was changed

Added logging of unfinished Signal and Update handlers when a Workflow finishes.

Warning

Warn will happen in cases of Workflow success, cancel, continue-as-new, fail with retryable, fail with non-retryable.

If there are unfinished handlers of both types, two warnings will be sent.

To disable such warnings a new feature flag $warnOnWorkflowUnfinishedHandlers has been added:

\Temporal\FeatureFlags::$warnOnWorkflowUnfinishedHandlers = false;

Examples:

Workflow Extra_Workflow_AllHandlersFinished cancelled while update handlers are still running. This may have interrupted work that the update handler was doing, and the client that sent the update will receive a 'workflow execution already completed' RPCError instead of the update result. You can wait for all update and signal handlers to complete by using yield Workflow::await(Workflow::allHandlersFinished(...));. Alternatively, if both you and the clients sending the update are okay with interrupting running handlers when the workflow finishes, and causing clients to receive errors, then you can disable this warning via the update handler attribute: #[UpdateMethod(unfinishedPolicy: HandlerUnfinishedPolicy::Abandon)]. The following updates were unfinished (and warnings were not disabled for their handler): await id:5e51ad4d-041c-4604-8b0a-cda641169da6, await id:1ea22590-aafa-4d27-aea4-9f0b7122b33d, await id:12059abd-2097-452b-b4de-36978c1c45da, await id:ca26f433-0974-4332-bc01-91c32e97dcc0, await id:ec827b4a-801c-453f-864c-b042bbcda3ea, await id:4b4dcf64-043c-4de2-b1fa-7431aedabf4c, await id:57839a31-34db-4560-b10a-4afc083133cc, await id:14158ca5-2d65-47f4-824c-7e15705219b5

Workflow Extra_Workflow_AllHandlersFinished finished while signal handlers are still running. This may have interrupted work that the signal handler was doing. You can wait for all update and signal handlers to complete by using yield Workflow::await(Workflow::allHandlersFinished(...));. Alternatively, if both you and the clients sending the signal are okay with interrupting running handlers when the workflow finishes, and causing clients to receive errors, then you can disable this warning via the signal handler attribute: #SignalMethod(unfinishedPolicy: HandlerUnfinishedPolicy::Abandon)]. The following signals were unfinished (and warnings were not disabled for their handler): resolve x2, await x8

Checklist

  1. Closes Warn or error when update handlers dangle across CAN or workflow exit #446
  2. How was this tested: manually
  3. Any docs updates needed?

Copy link

vercel bot commented Aug 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
php ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 10:21am

Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

This looks really nice. Makes sense to me. Thanks guys!

$stub->signal('exit');
$stub->getResult(timeout: 1);

// todo Check that `await` signal with count was mentioned in the logs
Copy link
Member

Choose a reason for hiding this comment

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

Looks like a bit of leftover? Below as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We currently don't have the capability to test this, so these TODOs will likely remain for the time being

@roxblnfk roxblnfk merged commit 20490e2 into master Sep 3, 2024
92 checks passed
@roxblnfk roxblnfk deleted the warn-about-running-handlers branch September 3, 2024 11:57
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.

Warn or error when update handlers dangle across CAN or workflow exit
3 participants