Commit 321f589c authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-6181 EITS could eat all tmpdir space and hang

Don't ignore errors from Count_distinct_field::add(),
pass them to the caller, so that it could abort the data
collection loop.
parent fece177f
call mtr.add_suppression("No space left on device");
create table t1 (a varchar(255), b varchar(255), c varchar(255));
set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3;
set debug_dbug='+d,simulate_file_write_error';
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze Error Error writing file 'tmp-file' (Errcode: 28 "No space left on device")
test.t1 analyze status Operation failed
set debug_dbug='';
drop table t1;
#
# MDEV-6181 EITS could eat all tmpdir space and hang
#
# test that ANALYZE TABLE is immediately aborted when going out of disk space
--source include/have_debug.inc
call mtr.add_suppression("No space left on device");
create table t1 (a varchar(255), b varchar(255), c varchar(255));
--disable_query_log
let $i=10000;
while ($i) {
insert t1 values (repeat(format(rand(),10), 20),
repeat(format(rand(),10), 20),
repeat(format(rand(),10), 20));
dec $i;
}
--enable_query_log
set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3;
set debug_dbug='+d,simulate_file_write_error';
--replace_regex /'.*'/'tmp-file'/
analyze table t1;
set debug_dbug='';
drop table t1;
...@@ -184,7 +184,7 @@ class Column_statistics_collected :public Column_statistics ...@@ -184,7 +184,7 @@ class Column_statistics_collected :public Column_statistics
public: public:
inline void init(THD *thd, Field * table_field); inline void init(THD *thd, Field * table_field);
inline void add(ha_rows rowno); inline bool add(ha_rows rowno);
inline void finish(ha_rows rows); inline void finish(ha_rows rows);
inline void cleanup(); inline void cleanup();
}; };
...@@ -2219,9 +2219,10 @@ void Column_statistics_collected::init(THD *thd, Field *table_field) ...@@ -2219,9 +2219,10 @@ void Column_statistics_collected::init(THD *thd, Field *table_field)
*/ */
inline inline
void Column_statistics_collected::add(ha_rows rowno) bool Column_statistics_collected::add(ha_rows rowno)
{ {
bool err= 0;
if (column->is_null()) if (column->is_null())
nulls++; nulls++;
else else
...@@ -2232,8 +2233,9 @@ void Column_statistics_collected::add(ha_rows rowno) ...@@ -2232,8 +2233,9 @@ void Column_statistics_collected::add(ha_rows rowno)
if (max_value && column->update_max(max_value, rowno == nulls)) if (max_value && column->update_max(max_value, rowno == nulls))
set_not_null(COLUMN_STAT_MAX_VALUE); set_not_null(COLUMN_STAT_MAX_VALUE);
if (count_distinct) if (count_distinct)
count_distinct->add(); err= count_distinct->add();
} }
return err;
} }
...@@ -2487,8 +2489,11 @@ int collect_statistics_for_table(THD *thd, TABLE *table) ...@@ -2487,8 +2489,11 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
table_field= *field_ptr; table_field= *field_ptr;
if (!bitmap_is_set(table->read_set, table_field->field_index)) if (!bitmap_is_set(table->read_set, table_field->field_index))
continue; continue;
table_field->collected_stats->add(rows); if ((rc= table_field->collected_stats->add(rows)))
break;
} }
if (rc)
break;
rows++; rows++;
} }
file->ha_rnd_end(); file->ha_rnd_end();
...@@ -2518,7 +2523,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table) ...@@ -2518,7 +2523,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
else else
table_field->collected_stats->cleanup(); table_field->collected_stats->cleanup();
} }
bitmap_clear_all(table->write_set); bitmap_clear_all(table->write_set);
if (!rc) if (!rc)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment