diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2009-09-29 14:55:36 +0100 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2009-09-29 14:55:36 +0100 |
commit | b7f887652b22d49574860d6948e67f0ea7a83294 (patch) | |
tree | 5cbd4ade8b015904ee232edafe82afe4ec18a853 /dbug | |
parent | 569ca8590c76e75a06d3ec2f320b7ea2b6960072 (diff) | |
download | mariadb-git-b7f887652b22d49574860d6948e67f0ea7a83294.tar.gz |
WL#4828 and BUG#45747
NOTE: Backporting the patch to next-mr.
WL#4828 Augment DBUG_ENTER/DBUG_EXIT to crash MySQL in different functions
-------
The assessment of the replication code in the presence of faults is extremely
import 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.
In order to accomplish this, the current patch refactories the debug macros
already provided in the source code and introduces three new macros that
allows to inject faults, specifically crashes, while entering or exiting a
function or method. For instance, to crash a server while returning from
the init_slave function (see module sql/slave.cc), one needs to do what
follows:
1 - Modify the source replacing DBUG_RETURN by DBUG_CRASH_RETURN;
DBUG_CRASH_RETURN(0);
2 - Use the debug variable to activate dbug instructions:
SET SESSION debug="+d,init_slave_crash_return";
The new macros are briefly described below:
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 activate.
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
activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.
DBUG_CRASH_VOID_RETURN (value) 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 activate. In this case, the dbug instruction should be
"+d,function_crash_return". Note that "function" should be the same string
used by either the DBUG_ENTER or DBUG_CRASH_ENTER.
To inject other faults, for instance, wrong return values, one should rely
on the macros already available. The current patch also removes a set of
macros that were either not being used or were redundant as other macros
could be used to provide the same feature. In the future, we also consider
dynamic instrumentation of the code.
BUG#45747 DBUG_CRASH_* is not setting the strict option
---------
When combining DBUG_CRASH_* with "--debug=d:t:i:A,file" the server crashes
due to a call to the abort function in the DBUG_CRASH_* macro althought the
appropriate keyword has not been set.
Diffstat (limited to 'dbug')
-rw-r--r-- | dbug/dbug.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dbug/dbug.c b/dbug/dbug.c index baf080f5e27..1ea160852eb 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -1665,6 +1665,27 @@ BOOLEAN _db_keyword_(CODE_STATE *cs, const char *keyword) /* * FUNCTION * + * _db_keywords_ test keyword formed by a set of strings for member + * of keyword list + * + * DESCRIPTION + * + * This function is similar to _db_keyword but receives a set of strings to + * be concatenated in order to make the keyword to be compared. + */ + +BOOLEAN _db_keywords_(const char *function, const char *type) +{ + char dest[_DBUG_MAX_FUNC_NAME_ + 1]; + + strxnmov(dest, _DBUG_MAX_FUNC_NAME_, function, type, NULL); + + return _db_strict_keyword_(dest); +} + +/* + * FUNCTION + * * Indent indent a line to the given indentation level * * SYNOPSIS @@ -2281,6 +2302,13 @@ void _db_unlock_file_() pthread_mutex_unlock(&THR_LOCK_dbug); } +const char* _db_get_func_(void) +{ + CODE_STATE *cs= 0; + get_code_state_or_return NULL; + return cs->func; +} + /* * Here we need the definitions of the clock routine. Add your * own for whatever system that you have. |