fail: check condition only when its failpoint is open#48
Open
gengliqi wants to merge 1 commit intotikv:masterfrom
Open
fail: check condition only when its failpoint is open#48gengliqi wants to merge 1 commit intotikv:masterfrom
gengliqi wants to merge 1 commit intotikv:masterfrom
Conversation
Signed-off-by: Liqi Geng <gengliqiii@gmail.com>
BusyJay
reviewed
Feb 5, 2020
BusyJay
reviewed
Feb 5, 2020
| 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, |
BusyJay
reviewed
Feb 5, 2020
| ($name:expr, $cond:expr, $e:expr) => {{ | ||
| if $cond { | ||
| fail_point!($name, $e); | ||
| if let Some(res) = $crate::eval($name, $e, || $cond) { |
Member
There was a problem hiding this comment.
This makes it hard to share mutable states between $cond and $e.
Collaborator
There was a problem hiding this comment.
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?
Collaborator
|
Here's a patch to fix CI: #49 |
brson
requested changes
Feb 16, 2020
| ($name:expr, $cond:expr, $e:expr) => {{ | ||
| if $cond { | ||
| fail_point!($name, $e); | ||
| if let Some(res) = $crate::eval($name, $e, || $cond) { |
Collaborator
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Liqi Geng gengliqiii@gmail.com
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)