-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add backtrace option to errors #151
Conversation
@@ -163,8 +163,11 @@ fn evaluate_expression( | |||
.iter() | |||
.zip(schema.fields()) | |||
.map(|(expr, field)| evaluate_expression(expr, batch, Some(field.data_type()))); | |||
let mut fields = output_schema.all_fields(); |
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 code obviously won't merge. was just a way to test via inducing an error, and I put it here in case anyone wants to play with this PR locally as part of reviewing.
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 looks awesome - i ran into the same issues when debugging myself! so should we have a macro do a bunch of the From<ErrorType> for Error
so we get backtraces for all our error types?
So, I think we'll have to undo some of the work when |
bba03bc
to
bc81d5b
Compare
bc81d5b
to
d10ecfb
Compare
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.
LGTM - i like that we have a good plan for removing this once error_generic_member_access
stabilizes. One nit: maybe we should open an issue to track that and just call it blocked until stabilization?
Good call: #157 |
d10ecfb
to
fcd8cb0
Compare
} | ||
} | ||
|
||
macro_rules! from_with_backtrace( |
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.
Isn't this more code with the macro given you are only implementing for 2 error types?
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.
yes. the idea is that it's really easy in the future to add more if you need it to debug something
When debugging it can be difficult to know where an error occurred if it is created in numerous places. For example, today if there's an error in expression eval and you run
dump-table
, you might simply see:But where in the numerous places arrow errors occur did this happen? Tracking this down can be tricky.
It turns out
thiserror
(the crate we use to create ourError
class) does have support for backtrace capture (see the fourth code-block here). However, it relies on a nightly only api (provide which relies on error_generic_member_access), so we can't use it.This PR adds manual backtrace capture to our error type. We do this by:
Backtraced
variant, which captures the error and a backtraceFrom
trait for errors where we want the backtrace.Arrow
errors, which are all over the place in our client code. But in the future, when debugging an issue, it will be easy to move other error types to do this as needed.This means that for errors we add this manual
From
, a backtrace will be captured at the point they are converted into adeltakernel::Error
. This is usually via a?
somewhere in the kernel, so it is useful for debugging.We also ensure that we only do this wrapping if backtracing is enabled (usually via
RUST_BACKTRACE=1
). Otherwise the wrapping method is a no-op, so this should have minimal perf impact.Finally, we augment the
dump-table
command to pretty-print any errors it gets, which makes the backtrace more readable.Now, we can get a nice error like this:
We should be able to revert back to automatic backtracing via
thiserror
whenerror_generic_member_access
stabilizes.