Skip to content

Conversation

@alexshtin
Copy link
Contributor

What changed?
If failWorkflowTask was created in completeWorkflowTask then entire request fails.

Why?
Fixes #652.

How did you test it?
Added integration test.

Potential risks
If anyone relies on success return in case of malformed request (very unlikely), their code will be broken.

@alexshtin alexshtin requested review from mfateev and samarabbas and removed request for mfateev August 4, 2020 17:41
return []*commandpb.Command{
{
CommandType: enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION,
CommandType: enumspb.COMMAND_TYPE_START_TIMER,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is 🤦. With new handler logic, I was able to catch it.

},
})
s.Nil(err, s.printHistory(msBuilder))
executionBuilder := s.getBuilder(testNamespaceID, we)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

s.getBuilder doesn't work anymore, because cache is invalidated and there is no ExecutionInfo. Instead, I am using ms2 object for assertes in all unit tests. I believe ms2 is a mutable state that actually get mutated with last RespondWorkflowTaskCompleted API call.

failWorkflowTaskInfo struct {
cause enumspb.WorkflowTaskFailedCause
message string
workflowTaskFailedError struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did some minor refactoring here.

}

if workflowTaskFailedErr != nil {
switch workflowTaskFailedErr.causeErr.(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like that we have logic about what error to return back to the caller spread across multiple files. I think we should have the workflow task error logic only within workflowTaskHandler.go.

Copy link
Contributor

@samarabbas samarabbas left a comment

Choose a reason for hiding this comment

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

Can you please address my comments.


if _, err = mutableState.AddWorkflowTaskFailedEvent(
scheduleID, startedID, cause, failure, request.GetIdentity(), request.GetBinaryChecksum(), "", "", 0,
scheduleID, startedID, workflowTaskFailedErr.failedCause, failure.NewServerFailure(workflowTaskFailedErr.Error(), true), request.GetIdentity(), request.GetBinaryChecksum(), "", "", 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we wrapping it in NewServerFailure?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add another method on workflowTaskFailedErr type to convert it into right format to add an history event for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WorkflowTaskFailedEvent has failure field which may contains different failures. Here it is just error message but other places may set other failures. The best way to refactor this, is to replace workflowTaskFailedError with WorkflowTaskFailure which will contains failedCause enum and error message. I don't know if it worth it. I would leave it as is for now.

Copy link
Contributor

@samarabbas samarabbas left a comment

Choose a reason for hiding this comment

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

Looks good. You can land it after addressing my comment.

@alexshtin alexshtin merged commit d51ef55 into temporalio:master Aug 17, 2020
@alexshtin alexshtin deleted the fix/respond-workflow-task-completed branch August 17, 2020 21:31
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.

respondWorkflowTaskCompleted doesn't fail on bad commands

2 participants