summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorJan Lindström <jplindst@mariadb.org>2014-07-22 19:31:45 +0300
committerJan Lindström <jplindst@mariadb.org>2014-07-22 19:31:45 +0300
commita1e41e325873bda2071f0d9c5b85778023435c0b (patch)
tree09e0731723aa156b2723fd00a118c19ae4936e43 /storage
parent15a529e12839579360bd81dd1997502259dd2cbd (diff)
downloadmariadb-git-a1e41e325873bda2071f0d9c5b85778023435c0b.tar.gz
MDEV-6470: Restrict number of error messages about persistent statictic tables not found
If mysql.innodb_table_stats or mysql.innodb_index_stats is not found or has unexpected structure output that error only once and no other error for every table trying to use them. If they do exists, then print fetch or recalculation errors only once / table or index.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/dict/dict0dict.cc35
-rw-r--r--storage/innobase/dict/dict0stats.cc129
-rw-r--r--storage/innobase/include/dict0dict.h3
-rw-r--r--storage/innobase/include/dict0mem.h6
-rw-r--r--storage/xtradb/dict/dict0dict.cc35
-rw-r--r--storage/xtradb/dict/dict0stats.cc129
-rw-r--r--storage/xtradb/include/dict0dict.h3
-rw-r--r--storage/xtradb/include/dict0mem.h6
8 files changed, 228 insertions, 118 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index a1234b0e914..052e9bf2567 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -121,6 +121,11 @@ UNIV_INTERN mysql_pfs_key_t dict_foreign_err_mutex_key;
/** Identifies generated InnoDB foreign key names */
static char dict_ibfk[] = "_ibfk_";
+bool innodb_table_stats_not_found = false;
+bool innodb_index_stats_not_found = false;
+static bool innodb_table_stats_not_found_reported = false;
+static bool innodb_index_stats_not_found_reported = false;
+
/*******************************************************************//**
Tries to find column names for the index and sets the col field of the
index.
@@ -5994,14 +5999,34 @@ dict_table_schema_check(
table = dict_table_get_low(req_schema->table_name);
if (table == NULL) {
+ bool should_print=true;
/* no such table */
- ut_snprintf(errstr, errstr_sz,
- "Table %s not found.",
- ut_format_name(req_schema->table_name,
- TRUE, buf, sizeof(buf)));
+ if (innobase_strcasecmp(req_schema->table_name, "mysql/innodb_table_stats") == 0) {
+ if (innodb_table_stats_not_found_reported == false) {
+ innodb_table_stats_not_found = true;
+ innodb_table_stats_not_found_reported = true;
+ } else {
+ should_print = false;
+ }
+ } else if (innobase_strcasecmp(req_schema->table_name, "mysql/innodb_index_stats") == 0 ) {
+ if (innodb_index_stats_not_found_reported == false) {
+ innodb_index_stats_not_found = true;
+ innodb_index_stats_not_found_reported = true;
+ } else {
+ should_print = false;
+ }
+ }
- return(DB_TABLE_NOT_FOUND);
+ if (should_print) {
+ ut_snprintf(errstr, errstr_sz,
+ "Table %s not found.",
+ ut_format_name(req_schema->table_name,
+ TRUE, buf, sizeof(buf)));
+ return(DB_TABLE_NOT_FOUND);
+ } else {
+ return(DB_STATS_DO_NOT_EXIST);
+ }
}
if (table->ibd_file_missing) {
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 928bdb3f2ef..aa417bbae7b 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -268,10 +268,12 @@ dict_stats_persistent_storage_check(
mutex_exit(&(dict_sys->mutex));
}
- if (ret != DB_SUCCESS) {
+ if (ret != DB_SUCCESS && ret != DB_STATS_DO_NOT_EXIST) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: %s\n", errstr);
return(false);
+ } else if (ret == DB_STATS_DO_NOT_EXIST) {
+ return false;
}
/* else */
@@ -2201,17 +2203,21 @@ dict_stats_save_index_stat(
"END;", trx);
if (ret != DB_SUCCESS) {
- char buf_table[MAX_FULL_NAME_LEN];
- char buf_index[MAX_FULL_NAME_LEN];
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Cannot save index statistics for table "
- "%s, index %s, stat name \"%s\": %s\n",
- ut_format_name(index->table->name, TRUE,
- buf_table, sizeof(buf_table)),
- ut_format_name(index->name, FALSE,
- buf_index, sizeof(buf_index)),
- stat_name, ut_strerr(ret));
+ if (innodb_index_stats_not_found == false &&
+ index->stats_error_printed == false) {
+ char buf_table[MAX_FULL_NAME_LEN];
+ char buf_index[MAX_FULL_NAME_LEN];
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Cannot save index statistics for table "
+ "%s, index %s, stat name \"%s\": %s\n",
+ ut_format_name(index->table->name, TRUE,
+ buf_table, sizeof(buf_table)),
+ ut_format_name(index->name, FALSE,
+ buf_index, sizeof(buf_index)),
+ stat_name, ut_strerr(ret));
+ index->stats_error_printed = true;
+ }
}
return(ret);
@@ -2900,20 +2906,24 @@ dict_stats_update_for_index(
}
/* else */
- /* Fall back to transient stats since the persistent
- storage is not present or is corrupted */
- char buf_table[MAX_FULL_NAME_LEN];
- char buf_index[MAX_FULL_NAME_LEN];
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Recalculation of persistent statistics "
- "requested for table %s index %s but the required "
- "persistent statistics storage is not present or is "
- "corrupted. Using transient stats instead.\n",
- ut_format_name(index->table->name, TRUE,
- buf_table, sizeof(buf_table)),
- ut_format_name(index->name, FALSE,
- buf_index, sizeof(buf_index)));
+ if (innodb_index_stats_not_found == false &&
+ index->stats_error_printed == false) {
+ /* Fall back to transient stats since the persistent
+ storage is not present or is corrupted */
+ char buf_table[MAX_FULL_NAME_LEN];
+ char buf_index[MAX_FULL_NAME_LEN];
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Recalculation of persistent statistics "
+ "requested for table %s index %s but the required "
+ "persistent statistics storage is not present or is "
+ "corrupted. Using transient stats instead.\n",
+ ut_format_name(index->table->name, TRUE,
+ buf_table, sizeof(buf_table)),
+ ut_format_name(index->name, FALSE,
+ buf_index, sizeof(buf_index)));
+ index->stats_error_printed = false;
+ }
}
dict_table_stats_lock(index->table, RW_X_LATCH);
@@ -2998,13 +3008,17 @@ dict_stats_update(
/* Fall back to transient stats since the persistent
storage is not present or is corrupted */
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Recalculation of persistent statistics "
- "requested for table %s but the required persistent "
- "statistics storage is not present or is corrupted. "
- "Using transient stats instead.\n",
- ut_format_name(table->name, TRUE, buf, sizeof(buf)));
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Recalculation of persistent statistics "
+ "requested for table %s but the required persistent "
+ "statistics storage is not present or is corrupted. "
+ "Using transient stats instead.\n",
+ ut_format_name(table->name, TRUE, buf, sizeof(buf)));
+ table->stats_error_printed = true;
+ }
goto transient;
@@ -3048,17 +3062,21 @@ dict_stats_update(
/* persistent statistics storage does not exist
or is corrupted, calculate the transient stats */
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: Fetch of persistent "
- "statistics requested for table %s but the "
- "required system tables %s and %s are not "
- "present or have unexpected structure. "
- "Using transient stats instead.\n",
- ut_format_name(table->name, TRUE,
- buf, sizeof(buf)),
- TABLE_STATS_NAME_PRINT,
- INDEX_STATS_NAME_PRINT);
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Error: Fetch of persistent "
+ "statistics requested for table %s but the "
+ "required system tables %s and %s are not "
+ "present or have unexpected structure. "
+ "Using transient stats instead.\n",
+ ut_format_name(table->name, TRUE,
+ buf, sizeof(buf)),
+ TABLE_STATS_NAME_PRINT,
+ INDEX_STATS_NAME_PRINT);
+ table->stats_error_printed = true;
+ }
goto transient;
}
@@ -3128,16 +3146,19 @@ dict_stats_update(
dict_stats_table_clone_free(t);
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error fetching persistent statistics "
- "for table %s from %s and %s: %s. "
- "Using transient stats method instead.\n",
- ut_format_name(table->name, TRUE, buf,
- sizeof(buf)),
- TABLE_STATS_NAME,
- INDEX_STATS_NAME,
- ut_strerr(err));
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Error fetching persistent statistics "
+ "for table %s from %s and %s: %s. "
+ "Using transient stats method instead.\n",
+ ut_format_name(table->name, TRUE, buf,
+ sizeof(buf)),
+ TABLE_STATS_NAME,
+ INDEX_STATS_NAME,
+ ut_strerr(err));
+ }
goto transient;
}
diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h
index ce709a2e912..f43ba11e74d 100644
--- a/storage/innobase/include/dict0dict.h
+++ b/storage/innobase/include/dict0dict.h
@@ -43,6 +43,9 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0types.h"
#include "row0types.h"
+extern bool innodb_table_stats_not_found;
+extern bool innodb_index_stats_not_found;
+
#ifndef UNIV_HOTBACKUP
# include "sync0sync.h"
# include "sync0rw.h"
diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h
index eb259020106..58de2c2b3f0 100644
--- a/storage/innobase/include/dict0mem.h
+++ b/storage/innobase/include/dict0mem.h
@@ -624,6 +624,9 @@ struct dict_index_t{
ulint stat_n_leaf_pages;
/*!< approximate number of leaf pages in the
index tree */
+ bool stats_error_printed;
+ /*!< has persistent statistics error printed
+ for this index ? */
/* @} */
rw_lock_t lock; /*!< read-write lock protecting the
upper levels of the index tree */
@@ -947,6 +950,9 @@ struct dict_table_t{
/*!< see BG_STAT_* above.
Writes are covered by dict_sys->mutex.
Dirty reads are possible. */
+ bool stats_error_printed;
+ /*!< Has persistent stats error beein
+ already printed for this table ? */
/* @} */
/*----------------------*/
/**!< The following fields are used by the
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 1aa40f92836..31d7639aee5 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -121,6 +121,11 @@ UNIV_INTERN mysql_pfs_key_t dict_foreign_err_mutex_key;
/** Identifies generated InnoDB foreign key names */
static char dict_ibfk[] = "_ibfk_";
+bool innodb_table_stats_not_found = false;
+bool innodb_index_stats_not_found = false;
+static bool innodb_table_stats_not_found_reported = false;
+static bool innodb_index_stats_not_found_reported = false;
+
/*******************************************************************//**
Tries to find column names for the index and sets the col field of the
index.
@@ -6037,14 +6042,34 @@ dict_table_schema_check(
table = dict_table_get_low(req_schema->table_name);
if (table == NULL) {
+ bool should_print=true;
/* no such table */
- ut_snprintf(errstr, errstr_sz,
- "Table %s not found.",
- ut_format_name(req_schema->table_name,
- TRUE, buf, sizeof(buf)));
+ if (innobase_strcasecmp(req_schema->table_name, "mysql/innodb_table_stats") == 0) {
+ if (innodb_table_stats_not_found_reported == false) {
+ innodb_table_stats_not_found = true;
+ innodb_table_stats_not_found_reported = true;
+ } else {
+ should_print = false;
+ }
+ } else if (innobase_strcasecmp(req_schema->table_name, "mysql/innodb_index_stats") == 0 ) {
+ if (innodb_index_stats_not_found_reported == false) {
+ innodb_index_stats_not_found = true;
+ innodb_index_stats_not_found_reported = true;
+ } else {
+ should_print = false;
+ }
+ }
- return(DB_TABLE_NOT_FOUND);
+ if (should_print) {
+ ut_snprintf(errstr, errstr_sz,
+ "Table %s not found.",
+ ut_format_name(req_schema->table_name,
+ TRUE, buf, sizeof(buf)));
+ return(DB_TABLE_NOT_FOUND);
+ } else {
+ return(DB_STATS_DO_NOT_EXIST);
+ }
}
if (table->ibd_file_missing) {
diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc
index 928bdb3f2ef..aa417bbae7b 100644
--- a/storage/xtradb/dict/dict0stats.cc
+++ b/storage/xtradb/dict/dict0stats.cc
@@ -268,10 +268,12 @@ dict_stats_persistent_storage_check(
mutex_exit(&(dict_sys->mutex));
}
- if (ret != DB_SUCCESS) {
+ if (ret != DB_SUCCESS && ret != DB_STATS_DO_NOT_EXIST) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: %s\n", errstr);
return(false);
+ } else if (ret == DB_STATS_DO_NOT_EXIST) {
+ return false;
}
/* else */
@@ -2201,17 +2203,21 @@ dict_stats_save_index_stat(
"END;", trx);
if (ret != DB_SUCCESS) {
- char buf_table[MAX_FULL_NAME_LEN];
- char buf_index[MAX_FULL_NAME_LEN];
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Cannot save index statistics for table "
- "%s, index %s, stat name \"%s\": %s\n",
- ut_format_name(index->table->name, TRUE,
- buf_table, sizeof(buf_table)),
- ut_format_name(index->name, FALSE,
- buf_index, sizeof(buf_index)),
- stat_name, ut_strerr(ret));
+ if (innodb_index_stats_not_found == false &&
+ index->stats_error_printed == false) {
+ char buf_table[MAX_FULL_NAME_LEN];
+ char buf_index[MAX_FULL_NAME_LEN];
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Cannot save index statistics for table "
+ "%s, index %s, stat name \"%s\": %s\n",
+ ut_format_name(index->table->name, TRUE,
+ buf_table, sizeof(buf_table)),
+ ut_format_name(index->name, FALSE,
+ buf_index, sizeof(buf_index)),
+ stat_name, ut_strerr(ret));
+ index->stats_error_printed = true;
+ }
}
return(ret);
@@ -2900,20 +2906,24 @@ dict_stats_update_for_index(
}
/* else */
- /* Fall back to transient stats since the persistent
- storage is not present or is corrupted */
- char buf_table[MAX_FULL_NAME_LEN];
- char buf_index[MAX_FULL_NAME_LEN];
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Recalculation of persistent statistics "
- "requested for table %s index %s but the required "
- "persistent statistics storage is not present or is "
- "corrupted. Using transient stats instead.\n",
- ut_format_name(index->table->name, TRUE,
- buf_table, sizeof(buf_table)),
- ut_format_name(index->name, FALSE,
- buf_index, sizeof(buf_index)));
+ if (innodb_index_stats_not_found == false &&
+ index->stats_error_printed == false) {
+ /* Fall back to transient stats since the persistent
+ storage is not present or is corrupted */
+ char buf_table[MAX_FULL_NAME_LEN];
+ char buf_index[MAX_FULL_NAME_LEN];
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Recalculation of persistent statistics "
+ "requested for table %s index %s but the required "
+ "persistent statistics storage is not present or is "
+ "corrupted. Using transient stats instead.\n",
+ ut_format_name(index->table->name, TRUE,
+ buf_table, sizeof(buf_table)),
+ ut_format_name(index->name, FALSE,
+ buf_index, sizeof(buf_index)));
+ index->stats_error_printed = false;
+ }
}
dict_table_stats_lock(index->table, RW_X_LATCH);
@@ -2998,13 +3008,17 @@ dict_stats_update(
/* Fall back to transient stats since the persistent
storage is not present or is corrupted */
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Recalculation of persistent statistics "
- "requested for table %s but the required persistent "
- "statistics storage is not present or is corrupted. "
- "Using transient stats instead.\n",
- ut_format_name(table->name, TRUE, buf, sizeof(buf)));
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Recalculation of persistent statistics "
+ "requested for table %s but the required persistent "
+ "statistics storage is not present or is corrupted. "
+ "Using transient stats instead.\n",
+ ut_format_name(table->name, TRUE, buf, sizeof(buf)));
+ table->stats_error_printed = true;
+ }
goto transient;
@@ -3048,17 +3062,21 @@ dict_stats_update(
/* persistent statistics storage does not exist
or is corrupted, calculate the transient stats */
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error: Fetch of persistent "
- "statistics requested for table %s but the "
- "required system tables %s and %s are not "
- "present or have unexpected structure. "
- "Using transient stats instead.\n",
- ut_format_name(table->name, TRUE,
- buf, sizeof(buf)),
- TABLE_STATS_NAME_PRINT,
- INDEX_STATS_NAME_PRINT);
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Error: Fetch of persistent "
+ "statistics requested for table %s but the "
+ "required system tables %s and %s are not "
+ "present or have unexpected structure. "
+ "Using transient stats instead.\n",
+ ut_format_name(table->name, TRUE,
+ buf, sizeof(buf)),
+ TABLE_STATS_NAME_PRINT,
+ INDEX_STATS_NAME_PRINT);
+ table->stats_error_printed = true;
+ }
goto transient;
}
@@ -3128,16 +3146,19 @@ dict_stats_update(
dict_stats_table_clone_free(t);
- ut_print_timestamp(stderr);
- fprintf(stderr,
- " InnoDB: Error fetching persistent statistics "
- "for table %s from %s and %s: %s. "
- "Using transient stats method instead.\n",
- ut_format_name(table->name, TRUE, buf,
- sizeof(buf)),
- TABLE_STATS_NAME,
- INDEX_STATS_NAME,
- ut_strerr(err));
+ if (innodb_table_stats_not_found == false &&
+ table->stats_error_printed == false) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr,
+ " InnoDB: Error fetching persistent statistics "
+ "for table %s from %s and %s: %s. "
+ "Using transient stats method instead.\n",
+ ut_format_name(table->name, TRUE, buf,
+ sizeof(buf)),
+ TABLE_STATS_NAME,
+ INDEX_STATS_NAME,
+ ut_strerr(err));
+ }
goto transient;
}
diff --git a/storage/xtradb/include/dict0dict.h b/storage/xtradb/include/dict0dict.h
index 3e3fb9f896c..0a93f0532f5 100644
--- a/storage/xtradb/include/dict0dict.h
+++ b/storage/xtradb/include/dict0dict.h
@@ -43,6 +43,9 @@ Created 1/8/1996 Heikki Tuuri
#include "trx0types.h"
#include "row0types.h"
+extern bool innodb_table_stats_not_found;
+extern bool innodb_index_stats_not_found;
+
#ifndef UNIV_HOTBACKUP
# include "sync0sync.h"
# include "sync0rw.h"
diff --git a/storage/xtradb/include/dict0mem.h b/storage/xtradb/include/dict0mem.h
index 527d50019a4..0dd0ea63f3b 100644
--- a/storage/xtradb/include/dict0mem.h
+++ b/storage/xtradb/include/dict0mem.h
@@ -638,6 +638,9 @@ struct dict_index_t{
ulint stat_n_leaf_pages;
/*!< approximate number of leaf pages in the
index tree */
+ bool stats_error_printed;
+ /*!< has persistent statistics error printed
+ for this index ? */
/* @} */
prio_rw_lock_t lock; /*!< read-write lock protecting the
upper levels of the index tree */
@@ -962,6 +965,9 @@ struct dict_table_t{
/*!< see BG_STAT_* above.
Writes are covered by dict_sys->mutex.
Dirty reads are possible. */
+ bool stats_error_printed;
+ /*!< Has persistent stats error beein
+ already printed for this table ? */
/* @} */
/*----------------------*/
/**!< The following fields are used by the