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

Fix conflict error handling #2469

Merged

Conversation

alexshtin
Copy link
Member

@alexshtin alexshtin commented Feb 5, 2022

What changed?

  • Fix few bugs in CAS failed operation error logic.
  • Improve error messages.
  • Add CAS error logging.
  • Add comments to clarify error handling logic.
  • Rename generic var and param names to be more specific.

Why?
N/A

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 5, 2022 08:49
@alexshtin alexshtin force-pushed the feature/fix-confict-error-handling branch from b19da82 to e7a384b Compare February 5, 2022 09:07
Comment on lines +733 to +735
if err == consts.ErrConflict {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i believe the logic should get rid of consts.ErrConflict in the long term

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a TODO for this (not by me), but I am not ready for this. Yet.

Comment on lines +475 to 493
if err != nil {
shard.GetLogger().Error(
"Persistent store operation Failure",
"Update workflow execution operation failed.",
tag.WorkflowNamespaceID(request.UpdateWorkflowMutation.ExecutionInfo.NamespaceId),
tag.WorkflowID(request.UpdateWorkflowMutation.ExecutionInfo.WorkflowId),
tag.WorkflowRunID(request.UpdateWorkflowMutation.ExecutionState.RunId),
tag.StoreOperationUpdateWorkflowExecution,
tag.Error(err),
)
return nil, err
switch err.(type) {
case *persistence.CurrentWorkflowConditionFailedError,
*persistence.WorkflowConditionFailedError,
*persistence.ConditionFailedError:
// TODO get rid of ErrConflict
return nil, consts.ErrConflict
default:
return nil, err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if the intention is to emit error logs whenever error is encountered, then i would suggest log when error is generated

Copy link
Member Author

Choose a reason for hiding this comment

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

I follow the rule: "Error should be propagated or handled. Not both". It gets propagated to this point and this substitution is sort of handling and good place to log it. I know we lost error call stack in this case.

@yiminc
Copy link
Member

yiminc commented Feb 6, 2022

Please update the PR description to include some context.

Comment on lines +79 to +82
if conflictRecord["[applied]"].(bool) {
// Should never happen. All records in batch should have [applied]=false.
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i guess this additional check may not be necessary

@alexshtin alexshtin merged commit 01d071a into temporalio:master Feb 9, 2022
@alexshtin alexshtin deleted the feature/fix-confict-error-handling branch February 9, 2022 03:49
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.

3 participants