MySQL Internals Test Faults
[edit] CONTEXT
Status of this section: up to date 2010-09-08
The assessment of the replication code in the presence of faults is extremely important to increase reliability. In particular, one needs to know if servers will either correctly recovery or print out appropriate error messages thus avoiding unexpected problems in a production environment. To fulfill this needs, we use the macros presented in what follows.
[edit] MACROS
- DBUG_EXECUTE_IF (keyword, code) allows to execute a piece of code if the appropriate dbug instruction is set. In this case, the dbug instruction should be +d,keyword.
- DBUG_EVALUATE_IF (keyword, val1, val2) is used in "if" expressions and returns "val2" if the appropriate dbug instruction is set. Otherwise, it returns "val1". In this case, the dbug instruction should be +d,keyword.
- DBUG_CRASH_ENTER (function) is equivalent to DBUG_ENTER which registers the beginning of a function but in addition to it allows for crashing the server while entering the function if the appropriate dbug instruction is set. In this case, the dbug instruction should be +d,function_crash_enter.
- DBUG_CRASH_RETURN (value) is equivalent to DBUG_RETURN which notifies the end of a function but in addition to it allows for crashing the server while returning from the function if the appropriate dbug instruction is set. In this case, the dbug instruction should be +d,function_crash_return. Note that "function" should be the same string used by the DBUG_ENTER.
- DBUG_CRASH_VOID_RETURN is equivalent to DBUG_VOID_RETURN which notifies the end of a function but in addition to it allows for crashing the server while returning from the function if the appropriate dbug instruction is set. In this case, the dbug instruction should be +d,function_crash_return. Note that "function" should be the same string used by the DBUG_ENTER.
[edit] USAGE
Let us assume the following function:
void function(void)
{
DBUG_CRASH_ENTER("function");
if (DBUG_EVALUATE_IF("process_if", 1, 0))
{
DBUG_EXECUTE_IF("process_code", {
const char *old_proc_info= thd->proc_info;
thd->proc_info= "DBUG sleep";
my_sleep(6000000);
thd->proc_info= old_proc_info;});
}
DBUG_CRASH_VOID_RETURN;
}
To crash the server in the fault points defined above, we need to be SUPER user and execute one of the following commands:
- SET SESSION debug="+d,function_crash_enter"; will crash the server while entering the function.
- SET SESSION debug="+d,function_crash_return"; will crash the server while returning from function.
- SET SESSION debug="+d,process_if"; will execute the code inside the "if".
- SET SESSION debug="+d,process_code"; will execute the "sleep" code.