Hello Sanja,
for http://forge.mysql.com/worklog/task.php?id=4374
"Maria - force start if Recovery fails multiple times",
in case recovery has failed many times I need to remove all logs, even
before translog_init() is called (because, if there is a log problem
or log handler bug, there could be a crash in translog_init()).
I'm going to write a simple function which will open the directory and
do "rm maria_log.[0-9]{6}".
While I was looking at ma_loghandler.c I noticed that
/**
@brief Check log files presence
@retval 0 no log files.
@retval 1 there is at least 1 log file in the directory
*/
my_bool translog_is_log_files()
{
MY_DIR *dirp;
uint i;
my_bool rc= FALSE;
/* Finds and removes transaction log files */
if (!(dirp = my_dir(log_descriptor.directory, MYF(MY_DONT_SORT))))
return 1;
for (i= 0; i < dirp->number_off_files; i++)
{
char *file= dirp->dir_entry[i].name;
if (strncmp(file, "maria_log.", 10) == 0 &&
file[10] >= '0' && file[10] <= '9' &&
file[11] >= '0' && file[11] <= '9' &&
file[12] >= '0' && file[12] <= '9' &&
file[13] >= '0' && file[13] <= '9' &&
file[14] >= '0' && file[14] <= '9' &&
file[15] >= '0' && file[15] <= '9' &&
file[16] >= '0' && file[16] <= '9' &&
file[17] >= '0' && file[17] <= '9' &&
file[18] == '\0')
{
rc= TRUE;
break;
}
}
my_dirend(dirp);
return FALSE;
}
has problems.
If the my_dir() fails it returns 1, which does not mean that "there is
at least 1 log file in the directory".
And, if strncmp() is true, we set rc to TRUE, but we return FALSE: rc
is never used.
So, the function always returns "no log files".
I propose that I fix this function and extend it a bit, like this:
I'll rename it to:
my_bool translog_walk_log_filenames(action)
and "action" will be a parameter: either SEARCH_FIRST or DELETE_ALL.
SEARCH_FIRST will be the equivalent of what translog_is_log_files()
does now (return TRUE at first found log), and DELETE_ALL will be what
I need (delete all found logs).
I hope this is ok with you?
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Guilhem Bichot <guilhem@stripped>
/ /|_/ / // /\ \/ /_/ / /__ MySQL France, Lead Software Engineer
/_/ /_/\_, /___/\___\_\___/ Bordeaux, France
<___/ www.mysql.com