Skip to content

Commit

Permalink
Properly update workflow transition history (#5885)
Browse files Browse the repository at this point in the history
## What changed?
<!-- Describe what has changed in this PR -->
- Properly update workflow transition history.
- Only update transition history when closing transaction as active
- Only update updates to replicated application state as state
transition (NOTE: this is a different concept from the existing state
transition counter we have in executionInfo, which is simply how many
times the mutable state object got updated.)
    - When sub state machine tree is dirty
    - When history event got generated.
    - When there's sync activity
- All other changes are either system level field update or not
replicated (e.g. buffer events or transient workflow task)

## Why?
<!-- Tell your future self why have you made these changes -->
- State-based replication rely on all clusters agree on the same
transition history. and replication task processing logic relies on the
transition history to detect missing or conflicting state transitions.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
- Existing tests
- Added unit tests

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
- State transition history is behind a feature flag so no risk.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->
- N/A

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
- No
  • Loading branch information
yycptt committed May 21, 2024
1 parent 1c27937 commit d7d6d9e
Show file tree
Hide file tree
Showing 11 changed files with 465 additions and 164 deletions.
4 changes: 2 additions & 2 deletions common/persistence/versionhistory/version_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func GetVersionHistoryEventVersion(v *historyspb.VersionHistory, eventID int64)
return 0, err
}
if eventID < common.FirstEventID || eventID > lastItem.GetEventId() {
return 0, serviceerror.NewInternal("input event ID is not in range.")
return 0, serviceerror.NewInternal(fmt.Sprintf("input event ID is not in range, eventID: %v", eventID))
}

// items are sorted by eventID & version
Expand All @@ -239,7 +239,7 @@ func GetVersionHistoryEventVersion(v *historyspb.VersionHistory, eventID int64)
return currentItem.GetVersion(), nil
}
}
return 0, serviceerror.NewInternal("input event ID is not in range.")
return 0, serviceerror.NewInternal(fmt.Sprintf("input event ID is not in range, eventID: %v", eventID))
}

// IsEmptyVersionHistory indicate whether version history is empty
Expand Down
2 changes: 1 addition & 1 deletion config/development-cluster-a.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ namespaceDefaults:
URI: "file:///tmp/temporal_vis_archival/development"

dynamicConfigClient:
filepath: "config/dynamicconfig/development-cass.yaml"
filepath: "config/dynamicconfig/development-xdc.yaml"
pollInterval: "10s"
2 changes: 1 addition & 1 deletion config/development-cluster-b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ namespaceDefaults:
URI: "file:///tmp/temporal_vis_archival/development"

dynamicConfigClient:
filepath: "config/dynamicconfig/development-cass.yaml"
filepath: "config/dynamicconfig/development-xdc.yaml"
pollInterval: "10s"
2 changes: 1 addition & 1 deletion config/development-cluster-c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ namespaceDefaults:
URI: "file:///tmp/temporal_vis_archival/development"

dynamicConfigClient:
filepath: "config/dynamicconfig/development-cass.yaml"
filepath: "config/dynamicconfig/development-xdc.yaml"
pollInterval: "10s"
57 changes: 57 additions & 0 deletions config/dynamicconfig/development-xdc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#frontend.enableClientVersionCheck:
#- value: true
# constraints: {}
#history.persistenceMaxQPS:
#- value: 3000
# constraints: {}
#frontend.persistenceMaxQPS:
#- value: 3000
# constraints: {}
#frontend.throttledLogRPS:
#- value: 20
# constraints: {}
#history.defaultActivityRetryPolicy:
#- value:
# InitialIntervalInSeconds: 1
# MaximumIntervalCoefficient: 100.0
# BackoffCoefficient: 2.0
# MaximumAttempts: 0
#history.defaultWorkflowRetryPolicy:
#- value:
# InitialIntervalInSeconds: 1
# MaximumIntervalCoefficient: 100.0
# BackoffCoefficient: 2.0
# MaximumAttempts: 0
#system.secondaryVisibilityWritingMode:
# - value: "off"
# constraints: {}
#system.enableReadFromSecondaryVisibility:
# - value: false
# constraints: {}
#system.enableParentClosePolicyWorker:
# - value: true
system.enableEagerWorkflowStart:
- value: true
frontend.enableUpdateWorkflowExecution:
- value: true
frontend.enableUpdateWorkflowExecutionAsyncAccepted:
- value: true
frontend.workerVersioningDataAPIs:
- value: true
frontend.workerVersioningWorkflowAPIs:
- value: true
frontend.accessHistoryFraction:
- value: 1.0
frontend.adminDeleteAccessHistoryFraction:
- value: 1.0
system.enableNexus:
# enableNexus also controls transition history which can't be enabled now
- value: false
component.nexusoperations.callback.endpoint.template:
- value: http://localhost:7243/api/v1/namespaces/{{.NamespaceName}}/nexus/callback
matching.queryWorkflowTaskTimeoutLogRate:
- value: 1.0
history.ReplicationEnableUpdateWithNewTaskMerge:
- value: true
history.enableWorkflowExecutionTimeoutTimer:
- value: true

0 comments on commit d7d6d9e

Please sign in to comment.