-
Notifications
You must be signed in to change notification settings - Fork 596
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
feat(error): report the error's source chain through psql #13264
Conversation
Signed-off-by: Bugen Zhao <[email protected]>
8b89b22
to
a474acb
Compare
Signed-off-by: Bugen Zhao <[email protected]>
@@ -44,8 +44,9 @@ pub enum PsqlError { | |||
#[error(transparent)] | |||
Internal(BoxedError), | |||
|
|||
#[error("Panicked when processing: {0}.\n | |||
This is a bug. We would appreciate a bug report at https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Fbug&template=bug_report.yml.")] | |||
#[error("Panicked when processing: {0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that mutli-line string already contains a \n
at the line break. 🤡
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report
@@ Coverage Diff @@
## main #13264 +/- ##
==========================================
+ Coverage 67.77% 67.85% +0.07%
==========================================
Files 1525 1525
Lines 259116 259118 +2
==========================================
+ Hits 175605 175813 +208
+ Misses 83511 83305 -206
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 23 files with indirect coverage changes 📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM! Just one concern: the *
representing omitted suffix seems unnecessary, since we don't lose any information actually, the omitted information is just printed on the next line.
src/utils/pgwire/src/pg_message.rs
Outdated
let msg = if env_var_is_true("RW_PRETTY_ERROR") { | ||
format!("{:#}", error.as_ref().as_report()) | ||
} else { | ||
format!("{}", error.as_ref().as_report()) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we ever want the Compact
behavior? I prefer not to offer too many choices unless there's a good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, can we add a test (maybe expect test) for an error message to demonstrate the error format?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we ever want the
Compact
behavior?
This could be a temporary workaround. 😕 SQL logic tests and planner tests are heavily relying on the error message, and I don't want to mess them into this PR.
Also, I'm not sure if the developers writing SQL logic tests are intended to match the full messages (instead of the interesting part only), like below. If so, then Pretty
will be less friendly.
risingwave/e2e_test/source/basic/ddl.slt
Line 21 in 761130c
statement error internal error: invalid digit found in string |
risingwave/e2e_test/ddl/invalid_operation.slt
Line 267 in 761130c
statement error QueryError: Bind error: update modifying the PK column is unsupported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, can we add a test (maybe expect test) for an error message to demonstrate the error format?
There's one in thiserror-ext
. Do you want another one for RisingWave's real cases? Then I'll write an integration test connecting to the pgwire
server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a temporary workaround. 😕 SQL logic tests and planner tests are heavily relying on the error message, and I don't want to mess them into this PR.
If DX is the only concern or trouble, I think we should try to fix it now or later. At least pretty should be the default behavior. (Otherwise what's the meaning of these work? lol)
I think it's ok to update tests in this PR, as the core changes are very small.
If you don't want to do it now, maybe we should introduce RW_COMPACT_ERROR
, instead of RW_PRETTY_ERROR
.
Do you want another one for RisingWave's real cases?
Yes, that's preferred. So that we can prevent either risingwave
or thiserror-ext
's unexpected changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update error messages in slt
and pretty is always enabled now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want another one for RisingWave's real cases?
Yes, that's preferred. So that we can prevent either
risingwave
orthiserror-ext
's unexpected changes.
I find the error message is not good enough... Maybe let's do this in future PRs. 🤡
- Manually implemented
caused by
:
risingwave/src/frontend/src/binder/expr/mod.rs
Lines 71 to 76 in e0d4500
self.bind_expr_inner(expr.clone()).map_err(|e| { RwError::from(ErrorCode::BindError(format!( "failed to bind expression: {}\n\nCaused by:\n {}", expr, e ))) }) - RPC boundary: feat(error): preserve error's source chain across gRPC boundary #13282
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's OK if the error message is not good. Just have a expect-test
to let us know what's the current status is enough. 🤣 And we can see more easily how it's improved in future PRs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find writing tests with madsim is the easiest way, but the udf example does not work there. 🤡
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤡
Similar concern, I think the |
I copied |
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
e2e_test/error_ui/main.slt
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄🤣
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Follow-up of #13248. Visit the error's source chain and get it printed through psql interface. This is achieved by
thiserror_ext::Report
.Note that we now interpolate the inner error message into the outer one, so the most of time, printing the out-most error should include all information. However, this is not a good practice that the community will follow (examples: awslabs/aws-sdk-rust#657, EmbarkStudios/rust-ecosystem#20). As a result, we lose the opportunity to visit the source of errors from 3rd-party libraries (like
tonic::transport::Error
), which leads to issues like #13163.As discussed in #11443 (comment),
snafu
provides a clever way to handle these two conventions together by trimming out the duplicated suffixes in the error message.thiserror-ext
adapts it to better suit our needs.Preview
Unsure about which format is preferred, I introduce a env variableRW_PRETTY_ERROR
to switch between these two formats:The style will always be
Pretty
.CompactNOT AVAILABLE:The experience will be majorly the same, except that we're now correctly visiting the source chain to avoid losing any context.
Pretty:
The sources will be printed line by line.
TheREMOVED*
symbol indicates that the suffix of the message (i.e., the message of the inner error) has been cleaned up.Tests
There's a new series of tests under
e2e_test/error_ui/main.slt
to track the error reporting of some selected SQL statements.risingwave/e2e_test/error_ui/main.slt
Lines 1 to 11 in 41c88a5
See https://github.com/risingwavelabs/risingwave/blob/d60b7e13a69b2ba56cc8411e6317662ed9e39f03/e2e_test/error_ui/README.md for details.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.