Skip to content

Conversation

FranzBusch
Copy link
Member

Motivation

Temporal's workflow state machine previously used a single shared sequence number counter for all operation types (timers, activities, conditions, child workflows, and external signals). This could potentially lead to confusion when tracking different types of operations, as each operation type needs its own independent sequence numbering to properly identify activation jobs.

Modifications

  • Split the single nextSequenceNumber into five operation-specific counters:

    • nextTimerSequenceNumber for sleep operations
    • nextActivitySequenceNumber for activity executions (local and remote)
    • nextConditionSequenceNumber for wait conditions
    • nextChildWorkflowSequenceNumber for child workflow executions
    • nextExternalSignalSequenceNumber for signaling external workflows
  • Updated all sequence number generation methods to use the appropriate counter

  • Updated WorkflowStateMachineStorage to call the correct sequence number method for each operation type

  • Enhanced documentation to clarify that each operation type maintains independent sequence counters

Result

Each workflow operation type now maintains its own independent sequence counter, making the sequence numbering system more robust and easier to reason about. This ensures that activation jobs can be correctly matched to their originating commands without any ambiguity across different operation types.

### Motivation

Temporal's workflow state machine previously used a single shared sequence number counter for all operation types (timers, activities, conditions, child workflows, and external signals). This could potentially lead to confusion when tracking different types of operations, as each operation type needs its own independent sequence numbering to properly identify activation jobs.

### Modifications

- Split the single `nextSequenceNumber` into five operation-specific counters:
  - `nextTimerSequenceNumber` for sleep operations
  - `nextActivitySequenceNumber` for activity executions (local and remote)
  - `nextConditionSequenceNumber` for wait conditions
  - `nextChildWorkflowSequenceNumber` for child workflow executions
  - `nextExternalSignalSequenceNumber` for signaling external workflows

- Updated all sequence number generation methods to use the appropriate counter
- Updated `WorkflowStateMachineStorage` to call the correct sequence number method for each operation type
- Enhanced documentation to clarify that each operation type maintains independent sequence counters

### Result

Each workflow operation type now maintains its own independent sequence counter, making the sequence numbering system more robust and easier to reason about. This ensures that activation jobs can be correctly matched to their originating commands without any ambiguity across different operation types.
@FranzBusch FranzBusch added the 🔨 semver/patch No public API change. label Oct 10, 2025
Copy link

@philippzagar philippzagar left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the improvement and nice docs @FranzBusch! 🚀

@FranzBusch FranzBusch merged commit 79c5ed9 into main Oct 11, 2025
21 of 23 checks passed
@FranzBusch FranzBusch deleted the workflow-sequence-numbers-per-operation branch October 11, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants