Skip to content

Conversation

@gengliqi
Copy link
Member

@gengliqi gengliqi commented Feb 5, 2020

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)

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,
Copy link
Member

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.

($name:expr, $cond:expr, $e:expr) => {{
if $cond {
fail_point!($name, $e);
if let Some(res) = $crate::eval($name, $e, || $cond) {
Copy link
Member

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.

Copy link
Collaborator

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?

@brson
Copy link
Collaborator

brson commented Feb 16, 2020

Here's a patch to fix CI: #49

Copy link
Collaborator

@brson brson left a 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.

($name:expr, $cond:expr, $e:expr) => {{
if $cond {
fail_point!($name, $e);
if let Some(res) = $crate::eval($name, $e, || $cond) {
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants