Skip to content

Conversation

spkane31
Copy link

@spkane31 spkane31 commented Sep 17, 2025

What was changed

Add # of signals as a workflow input

Why?

To ensure expected number of unique signals is accurate and no action from signals that are executed more than once.

Checklist

  1. Closes [Feature Request] Count and de-duplicate signals in kitchensink #204

  2. How was this tested: added unit tests

  3. Any docs updates needed?

@spkane31 spkane31 marked this pull request as ready for review September 18, 2025 20:47
@spkane31 spkane31 requested a review from a team as a code owner September 18, 2025 20:47
Copy link
Member

@bergundy bergundy left a comment

Choose a reason for hiding this comment

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

Didn't review the whole thing, added some comments.

// signal de-duplication fields
let expectedSignalCount = 0;
const expectedSignalIds = new Set<number>();
const receivedSignalIds = new Set<number>();
Copy link
Member

Choose a reason for hiding this comment

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

How are you transferring these on continue-as-new?

Copy link
Collaborator

@stephanos stephanos Sep 23, 2025

Choose a reason for hiding this comment

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

Thinking out out loud: what if we always fed the workflowState into the new workflow? The CAN action has "arguments" that are propagated right now.

Copy link
Collaborator

@stephanos stephanos left a comment

Choose a reason for hiding this comment

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

Left some initial comments on the Go side of things.

How about we split the non-Go part into a separate PR to make it easier to get the behavior right and making reviewing easier. Then, the other languages should be an easy fast-follower.

WorkflowInput: &WorkflowInput{
ExpectedSignalCount: 10,
InitialActions: ListActionSet(
NewAwaitWorkflowStateAction("signals_complete", "true"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might be too brittle since NewSetWorkflowStateAction can override that entire state if I'm not mistaken. It would be better to safe-guard that special key somehow.

Copy link
Collaborator

@stephanos stephanos Sep 23, 2025

Choose a reason for hiding this comment

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

Related to that, I've been wondering if SetWorkflowStateAction overriding the entire map is helpful. If it only updated a single key, that might be more useful.

Or we add a new MergeWorkflowStateAction that ... well merges selectively. But that would still be vulnerable to overrides from SetWorkflowStateAction.


// Check if all expected signals have been received (only for signals with IDs)
if receivedID != 0 && state.validateSignalCompletion() {
state.workflowState.Kvs["signals_complete"] = "true"
Copy link
Member

Choose a reason for hiding this comment

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

Do you even need this in the workflow state kvs?
The workflow should just fail if it did not receive all of the expected signals.

Copy link
Member

Choose a reason for hiding this comment

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

Still don't understand how the list of expected signals would be carried over the continue as new boundary.

ClientSequence: &ClientSequence{
ActionSets: []*ClientActionSet{
{
Actions: NewSignalActionsWithIDs(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
Copy link
Member

Choose a reason for hiding this comment

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

Probably best to just give a range here instead of having to provide each individual signal ID.

@spkane31 spkane31 force-pushed the spk/count-dedup-signals branch from b51756f to 7b71342 Compare October 2, 2025 23:29
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.

[Feature Request] Count and de-duplicate signals in kitchensink
3 participants