-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`roachpb.Error` has long been poor to work with. It could only transport structured errors for a hard-coded enum message (`ErrorDetail`) and had a complex and circuituous interaction with the standard library's `error` type: `pErr.GoError()` would return an `error` that was sometimes just `pErr` itself (hidden behind an identical type); other times it was an `UnhandledRetryableError` wrapping `pErr`, and then of course sometimes it would be the structured error from which `pErr` was created in the first place. Thanks to `cockroachdb/errors`, there's a much better option around, namely `errorspb.EncodedError` which has powerful capabilities to essentially carry any error across RPC boundaries (and notably does so "out of the box" for protobuf-backed errors) while retaining its original structure, as long as the error type is known on both sides of the RPC. The simplifications that result from this primitive would be enough to motivate this change in itself, but additionally after this change we will be able to reliably detect context cancellations, etc, without relying on error-prone and insecure string matching. Going into more detail, this commit makes the following changes: - adds an `EncodedError` to `Error` - deprecates the following fields on `Error`, which are henceforth deduced from the `EncodedError` where present: - `transaction_restart` - `message` - `detail` These fields are populated for the time being so that 20.2 nodes understand the errors emitted by 21.1 nodes. In 21.2, we can drop them all. - deprecates `(*Error).SetDetail`, which has only one real caller anyway (and that caller will be able to replace EncodedError instead once 21.2 comes around). - makes `(*Error).SafeFormat` redact properly based on `EncodedError` (yay!), though there's a larger TODO that's left for a follow-up change (around the fact that error details can depend on the surrounding Error for rendering, particularly relevant when SetTxn is called) We can capitalize on EncodedError before the 21.2 cycle, but this is left for future PRs. Fixes #54939. Release note: None
- Loading branch information
Showing
21 changed files
with
496 additions
and
316 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.