-
Notifications
You must be signed in to change notification settings - Fork 590
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
refactor(error): eliminate most RwError
usages in common
crate
#13588
Conversation
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Signed-off-by: Bugen Zhao <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #13588 +/- ##
==========================================
- Coverage 68.18% 68.13% -0.05%
==========================================
Files 1520 1519 -1
Lines 261483 261375 -108
==========================================
- Hits 178289 178097 -192
- Misses 83194 83278 +84
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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!
Signed-off-by: Bugen Zhao <[email protected]>
a1eaf84
to
1c3a538
Compare
Signed-off-by: Bugen Zhao <[email protected]>
The error message is much more readable 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.
LGTM! Thanks for your elegant work! Could you please write something like an error-handling guide?
#[source] | ||
inner: std::process::ExitStatusError, | ||
stdout: String, | ||
stderr: String, |
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.
#[source]
will generate From<ExitStatusError>
for JeprofError
right? But how are stdout
and stderr
set?
Does this work because of thiserror_ext::ContextInto
which generates into_exit_error
which will retain the source error as inner
and set the arguments for stdout
and stderr
?
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.
Does this work because of
thiserror_ext::ContextInto
which generatesinto_exit_error
which will retain the source error asinner
and set the arguments forstdout
andstderr
?
Exactly! I'll refine the documentation of thiserror_ext
once it gets more stable.
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.
#[source]
will generateFrom<ExitStatusError>
forJeprofError
right?
This is not accurate. Only #[from]
will generate From
impl, while #[source]
only helps us to correctly maintain the source chain with source()
method.
/// Find `column_desc` in `field_descs` by name. | ||
pub fn field(&self, name: &String) -> crate::error::Result<(ColumnDesc, i32)> { | ||
if let DataType::Struct { .. } = self.data_type { | ||
for (index, col) in self.field_descs.iter().enumerate() { | ||
if col.name == *name { | ||
return Ok((col.clone(), index as i32)); | ||
} | ||
} | ||
Err(ErrorCode::ItemNotFound(format!("Invalid field name: {}", name)).into()) | ||
} else { | ||
Err(ErrorCode::ItemNotFound(format!( | ||
"Cannot get field from non nested column: {}", | ||
self.name | ||
)) | ||
.into()) | ||
} | ||
} | ||
|
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 is a dead method?
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. I don't find any references.
@@ -136,7 +136,7 @@ pub fn cdc_table_name_column_desc() -> ColumnDesc { | |||
/// The local system catalog reader in the frontend node. | |||
#[async_trait] | |||
pub trait SysCatalogReader: Sync + Send + 'static { | |||
async fn read_table(&self, table_id: &TableId) -> Result<Vec<OwnedRow>>; | |||
async fn read_table(&self, table_id: &TableId) -> Result<Vec<OwnedRow>, BoxedError>; |
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.
Will BoxedError
be abused after removing RwError
?
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.
Since this is a trait, we have no information about how the users may have implemented it, so does the error type. It seems a common practice to let trait methods return Box<dyn Error>
. Similar ideas are applied to sqllogictest::AsyncDB
.
@@ -1001,6 +1000,24 @@ impl ToText for crate::types::Interval { | |||
} | |||
} | |||
|
|||
/// Error type for parsing an [`Interval`]. | |||
#[derive(thiserror::Error, Debug, thiserror_ext::Construct)] |
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.
Is there any big difference between IntervalParseError::Invalid
and IntervalParseError::invalid
? Given that the former one is also a special function?
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.
- One can pass any
impl Into<String>
with constructors. - Also, if there's a
backtrace
field, it can also be automatically generated. - If there's a newtype wrapper (error-handling: simplify boxed error definition #13215), it'll be directly implemented on the wrapper type.
#[automatically_derived]
impl IntervalParseError {
/// Constructs a [`IntervalParseError::Invalid`] variant.
pub fn invalid(arg_0: impl Into<String>) -> Self {
IntervalParseError::Invalid { 0: arg_0.into() }.into()
}
}
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
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🐮
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 often forget why on earth do we want to eliminate big RwError
. Do you have a tldr? 🤪
What's the largest benefit?
The worst part of These two roles are not that compatible. For example, the leaf error usually contains a message field only, while the root error is likely to be simply some risingwave/src/common/src/error.rs Lines 151 to 161 in b16bbcc
There're also other reasons for removing
|
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Eliminate most
RwError
usages in thecommon
crate. #4077To achieve that, one must not hesitate to define per-module error types. Examples:
risingwave/src/common/heap_profiling/src/jeprof.rs
Lines 20 to 32 in 05ab5e1
risingwave/src/common/src/types/postgres_type.rs
Lines 51 to 53 in 05ab5e1
The remaining ones are:
ArrayError
session_config
, which is conflict with refactor(frontend): config session variable using proc-macro #13554Checklist
./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.