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

Safe message handler sample #73

Merged
merged 3 commits into from
Aug 12, 2024
Merged

Conversation

cretz
Copy link
Member

@cretz cretz commented Jun 24, 2024

What was changed

Sample showing atomic message handling in .NET w/ Semaphore using the logic from temporalio/samples-python#123

@cretz cretz requested review from drewhoskins-temporal and a team June 24, 2024 19:17
Copy link
Member Author

Choose a reason for hiding this comment

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

Added this abstraction as part of this PR so we can reuse dev servers across tests

@cretz cretz force-pushed the atomic-message-handlers branch from 4d2502b to be233c9 Compare June 24, 2024 19:26
@cretz cretz changed the title Atomic message handler sample Safe message handler sample Jun 27, 2024
@cretz cretz force-pushed the atomic-message-handlers branch from a466055 to 3f773a5 Compare June 27, 2024 17:35
ExtraArgs =
[
"--dynamic-config-value",
"frontend.enableUpdateWorkflowExecution=true",

Choose a reason for hiding this comment

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

I wonder if we should enable stuff like this when go to public preview?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think we should according to the implied opt-in vs opt-out nature of release stages at https://docs.temporal.io/evaluate/release-stages. But of course that is a server thing and not related to this PR.

@cretz
Copy link
Member Author

cretz commented Jul 2, 2024

By request, I am not merging this until temporalio/samples-python#123 is merged.

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.

Cool sample. Just some language suggestions.

# Safe Message Handlers

This sample shows a workflow using `Temporalio.Workflows.Semaphore` to atomically process certain blocks of workflow
code to prevent data race issues. The sample code demonstrates assigning cluster nodes to jobs atomically.
Copy link
Member

Choose a reason for hiding this comment

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

For some strict definition of data race, that can't happen in Temporal regardless (what's being prevented here is I think more strictly a logical race). I'd suggest we say "to serialize execution of certain blocks of workflow code" just to be extra clear here.

Comment on lines +118 to +119
// This await would be dangerous without nodesLock because it yields control and allows
// interleaving
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// This await would be dangerous without nodesLock because it yields control and allows
// interleaving
// This await would be dangerous without nodesLock because it yields control and would
// allow execution to interleave with other concurrent updates

@cretz
Copy link
Member Author

cretz commented Jul 24, 2024

This needs to be updated to remove all concept of health check and bad nodes (see temporalio/samples-python#132). We also need to make sure we don't continue as new while a handler is running, so we'll need the new all-finished property which means this is likely held up until a .NET SDK release.

@cretz
Copy link
Member Author

cretz commented Aug 12, 2024

Merging now without all handler stuff to not wait on next release. We can come back and add later if we want.

@cretz cretz merged commit 175feb5 into temporalio:main Aug 12, 2024
6 checks passed
@cretz cretz deleted the atomic-message-handlers branch August 12, 2024 15:20
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