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

Pass workflowTask object to completion methods of mutable state #3897

Merged
merged 1 commit into from
Feb 3, 2023

Conversation

alexshtin
Copy link
Member

What changed?
Pass workflowTask object to completion methods of mutable state.

Why?
To avoid reconstruction of workflowTask object from mutable state every time.

How did you test it?
Existing tests.

Potential risks
No risks.

Is hotfix candidate?
No.

@alexshtin alexshtin requested a review from a team as a code owner February 3, 2023 02:12
@@ -482,23 +482,10 @@ func (m *workflowTaskStateMachine) skipWorkflowTaskCompletedEvent(workflowTaskTy
return onlyUpdateRejectionMessages
}
func (m *workflowTaskStateMachine) AddWorkflowTaskCompletedEvent(
scheduledEventID int64,
startedEventID int64,
workflowTask *WorkflowTaskInfo,
Copy link
Member Author

Choose a reason for hiding this comment

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

This file is an actual change. All the rest is just update callers and tests.

Everywhere where these 3 methods are called workflow task object already exist and populated with correct data. I am now passing it directly instead of calling m.GetWorkflowTaskInfo(scheduledEventID) one more time.

) {
// TODO (alex-update): Uncomment this code to support speculative workflow task restoration.

/*
// StartedEventID might be lost (cleared) for speculative workflow task due to shard reload or history service restart.
if workflowTask != nil && workflowTask.Type == enumsspb.WORKFLOW_TASK_TYPE_SPECULATIVE && workflowTask.StartedEventID == common.EmptyEventID {
workflowTask.StartedEventID = startedEventID
workflowTask.StartedEventID = workflowTask.ScheduledEventID + 1
Copy link
Member

Choose a reason for hiding this comment

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

Started ID is always scheduled ID + 1? I don't recall we buffer events when there's a scheduled workflow task, or is speculative workflow task different?

Copy link
Member Author

Choose a reason for hiding this comment

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

For normal WT we don't buffer events after scheduled WT, we only buffer them after WT is started. This formula won't work for it. Speculative (and transient) WT gets converted to normal when started, if there are new events came after it was scheduled.

@alexshtin alexshtin merged commit 32a4686 into temporalio:master Feb 3, 2023
@alexshtin alexshtin deleted the feature/pass-wt branch February 3, 2023 06:44
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.

2 participants