sql,*: error handling improvements#35821
Merged
craig[bot] merged 9 commits intocockroachdb:masterfrom Mar 18, 2019
Merged
Conversation
Member
This was referenced Mar 16, 2019
4d371a4 to
695d7aa
Compare
craig bot
pushed a commit
that referenced
this pull request
Mar 16, 2019
35824: sqlbase: fix invalid uses of `pgerorr.NewErrorf` r=knz a=knz This goes alongside #35821. It's not valid to pass an opaque string as the `format` argument of a formatting function. Also, wrap long lines. Release note: None Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
... like it had always been intended. Release note: None
RaduBerinde
approved these changes
Mar 16, 2019
Member
RaduBerinde
left a comment
There was a problem hiding this comment.
LGTM. This is great, thank you for the patience to go through all these!
Release note: None
Contributor
Author
|
Note to self: before this merges review the CCL code too. |
The `depth` argument wasn't incremented properly, causing one level to be lost. Release note: None
We wish to embed stack traces in Sentry reports for internal errors. However, since internal errors flow through RPCs as protobufs and raven.Stacktrace objects (used for Sentry reports) do not have a protobuf encoding, we want another serialization format. This patch provides this by means of an encapsulation of `raven.Stacktrace` as `log.StackTrace`, with working `Encode`/`Decode` methods. Release note: None
This patch splits `log.SendCrashReport` into the following pieces: - `log.ShouldSendReport` tests whether a report should be assembled+sent; - `log.SendReport` sends a report from a message and zero or more reportalbe objects. - `log.ReportableObject` aliases `raven.Interface` and is instantiated by: - `log.NewReportableMessage()` for simple strings. - `log.NewException()` for string + stack trace. Release note: None
cb01838 to
02c30ae
Compare
This patch achieves the following: - it extends the pgerror.Error object with a new field `SafeDetail`, aimed to contain non-PII details and thuis suitable for inclusion in reporting. - it populates the scrubbed format + safe arguments of error messages in `SafeDetail` using the same logic as `log.ReportablesToSafeError`. - it captures the stack trace in `SafeDetail` but also `Detail` so that a human user seeing the error can report the stack trace with a manually created issue. - it extends `pgerror.Wrapf()` so as to combine details in an existing error with the details of the point that calls `pgerror.Wrapf()`. - it provides a custom `fmt.Formatter` for `pgerror.Error`, so that: - `%#v` will now print the pg error code in addition to the message; - `%+v` will now print the source, code, message and stored `SafeDetail`. Release note: None
This patch ensures that a sentry report is created when a pg error with CodeInternalError flows out of the execution layers. Release note: None
Release note: None
This patch adds a linter to prevent uses of `errors.Wrapf` in `sql` and sub-packages, to promote use of `pgerror.Wrapf` and `pgerror.NewAssertionErrorWithWrappedErrf` instead. It also replaces all the uses of `errors.Wrap`/`Wrapf` accordingly, removes a few uses of `panic()`, and adds a few calls to `pgerror.NewAssertionErrorf`. Release note: None
Contributor
Author
|
This ship is sailing 🌊 bors r+ |
craig bot
pushed a commit
that referenced
this pull request
Mar 18, 2019
35821: sql,*: error handling improvements r=knz a=knz Subsumes #35825. Subsumes #35820. This PR replaces uses of `errors.New`, `errors.Errorf` and `errors.Wrap` by their `pgerror` equivalents. It also embeds the subsumed PRs; see those PR's discussion for details. Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
Contributor
Build succeeded |
knz
added a commit
to knz/cockroach
that referenced
this pull request
Mar 21, 2019
This an oversight in cockroachdb#35821 - all the errors in `inbound.go` use `errors.Wrap`, this one must too. (This and the rest of the file should really use `pgerror.Wrap`, which in combination with cockroachdb#36023 would be innocuous. But that's an aside.) In either case, all the functionality in this file requires wrapping, not flattening the error into a string. Release note: None
Contributor
|
I think this PR was too eager to replace Wrapfs with NewAssertionErrors. Specifically the ones in schema_changer.go occur in the context of a client.Txn where the error (or its cause) is inspected. This replaces potentially-retriable errors with assertion errors which can cause schema changes to fail unnecessarily. I'll fix the ones that I'm specifically finding to be problems, but it makes me nervous to see how many Wrapfs were replaced with assertion errors instead of using the new Wrapf. |
bdarnell
added a commit
to bdarnell/cockroach
that referenced
this pull request
Jul 9, 2019
The AssertionError wrappers hid the retryable nature of the errors, causing failures in cases that should have been retried. Most of the affected wrappers were changed from Wrapf to NewAssertionError in cockroachdb#35821. I looked at all uses of NewAssertionErrorWithWrappedErrf and changed all the ones where a client.Txn was in scope unless they were clearly not going to be txn-related (for example, proto unmarshaling errors). Release note (bug fix): Transaction retries in schema changes are again handled correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Subsumes #35825.
Subsumes #35820.
This PR replaces uses of
errors.New,errors.Errorfanderrors.Wrapby theirpgerrorequivalents. It also embeds the subsumed PRs; see those PR's discussion for details.