Description:
I do:
1. CREATE TABLE `t2` (
`f1` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
2. Insert 2 rows.
3. Run insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2; insert into t2 select * from t2;
4. kill this query in middle
5. delete all rows except 2
6. Run bunch of inserts again
7. In middle of query server is stopped by cron process which does rebuild
8. After server restarted I run count(*) query and get negative result.
How to repeat:
See description, then run query:
mysql> select count(*) from t2;
+----------+
| count(*) |
+----------+
| -2097150 |
+----------+
1 row in set (0.00 sec)
Suggested fix:
I understand table is most likely corrupted (archive with frm, MYD and MYI will be attached), but why count(*) returns such value anyway?