diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2019-05-22 14:59:00 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2019-05-22 14:59:00 +0200 |
commit | e3d3bc858d38ea883e964c42b4bd08bb3ba964ac (patch) | |
tree | 1b36a7d15291a7c4f43206dea033a8b7a1392ac3 /sql/sql_cache.cc | |
parent | 2c9844a438c5f0bddcb037a1e05978118f48abb6 (diff) | |
download | mariadb-git-bb-5.5-MDEV-5924.tar.gz |
MDEV-5924: MariaDB could crash after changing the query_cache sizebb-5.5-MDEV-5924
The real problem was that attempt to roll back cahnes after end of memory in QC was made incorrectly and lead to using uninitialized memory.
(bug has nothing to do with resize operation, it is just lack of resources erro processed incorrectly)
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 5ba32e0bbd7..c1ccd35d5c1 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -3300,7 +3300,12 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, if (!insert_table(key_length, key, (*block_table), tables_used->view_db.length, HA_CACHE_TBL_NONTRANSACT, 0, 0, TRUE)) + { + // Mark failed + (*block_table)->next= (*block_table)->prev= NULL; + (*block_table)->parent= NULL; DBUG_RETURN(0); + } /* We do not need to register view tables here because they are already present in the global list. @@ -3324,11 +3329,21 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used, tables_used->callback_func, tables_used->engine_data, TRUE)) + { + // Mark failed + (*block_table)->next= (*block_table)->prev= NULL; + (*block_table)->parent= NULL; DBUG_RETURN(0); + } if (tables_used->table->file-> register_query_cache_dependant_tables(thd, this, block_table, &n)) + { + // Mark failed + (*block_table)->next= (*block_table)->prev= NULL; + (*block_table)->parent= NULL; DBUG_RETURN(0); + } } } DBUG_RETURN(n - counter); @@ -3365,9 +3380,12 @@ my_bool Query_cache::register_all_tables(THD *thd, for (Query_cache_block_table *tmp = block->table(0) ; tmp != block_table; tmp++) - unlink_table(tmp); - if (block_table->parent) - unlink_table(block_table); + { + if (tmp->prev) // not marked as failed and unuseable + unlink_table(tmp); + else + break; + } } return test(n); } |