[MDEV-518] Statistics: If stat tables get corrupted, queries use wrong statistical data Created: 2012-09-09  Updated: 2012-11-17  Resolved: 2012-11-17

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: 10.0.1

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None


 Description   

From IRC:

<igor> elenst: could you come up with the test case where e.g. mysql.stat_table is corrupted somehow, then we 1) flush table t1; 2) set use_stat_tables='preferably' 3) run explain select * from t1;
<igor> elenst: in this case the result of explain is expected the same as we do not use ant stat tables (+ some warning).
<igor> elenst: I'm afraid now we just have rows == 0 in the explain output with this scenario, which not correct of course.

The provided test case confirms the suspicion: EXPLAIN shows 0 rows while the real number is 2.

Test case

# Run as perl ./mtr <testname>
 
CREATE TABLE t1 (i INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD.save
 
FLUSH TABLES;
SET use_stat_tables=PREFERABLY;
 
EXPLAIN SELECT * FROM t1;
 
# Cleanup
--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD.save $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stat.MYD
 
SET use_stat_tables=DEFAULT;
DROP TABLE t1;

Actual result:

CREATE TABLE t1 (i INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
FLUSH TABLES;
SET use_stat_tables=PREFERABLY;
EXPLAIN SELECT * FROM t1;
id     select_type     table   type    possible_keys   key     key_len ref     rows    Extra
1      SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    0
Warnings:
Error  29      File './mysql/table_stat.MYD' not found (Errcode: 2)
Error  1017    Can't find file: 'table_stat' (errno: 2)
SET use_stat_tables=DEFAULT;
DROP TABLE t1;

bzr version-info

revision-id: elenst@ubuntu11.home-20120903180152-r1n87m6pcvzffh63
date: 2012-09-03 22:01:52 +0400
build-date: 2012-09-09 01:58:25 +0300
revno: 3367

Workaround: if EXPLAIN produces warnings about corrupted stat tables, set use_stat_tables to NEVER.



 Comments   
Comment by Igor Babaev [ 2012-11-17 ]

The bug was fixed on 11-09-2012 and pushed into maria-5.5-mwl248.

Generated at Thu Feb 08 06:29:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.