Skip to content

Commit

Permalink
MDEV-6424: MariaDB server crashes with assertion failure in file ha_i…
Browse files Browse the repository at this point in the history
…nnodb.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).
  • Loading branch information
Jan Lindström committed Nov 17, 2016
1 parent 42a398b commit 03ddc19
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 12 deletions.
76 changes: 70 additions & 6 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1998,11 +1998,16 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
LEX_STRING* stmt;

stmt = thd_query_string(thd);
*length = stmt->length;
return(stmt->str);
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
}
return (query);
}

/**********************************************************************//**
Expand Down Expand Up @@ -6616,7 +6621,66 @@ build_template_field(
UNIV_MEM_INVALID(templ, sizeof *templ);
templ->col_no = i;
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);

/* If clustered index record field is not found, lets print out
field names and all the rest to understand why field is not found. */
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
dict_field_t* field=NULL;
size_t size = 0;

for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
if (ifield && !memcmp(tb_col_name, ifield->name,
strlen(tb_col_name))) {
field = ifield;
break;
}
}

ib_logf(IB_LOG_LEVEL_INFO,
"Looking for field %lu name %s from table %s",
i,
(tb_col_name ? tb_col_name : "NULL"),
clust_index->table->name);


for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
ib_logf(IB_LOG_LEVEL_INFO,
"InnoDB Table %s field %lu name %s",
clust_index->table->name,
j,
(ifield ? ifield->name : "NULL"));
}

for(ulint j=0; j < table->s->stored_fields; j++) {
ib_logf(IB_LOG_LEVEL_INFO,
"MySQL table %s field %lu name %s",
table->s->table_name.str,
j,
table->field[j]->field_name);
}

ib_logf(IB_LOG_LEVEL_ERROR,
"Clustered record field for column %lu"
" not found table n_user_defined %d"
" index n_user_defined %d"
" InnoDB table %s field name %s"
" MySQL table %s field name %s n_fields %d"
" query %s",
i,
clust_index->n_user_defined_cols,
clust_index->table->n_cols - DATA_N_SYS_COLS,
clust_index->table->name,
(field ? field->name : "NULL"),
table->s->table_name.str,
(tb_col_name ? tb_col_name : "NULL"),
table->s->stored_fields,
innobase_get_stmt(current_thd, &size));

ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
}

if (dict_index_is_clust(index)) {
templ->rec_field_no = templ->clust_rec_field_no;
Expand Down
76 changes: 70 additions & 6 deletions storage/xtradb/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2355,11 +2355,16 @@ innobase_get_stmt(
THD* thd, /*!< in: MySQL thread handle */
size_t* length) /*!< out: length of the SQL statement */
{
LEX_STRING* stmt;

stmt = thd_query_string(thd);
*length = stmt->length;
return(stmt->str);
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
}
return (query);
}

/**********************************************************************//**
Expand Down Expand Up @@ -7517,7 +7522,66 @@ build_template_field(
UNIV_MEM_INVALID(templ, sizeof *templ);
templ->col_no = i;
templ->clust_rec_field_no = dict_col_get_clust_pos(col, clust_index);
ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);

/* If clustered index record field is not found, lets print out
field names and all the rest to understand why field is not found. */
if (templ->clust_rec_field_no == ULINT_UNDEFINED) {
const char* tb_col_name = dict_table_get_col_name(clust_index->table, i);
dict_field_t* field=NULL;
size_t size = 0;

for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
if (ifield && !memcmp(tb_col_name, ifield->name,
strlen(tb_col_name))) {
field = ifield;
break;
}
}

ib_logf(IB_LOG_LEVEL_INFO,
"Looking for field %lu name %s from table %s",
i,
(tb_col_name ? tb_col_name : "NULL"),
clust_index->table->name);


for(ulint j=0; j < clust_index->n_user_defined_cols; j++) {
dict_field_t* ifield = &(clust_index->fields[j]);
ib_logf(IB_LOG_LEVEL_INFO,
"InnoDB Table %s field %lu name %s",
clust_index->table->name,
j,
(ifield ? ifield->name : "NULL"));
}

for(ulint j=0; j < table->s->stored_fields; j++) {
ib_logf(IB_LOG_LEVEL_INFO,
"MySQL table %s field %lu name %s",
table->s->table_name.str,
j,
table->field[j]->field_name);
}

ib_logf(IB_LOG_LEVEL_ERROR,
"Clustered record field for column %lu"
" not found table n_user_defined %d"
" index n_user_defined %d"
" InnoDB table %s field name %s"
" MySQL table %s field name %s n_fields %d"
" query %s",
i,
clust_index->n_user_defined_cols,
clust_index->table->n_cols - DATA_N_SYS_COLS,
clust_index->table->name,
(field ? field->name : "NULL"),
table->s->table_name.str,
(tb_col_name ? tb_col_name : "NULL"),
table->s->stored_fields,
innobase_get_stmt(current_thd, &size));

ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED);
}

if (dict_index_is_clust(index)) {
templ->rec_field_no = templ->clust_rec_field_no;
Expand Down

0 comments on commit 03ddc19

Please sign in to comment.