-
Notifications
You must be signed in to change notification settings - Fork 40
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
fail: check condition only when its failpoint is open #48
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Liqi Geng <[email protected]>
pub fn eval<R, F: FnOnce(Option<String>) -> R>(name: &str, f: F) -> Option<R> { | ||
pub fn eval<R, F: FnOnce(Option<String>) -> R>( | ||
name: &str, | ||
f: F, |
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.
Can use impl trait here too.
return res; | ||
} | ||
}}; | ||
($name:expr, $cond:expr, $e:expr) => {{ | ||
if $cond { | ||
fail_point!($name, $e); | ||
if let Some(res) = $crate::eval($name, $e, || $cond) { |
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 makes it hard to share mutable states between $cond and $e
.
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.
If true then we better add a test case that captures the expected behavior.
@gengliqi can you try adding a test case that shares mutable references between the two expressions and seeing if they worked previously but don't work after this patch?
Here's a patch to fix CI: #49 |
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.
Per @BusyJay there is question about whether this patch regresses an existing capability. I've asked for a test case to capture that scenario.
return res; | ||
} | ||
}}; | ||
($name:expr, $cond:expr, $e:expr) => {{ | ||
if $cond { | ||
fail_point!($name, $e); | ||
if let Some(res) = $crate::eval($name, $e, || $cond) { |
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.
If true then we better add a test case that captures the expected behavior.
@gengliqi can you try adding a test case that shares mutable references between the two expressions and seeing if they worked previously but don't work after this patch?
Signed-off-by: Liqi Geng [email protected]
The check-condition code in failpoint runs all the time even it is not open.
It may lead to bad performance if checking the condition is very expensive
or misuse if someone modifies some variables in check-condition code and it's valid only when its failpoint is open. (my guess scenario)