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

Wrap underlying cause for conditional update error #4797

Merged
merged 6 commits into from
Apr 11, 2022

Conversation

vytautas-karpavicius
Copy link
Contributor

What changed?
Instead of using value error execution.ErrConflict lets use error type execution.conflictError which wraps underlying cause.

Why?
Currently it can be very hard to debug certain failures when only thing that is visible in logs or returned via some endpoints is
code:internal message:conditional update failed

Now, underlying cause will be included in error message as well.

How did you test it?

Potential risks

Release notes

Documentation Changes

@vytautas-karpavicius vytautas-karpavicius requested a review from a team April 8, 2022 15:02
}

func (e *conflictError) Error() string {
return fmt.Sprintf("conditional update failed: %s", e.Cause.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Sprintf("conditional update failed: %s", e.Cause.Error())
return fmt.Sprintf("conditional update failed: %v", e.Cause)

Since I haven't actually looked into it in detail before: this should probably be ... %v", e.Cause.

Because:
fmt.Errorf does this: https://github.com/golang/go/blob/master/src/fmt/errors.go#L17-L30
and, with the Error() impl which just returns that message, is basically "eagerly create the full message".
TIL.
That wrapErrs flag later reaches here in the fmt printer: https://github.com/golang/go/blob/master/src/fmt/print.go#L574-L587
which just swaps it with %v for stringifying, and holds onto the error value (which is ignored by Errorf).
TIL 2.

That's... simple and fairly backwards-compatible, but yow. Worse than I expected. Potentially unnecessarily costly and destroys a lot of information for no good reason (doesn't check for or support %+v or %#v because it can't).

Comment on lines 60 to 64
// NewConflictError is only public because it used in workflow/util_test.go
// TODO: refactor those tests
func NewConflictError(cause error) error {
return &conflictError{cause}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

personal preference: require a *testing.T argument for any test-only code. even if it's unused, it makes it rather unambiguous that it's not intended for any other kind of use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is actually a neat idea 👍 . I'm going to do that from now on.

Copy link
Contributor

@Groxx Groxx left a comment

Choose a reason for hiding this comment

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

Small stuff worth thinking about, but LGTM.

Hiding the value (and type if feasible) and using an IsThing func is definitely my personal preference - it's more future-flexible and you can't miss any of the old references, so 👍👍

@coveralls
Copy link

coveralls commented Apr 11, 2022

Pull Request Test Coverage Report for Build edaf25ea-7de7-4406-b49d-7e057268957c

  • 5 of 19 (26.32%) changed or added relevant lines in 4 files are covered.
  • 53 unchanged lines in 11 files lost coverage.
  • Overall coverage decreased (-0.006%) to 57.023%

Changes Missing Coverage Covered Lines Changed/Added Lines %
service/history/decision/handler.go 0 1 0.0%
service/history/historyEngine.go 0 2 0.0%
service/history/execution/context.go 4 15 26.67%
Files with Coverage Reduction New Missed Lines %
client/history/client.go 2 38.58%
client/history/metricClient.go 2 45.3%
service/history/queue/transfer_queue_processor.go 2 56.86%
service/history/shard/context.go 2 66.78%
common/task/fifoTaskScheduler.go 3 84.54%
service/history/task/fetcher.go 3 86.67%
common/types/history.go 4 24.89%
service/frontend/workflowHandler.go 4 60.31%
service/history/handler.go 4 47.6%
service/history/historyEngine.go 13 70.81%
Totals Coverage Status
Change from base Build 144e56d1-f0a5-49d1-a923-230907c96141: -0.006%
Covered Lines: 83979
Relevant Lines: 147272

💛 - Coveralls

@vytautas-karpavicius vytautas-karpavicius merged commit 7a1fe53 into master Apr 11, 2022
@vytautas-karpavicius vytautas-karpavicius deleted the wrap-conflict-err branch April 11, 2022 11:18
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