Skip to content

Commit b12e8d9

Browse files
committed
MENT-2235 Aria engine: log initialization failed
Some thing causes the aria_log_control file to be larger than the expected 52 bytes. The control file has the correct information but somehow it is filled up with ox00 bytes up to 512 bytes. This could have happened in case of a file system crash that enlarged the file to the sector boundary. Fixed that aria will ignore bytes outside of it's expected Other things: - Fixed wrong DBUG_ASSERT() in my_malloc_size_cb_func() that could cause crashes in debug binaries during Aria recovery.
1 parent 1331c73 commit b12e8d9

File tree

2 files changed

+45
-10
lines changed

2 files changed

+45
-10
lines changed

sql/mysqld.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3635,12 +3635,12 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
36353635
#endif
36363636

36373637
/*
3638-
When thread specific is set, both mysqld_server_initialized and thd
3639-
must be set, and we check that with DBUG_ASSERT.
3640-
3641-
However, do not crash, if current_thd is NULL, in release version.
3638+
is_thread_specific is only relevant when a THD exist and the server
3639+
has fully started. is_thread_specific can be set during recovery by
3640+
Aria for functions that are normally only run in one thread.
3641+
However InnoDB sets thd early, so we can use it.
36423642
*/
3643-
DBUG_ASSERT(!is_thread_specific || (mysqld_server_initialized && thd));
3643+
DBUG_ASSERT(!is_thread_specific || thd || !plugins_are_initialized);
36443644

36453645
if (is_thread_specific && likely(thd)) /* If thread specific memory */
36463646
{

storage/maria/ma_control_file.c

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
275275
my_bool wait_for_lock)
276276
{
277277
uchar buffer[CF_MAX_SIZE];
278-
char name[FN_REFLEN], errmsg_buff[256];
278+
char name[FN_REFLEN], errmsg_buff[512];
279279
const char *errmsg, *lock_failed_errmsg= "Could not get an exclusive lock;"
280280
" file is probably in use by another process";
281281
uint new_cf_create_time_size, new_cf_changeable_size, new_block_size;
@@ -399,10 +399,14 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
399399

400400
if (new_cf_create_time_size < CF_MIN_CREATE_TIME_TOTAL_SIZE ||
401401
new_cf_changeable_size < CF_MIN_CHANGEABLE_TOTAL_SIZE ||
402-
new_cf_create_time_size + new_cf_changeable_size != file_size)
402+
new_cf_create_time_size + new_cf_changeable_size > file_size)
403403
{
404404
error= CONTROL_FILE_INCONSISTENT_INFORMATION;
405-
errmsg= "Sizes stored in control file are inconsistent";
405+
sprintf(errmsg_buff,
406+
"Sizes stored in control file are inconsistent. "
407+
"create_time_size: %u changeable_size: %u file_size: %llu",
408+
new_cf_create_time_size, new_cf_changeable_size, (ulonglong) file_size);
409+
errmsg= errmsg_buff;
406410
goto err;
407411
}
408412

@@ -613,13 +617,28 @@ my_bool ma_control_file_inited(void)
613617
return (control_file_fd >= 0);
614618
}
615619

620+
621+
622+
static int check_zerofill(uchar *buffer, ulonglong offset, ulonglong length)
623+
{
624+
uchar *pos= buffer + offset, *end= buffer+length;
625+
while (pos < end)
626+
{
627+
if (*pos++)
628+
return 1;
629+
}
630+
return 0;
631+
}
632+
633+
616634
/**
617635
Print content of aria_log_control file
618636
*/
619637

620638
my_bool print_aria_log_control()
621639
{
622640
uchar buffer[CF_MAX_SIZE];
641+
char errmsg_buff[512];
623642
char name[FN_REFLEN], uuid_str[MY_UUID_STRING_LENGTH+1];
624643
const char *errmsg;
625644
uint new_cf_create_time_size, new_cf_changeable_size;
@@ -696,10 +715,14 @@ my_bool print_aria_log_control()
696715

697716
if (new_cf_create_time_size < CF_MIN_CREATE_TIME_TOTAL_SIZE ||
698717
new_cf_changeable_size < CF_MIN_CHANGEABLE_TOTAL_SIZE ||
699-
new_cf_create_time_size + new_cf_changeable_size != file_size)
718+
new_cf_create_time_size + new_cf_changeable_size > file_size)
700719
{
701720
error= CONTROL_FILE_INCONSISTENT_INFORMATION;
702-
errmsg= "Sizes stored in control file are inconsistent";
721+
sprintf(errmsg_buff,
722+
"Sizes stored in control file are inconsistent. "
723+
"create_time_size: %u changeable_size: %u file_size: %llu",
724+
new_cf_create_time_size, new_cf_changeable_size, (ulonglong) file_size);
725+
errmsg= errmsg_buff;
703726
goto err;
704727
}
705728
checkpoint_lsn= lsn_korr(buffer + new_cf_create_time_size +
@@ -723,6 +746,18 @@ my_bool print_aria_log_control()
723746
(buffer + new_cf_create_time_size + CF_RECOV_FAIL_OFFSET)[0];
724747
printf("recovery_failures: %u\n", recovery_fails);
725748
}
749+
if (check_zerofill(buffer, new_cf_create_time_size + new_cf_changeable_size, file_size))
750+
{
751+
printf("Warning: %s file_size is %llu (should be %llu) and contains unknown data.\n"
752+
"It will still work but should be examined.\n",
753+
name, (ulonglong) file_size,
754+
(ulonglong) (new_cf_create_time_size + new_cf_changeable_size));
755+
}
756+
else if (new_cf_create_time_size + new_cf_changeable_size < file_size)
757+
printf("Note: file_size (%llu) is bigger than the expected file size %llu.\n"
758+
"This is unexpected but will not cause any issues.\n",
759+
(ulonglong) file_size,
760+
(ulonglong) (new_cf_create_time_size + new_cf_changeable_size));
726761
mysql_file_close(file, MYF(0));
727762
DBUG_RETURN(0);
728763

0 commit comments

Comments
 (0)