Skip to content

Commit 03ddc19

Browse files
committed
MDEV-6424: MariaDB server crashes with assertion failure in file ha_innodb.c line 11652
This is not a fix, this is instrumentation to find out is MySQL frm dictionary and InnoDB data dictionary really out-of-sync when this assertion is fired, or is there some other reason (bug).
1 parent 42a398b commit 03ddc19

File tree

2 files changed

+140
-12
lines changed

2 files changed

+140
-12
lines changed

storage/innobase/handler/ha_innodb.cc

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,11 +1998,16 @@ innobase_get_stmt(
19981998
THD* thd, /*!< in: MySQL thread handle */
19991999
size_t* length) /*!< out: length of the SQL statement */
20002000
{
2001-
LEX_STRING* stmt;
2002-
2003-
stmt = thd_query_string(thd);
2004-
*length = stmt->length;
2005-
return(stmt->str);
2001+
const char* query = NULL;
2002+
LEX_STRING *stmt = NULL;
2003+
if (thd) {
2004+
stmt = thd_query_string(thd);
2005+
if (stmt) {
2006+
*length = stmt->length;
2007+
query = stmt->str;
2008+
}
2009+
}
2010+
return (query);
20062011
}
20072012

20082013
/**********************************************************************//**
@@ -6616,7 +6621,66 @@ build_template_field(
66166621
UNIV_MEM_INVALID(templ, sizeof *templ);
66176622
templ->col_no = i;
66186623
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
6619-
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
6624+
6625+
/* If clustered index record field is not found, lets print out
6626+
field names and all the rest to understand why field is not found. */
6627+
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
6628+
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
6629+
dict_field_t* field=NULL;
6630+
size_t size = 0;
6631+
6632+
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
6633+
dict_field_t* ifield = &(clust_index->fields[j]);
6634+
if (ifield && !memcmp(tb_col_name, ifield->name,
6635+
strlen(tb_col_name))) {
6636+
field = ifield;
6637+
break;
6638+
}
6639+
}
6640+
6641+
ib_logf(IB_LOG_LEVEL_INFO,
6642+
"Looking for field %lu name %s from table %s",
6643+
i,
6644+
(tb_col_name ? tb_col_name : "NULL"),
6645+
clust_index->table->name);
6646+
6647+
6648+
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
6649+
dict_field_t* ifield = &(clust_index->fields[j]);
6650+
ib_logf(IB_LOG_LEVEL_INFO,
6651+
"InnoDB Table %s field %lu name %s",
6652+
clust_index->table->name,
6653+
j,
6654+
(ifield ? ifield->name : "NULL"));
6655+
}
6656+
6657+
for(ulint j=0; j < table->s->stored_fields; j++) {
6658+
ib_logf(IB_LOG_LEVEL_INFO,
6659+
"MySQL table %s field %lu name %s",
6660+
table->s->table_name.str,
6661+
j,
6662+
table->field[j]->field_name);
6663+
}
6664+
6665+
ib_logf(IB_LOG_LEVEL_ERROR,
6666+
"Clustered record field for column %lu"
6667+
" not found table n_user_defined %d"
6668+
" index n_user_defined %d"
6669+
" InnoDB table %s field name %s"
6670+
" MySQL table %s field name %s n_fields %d"
6671+
" query %s",
6672+
i,
6673+
clust_index->n_user_defined_cols,
6674+
clust_index->table->n_cols - DATA_N_SYS_COLS,
6675+
clust_index->table->name,
6676+
(field ? field->name : "NULL"),
6677+
table->s->table_name.str,
6678+
(tb_col_name ? tb_col_name : "NULL"),
6679+
table->s->stored_fields,
6680+
innobase_get_stmt(current_thd, &size));
6681+
6682+
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
6683+
}
66206684

66216685
if (dict_index_is_clust(index)) {
66226686
templ->rec_field_no = templ->clust_rec_field_no;

storage/xtradb/handler/ha_innodb.cc

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,11 +2355,16 @@ innobase_get_stmt(
23552355
THD* thd, /*!< in: MySQL thread handle */
23562356
size_t* length) /*!< out: length of the SQL statement */
23572357
{
2358-
LEX_STRING* stmt;
2359-
2360-
stmt = thd_query_string(thd);
2361-
*length = stmt->length;
2362-
return(stmt->str);
2358+
const char* query = NULL;
2359+
LEX_STRING *stmt = NULL;
2360+
if (thd) {
2361+
stmt = thd_query_string(thd);
2362+
if (stmt) {
2363+
*length = stmt->length;
2364+
query = stmt->str;
2365+
}
2366+
}
2367+
return (query);
23632368
}
23642369

23652370
/**********************************************************************//**
@@ -7517,7 +7522,66 @@ build_template_field(
75177522
UNIV_MEM_INVALID(templ, sizeof *templ);
75187523
templ->col_no = i;
75197524
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
7520-
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
7525+
7526+
/* If clustered index record field is not found, lets print out
7527+
field names and all the rest to understand why field is not found. */
7528+
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
7529+
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
7530+
dict_field_t* field=NULL;
7531+
size_t size = 0;
7532+
7533+
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
7534+
dict_field_t* ifield = &(clust_index->fields[j]);
7535+
if (ifield && !memcmp(tb_col_name, ifield->name,
7536+
strlen(tb_col_name))) {
7537+
field = ifield;
7538+
break;
7539+
}
7540+
}
7541+
7542+
ib_logf(IB_LOG_LEVEL_INFO,
7543+
"Looking for field %lu name %s from table %s",
7544+
i,
7545+
(tb_col_name ? tb_col_name : "NULL"),
7546+
clust_index->table->name);
7547+
7548+
7549+
for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
7550+
dict_field_t* ifield = &(clust_index->fields[j]);
7551+
ib_logf(IB_LOG_LEVEL_INFO,
7552+
"InnoDB Table %s field %lu name %s",
7553+
clust_index->table->name,
7554+
j,
7555+
(ifield ? ifield->name : "NULL"));
7556+
}
7557+
7558+
for(ulint j=0; j < table->s->stored_fields; j++) {
7559+
ib_logf(IB_LOG_LEVEL_INFO,
7560+
"MySQL table %s field %lu name %s",
7561+
table->s->table_name.str,
7562+
j,
7563+
table->field[j]->field_name);
7564+
}
7565+
7566+
ib_logf(IB_LOG_LEVEL_ERROR,
7567+
"Clustered record field for column %lu"
7568+
" not found table n_user_defined %d"
7569+
" index n_user_defined %d"
7570+
" InnoDB table %s field name %s"
7571+
" MySQL table %s field name %s n_fields %d"
7572+
" query %s",
7573+
i,
7574+
clust_index->n_user_defined_cols,
7575+
clust_index->table->n_cols - DATA_N_SYS_COLS,
7576+
clust_index->table->name,
7577+
(field ? field->name : "NULL"),
7578+
table->s->table_name.str,
7579+
(tb_col_name ? tb_col_name : "NULL"),
7580+
table->s->stored_fields,
7581+
innobase_get_stmt(current_thd, &size));
7582+
7583+
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
7584+
}
75217585

75227586
if (dict_index_is_clust(index)) {
75237587
templ->rec_field_no = templ->clust_rec_field_no;

0 commit comments

Comments
 (0)