Merge Bug#55832 fix from mysql-5.1-innodb:

------------------------------------------------------------
revno: 3550
revision-id: marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2
parent: marko.makela@oracle.com-20100823102854-t1clrojqis2ley36
committer: Marko Mäkelä <marko.makela@oracle.com>
branch nick: 5.1-innodb
timestamp: Tue 2010-08-24 11:10:03 +0300
message:
  Bug#55832: selects crash too easily when innodb_force_recovery>3

  dict_update_statistics_low(): Create bogus statistics for those
  indexes that cannot be accessed because of the innodb_force_recovery
  setting.

  ha_innobase::info(): Calculate statistics for each index, even if
  innodb_force_recovery is set. Fill in bogus data for those indexes
  that are not accessed because of the innodb_force_recovery setting.
This commit is contained in:
Marko Mäkelä 2010-08-24 11:34:19 +03:00
commit 938ce0efd7
2 changed files with 54 additions and 40 deletions

View file

@ -4206,7 +4206,6 @@ dict_update_statistics_low(
dictionary mutex */
{
dict_index_t* index;
ulint size;
ulint sum_of_index_sizes = 0;
if (table->ibd_file_missing) {
@ -4221,14 +4220,6 @@ dict_update_statistics_low(
return;
}
/* If we have set a high innodb_force_recovery level, do not calculate
statistics, as a badly corrupted index can cause a crash in it. */
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
return;
}
/* Find out the sizes of the indexes and how many different values
for the key they approximately have */
@ -4240,26 +4231,48 @@ dict_update_statistics_low(
return;
}
while (index) {
size = btr_get_size(index, BTR_TOTAL_SIZE);
index->stat_index_size = size;
do {
if (UNIV_LIKELY
(srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE
|| (srv_force_recovery < SRV_FORCE_NO_LOG_REDO
&& dict_index_is_clust(index)))) {
ulint size;
size = btr_get_size(index, BTR_TOTAL_SIZE);
sum_of_index_sizes += size;
index->stat_index_size = size;
size = btr_get_size(index, BTR_N_LEAF_PAGES);
sum_of_index_sizes += size;
if (size == 0) {
/* The root node of the tree is a leaf */
size = 1;
size = btr_get_size(index, BTR_N_LEAF_PAGES);
if (size == 0) {
/* The root node of the tree is a leaf */
size = 1;
}
index->stat_n_leaf_pages = size;
btr_estimate_number_of_different_key_vals(index);
} else {
/* If we have set a high innodb_force_recovery
level, do not calculate statistics, as a badly
corrupted index can cause a crash in it.
Initialize some bogus index cardinality
statistics, so that the data can be queried in
various means, also via secondary indexes. */
ulint i;
sum_of_index_sizes++;
index->stat_index_size = index->stat_n_leaf_pages = 1;
for (i = dict_index_get_n_unique(index); i; ) {
index->stat_n_diff_key_vals[i--] = 1;
}
}
index->stat_n_leaf_pages = size;
btr_estimate_number_of_different_key_vals(index);
index = dict_table_get_next_index(index);
}
} while (index);
index = dict_table_get_first_index(table);