Skip to content

Latest commit

 

History

History
 
 

README.md

What is failpoint?

Failpoint is a fault injection testing framework that can precisely inject faults at any location within a function, helping to test system fault tolerance and stability.
Writing failpoints does not require modifying the source code of the system under test (SUT), making it suitable for both R&D engineers (RD) and quality assurance (QA).

How to use failpoint?

Defining a failpoint

Defining a failpoint is very simple. Here's an example:

RULE bdb_ha_get_leader_exception
CLASS com.starrocks.ha.BDBHA
METHOD getLeader()
HELPER com.starrocks.failpoint.FailPointHelper
IF shouldTrigger("bdb_ha_get_leader_exception")
DO throw new RuntimeException("failpoint triggered");
ENDRULE

This is a failpoint written in Byteman script that triggers an exception when calling com.starrocks.ha.BDBHA.getLeader.

  • RULE: The name of the rule.
  • CLASS: The class name where the fault is injected.
  • METHOD: The method name where the fault is injected. You can also specify parameter types for overloaded methods, e.g., getLeader(int).
  • HELPER: The helper class. All functions in this class can be used in the IF and DO blocks below.
  • IF: The trigger condition. Here, shouldTrigger is fixed, with the parameter being the RULE name.
  • DO: The fault action. In the example, it throws an exception. Other options include:
  • ENDRULE: Marks the end of the rule definition.

Using failpoints

  1. Place the written Byteman script in conf/failpoint.btm and add the startup option --failpoint.

  2. Use admin commands to trigger failpoints:

// Enable permanently
ADMIN ENABLE FAILPOINT 'bdb_ha_get_leader_exception' ON FRONTEND;

// Disable after 10 executions
ADMIN ENABLE FAILPOINT 'bdb_ha_get_leader_exception' WITH 10 TIMES ON FRONTEND;

// Trigger with 10% probability
ADMIN ENABLE FAILPOINT 'bdb_ha_get_leader_exception' WITH 0.1 PROBABILITY ON FRONTEND;

// Disable
ADMIN DISABLE FAILPOINT 'bdb_ha_get_leader_exception' ON FRONTEND;