Bug #71299 simple DML causes too many corrupt csv tables.
Submitted: 5 Jan 2014 12:36 Modified: 5 Jan 2014 12:42
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: CSV Severity:S1 (Critical)
Version:5.7.4 OS:Windows
Assigned to: CPU Architecture:Any

[5 Jan 2014 12:36] Shane Bester
Description:
Basic DML causes CSV tables to report themselves as corrupted.
Consider the most simple table, one with a single integer.

mysql> check table t1;
+---------+-------+----------+----------+
| Table   | Op    | Msg_type | Msg_text |
+---------+-------+----------+----------+
| test.t1 | check | error    | Corrupt  |
+---------+-------+----------+----------+
1 row in set (0.00 sec)

mysql> select * from t1;
+-----+
| a   |
+-----+
| 689 |
| 387 |
+-----+
2 rows in set, 1 warning (0.14 sec)

mysql> show warnings;
+-------+------+--------------------------------------------------------+
| Level | Code | Message                                                |
+-------+------+--------------------------------------------------------+
| Error | 1194 | Table 't1' is marked as crashed and should be repaired |
+-------+------+--------------------------------------------------------+
1 row in set (0.00 sec)

How to repeat:
will come soon.
[5 Jan 2014 12:42] MySQL Verification Team
Here's a sample psuedo-random testcase.  Please test more thoroughly, with the MyISAM/InnoDB strength tests.  All engines should withstand simple stress tests.

----------
drop table if exists `t1`;
create table `t1`(`a` int not null) engine=csv;
drop procedure if exists `p1`;
delimiter $

create procedure `p1`()
begin
  set @r=100000;
  repeat
  if rand()>0.5 then replace into `t1` values(floor(rand()*@r)); end if;
  if rand()>0.5 then 	insert ignore into `t1` values(floor(rand()*@r)); end if;
  if rand()>0.5 then update `t1` set `a`=floor(rand()*@r) limit 5; end if;
  if rand()>0.5 then delete from `t1` order by `a` limit 2; end if;
  if rand()>0.5 then select count(*) from `t1` into @c; end if;
  until 1=2 end repeat;
end $
delimiter ;

call p1();   ### and in another thread, run CHECK TABLE `t1`;
----------
[5 Jan 2014 12:42] MySQL Verification Team
mysql> call p1();
ERROR 3 (HY000): Error writing file '.\test\t1.CSN' (Errcode: 22 - Invalid argument [OS Error Code : 0x6f8])
mysql> call p1();
ERROR 3 (HY000): Error writing file '.\test\t1.CSN' (Errcode: 22 - Invalid argument [OS Error Code : 0x6f8])
mysql>
[5 Jan 2014 12:48] MySQL Verification Team
Just running "call p1()" in two threads quickly shows the error.

mysql> call p1();
ERROR 1194 (HY000): Table 't1' is marked as crashed and should be repaired
[29 Apr 2014 8:55] MySQL Verification Team
Also: 
Bug 17746357 - ASSERTION FAILED: SHARE->ROWS_RECORDED, FILE HA_TINA.CC, LINE 1122
[31 Oct 2017 7:31] MySQL Verification Team
seems only windows affected.   I bet this is related to the serious bug
https://bugs.mysql.com/bug.php?id=88299 !