move workflow time skipping code into a different file#10867
move workflow time skipping code into a different file#10867feiyang3cat wants to merge 8 commits into
Conversation
7fc644c to
2e34647
Compare
| "google.golang.org/protobuf/types/known/timestamppb" | ||
| ) | ||
|
|
||
| // ============================================================================= |
There was a problem hiding this comment.
added sectional comments
| // ============================================================================= | ||
| // Time Skipping Runtime Data Structure | ||
| // ============================================================================= | ||
| type timeSkippingTransition struct { |
There was a problem hiding this comment.
expose the new and methods of this struct so that chasm framework can use this data structure directly
| // if checks if time skipping is enabled, if the workflow has in-flight work, | ||
| // and if the workflow is at the correct state and status to skip time. | ||
| // And if there is a time point to skip to is not the scope of this method. | ||
| func (ms *MutableStateImpl) isWorkflowSkippable() bool { |
There was a problem hiding this comment.
merged hasInflightWorkToPreventTimeSkipping and shouldExecuteTimeSkipping into this unified method
2e34647 to
fb0371a
Compare
… isSkippable and calculate all called
ed3fac9 to
eeb5129
Compare
| transition.TrackEarliestFutureTime(executionTime) | ||
| } | ||
| } | ||
| if ms.HadOrHasWorkflowTask() { |
There was a problem hiding this comment.
-
this is the key logic change to allow execution/run timeout
-
but the
ifcondition for status check is added because child workflows
Why root workflows don't have this problem:
the create transaction both applies the start event and calls AddFirstWorkflowTaskScheduled. So when that transaction's close-tx runs closeTransactionHandleWorkflowTimeSkipping, the workflow already has a pending WFT → HasPendingWorkflowTask() == true → isWorkflowSkippable() returns false ("has pending workflow task"). There is no window where a root workflow is running, time-skipping-enabled, and idle with no WFT. So the timeout target is never reached on a not-yet-started root workflow — the HadOrHasWorkflowTask guard changes nothing for it.
Why child workflows have the problem:
child workflow GenerateFirstWorkflowTask returns 0, nil — it does not schedule the first WFT. The child MS is created and persisted with only the start event; the first WFT is scheduled later in a separate step (the scheduleworkflowtask API path, driven after the parent's transfer task records the child as started). In between:
- running ✓, time-skipping enabled ✓ (config propagated from parent),
- no pending WFT (not scheduled yet), no completed WFT → HadOrHasWorkflowTask() == false,
- no timers / activities / children → isWorkflowSkippable() returns true.
eeb5129 to
c3d5800
Compare
What changed?
isWorkflowSkippableworkflowto relevant methods to separate them from chasm methodsTimeSkippingTransitionas a standard data structure and will be used by chasm as wellWhy?
How did you test it?