summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0stats.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/dict/dict0stats.cc')
-rw-r--r--storage/innobase/dict/dict0stats.cc71
1 files changed, 55 insertions, 16 deletions
diff --git a/storage/innobase/dict/dict0stats.cc b/storage/innobase/dict/dict0stats.cc
index 537a70c2069..54988b910d8 100644
--- a/storage/innobase/dict/dict0stats.cc
+++ b/storage/innobase/dict/dict0stats.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, MariaDB Corporation.
+Copyright (c) 2015, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -913,10 +913,15 @@ dict_stats_update_transient_for_index(
index->stat_n_leaf_pages = size;
- /* We don't handle the return value since it will be false
- only when some thread is dropping the table and we don't
- have to empty the statistics of the to be dropped index */
- btr_estimate_number_of_different_key_vals(index);
+ /* Do not continue if table decryption has failed or
+ table is already marked as corrupted. */
+ if (index->is_readable()) {
+ /* We don't handle the return value since it
+ will be false only when some thread is
+ dropping the table and we don't have to empty
+ the statistics of the to be dropped index */
+ btr_estimate_number_of_different_key_vals(index);
+ }
}
}
@@ -967,8 +972,9 @@ dict_stats_update_transient(
continue;
}
- /* Do not continue if table decryption has failed. */
- if (index->table->is_encrypted) {
+ /* Do not continue if table decryption has failed or
+ table is already marked as corrupted. */
+ if (!index->is_readable()) {
break;
}
@@ -2419,6 +2425,41 @@ dict_stats_save_index_stat(
return(ret);
}
+/** Report an error if updating table statistics failed because
+.ibd file is missing, table decryption failed or table is corrupted.
+@param[in,out] table Table
+@param[in] defragment true if statistics is for defragment
+@retval DB_DECRYPTION_FAILED if decryption of the table failed
+@retval DB_TABLESPACE_DELETED if .ibd file is missing
+@retval DB_CORRUPTION if table is marked as corrupted */
+dberr_t
+dict_stats_report_error(dict_table_t* table, bool defragment)
+{
+ dberr_t err;
+
+ FilSpace space(table->space);
+ const char* df = defragment ? " defragment" : "";
+
+ if (!space()) {
+ ib::warn() << "Cannot save" << df << " statistics for table "
+ << table->name
+ << " because the .ibd file is missing. "
+ << TROUBLESHOOTING_MSG;
+ err = DB_TABLESPACE_DELETED;
+ } else {
+ ib::warn() << "Cannot save" << df << " statistics for table "
+ << table->name
+ << " because file " << space()->chain.start->name
+ << (table->corrupted
+ ? " is corrupted."
+ : " cannot be decrypted.");
+ err = table->corrupted ? DB_CORRUPTION : DB_DECRYPTION_FAILED;
+ }
+
+ dict_stats_empty_table(table, defragment);
+ return err;
+}
+
/** Save the table's statistics into the persistent statistics storage.
@param[in] table_orig table whose stats to save
@param[in] only_for_index if this is non-NULL, then stats for indexes
@@ -2438,6 +2479,11 @@ dict_stats_save(
char db_utf8[MAX_DB_UTF8_LEN];
char table_utf8[MAX_TABLE_UTF8_LEN];
+ if (table_orig->is_readable()) {
+ } else {
+ return (dict_stats_report_error(table_orig));
+ }
+
table = dict_stats_snapshot_create(table_orig);
dict_fs2utf8(table->name.m_name, db_utf8, sizeof(db_utf8),
@@ -3160,15 +3206,8 @@ dict_stats_update(
{
ut_ad(!mutex_own(&dict_sys->mutex));
- if (table->ibd_file_missing) {
-
- ib::warn() << "Cannot calculate statistics for table "
- << table->name
- << " because the .ibd file is missing. "
- << TROUBLESHOOTING_MSG;
-
- dict_stats_empty_table(table, true);
- return(DB_TABLESPACE_DELETED);
+ if (!table->is_readable()) {
+ return (dict_stats_report_error(table));
} else if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
/* If we have set a high innodb_force_recovery level, do
not calculate statistics, as a badly corrupted index can