For example, I may register a defer block to disable failpoint to ensure that it's triggered no matter intermediate error occurs, while I'm going to disable the failpoint on the fly of the code flow early to switch behavior.
Then, one failpoint can be disabled twice and with current implementation, this causes failpoint: failpoint is disabled error.
func foo() {
failpoint.Enable(...)
defer failpoint.Disable(...)
// ... error may occur in this block, thus I need a defer block above
failpoint.Disable(...)
// failpoint has been disabled, but it will be disable again when executing the defer block
}
For example, I may register a
defer
block to disable failpoint to ensure that it's triggered no matter intermediate error occurs, while I'm going to disable the failpoint on the fly of the code flow early to switch behavior.Then, one failpoint can be disabled twice and with current implementation, this causes
failpoint: failpoint is disabled
error.I'd like to make
failpoint.Disable
idempotent.What do you think @lonng @kennytm?