Skip to content

Failpoint

disksing edited this page Jan 21, 2022 · 4 revisions

Failpoint

client-go uses pingcap/failpoint for failpoint injections, which are mainly used for tests.

As a library, client-go expects the failpoints defined there can be triggered by external users. For this reason, the usage of failpoints in client-go differs from the official recommendation.

Specifically, instead of relying on code generation, client-go's failpoint uses EvalFailpoint directly to determine whether a failpoint has been injected.

Obviously this poses a performance issue, so we define an additional short-circuit flag that makes client-go skip all failpoint checks under normal circumstances. If the library user needs to use failpoint (usually in tests), then it is responsible for calling EnableFailpoints() to turn off the short-circuit flag.

Note in particular that EnableFailpoints() needs to be called before any client code is used to avoid data race.

Clone this wiki locally