Bug #97839 CREATE TABLE fails with key_block_size=2 and O_DIRECT
Submitted: 2 Dec 2019 2:30 Modified: 4 Dec 2019 2:23
Reporter: zhai weixiang (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[2 Dec 2019 2:30] zhai weixiang
Description:
root@(none) 10:26:50>create database test;
Query OK, 1 row affected (0.00 sec)

root@(none) 10:26:55>use test
Database changed
root@test 10:26:56>create table t1 (a int,  b int) key_block_size=2;
ERROR 3675 (HY000): Create table/tablespace 't1' failed, as disk is full

root@test 10:27:10>show variables like '%innodb_flush_method%';
+---------------------+----------+
| Variable_name       | Value    |
+---------------------+----------+
| innodb_flush_method | O_DIRECT |
+---------------------+----------+
1 row in set (0.00 sec)

From error log:

2019-12-02T02:27:10.274068Z 8 [Warning] [MY-012638] [InnoDB] Retry attempts for writing partial data failed.
2019-12-02T02:27:10.274094Z 8 [ERROR] [MY-012639] [InnoDB] Write to file ./test/t1.ibd failed at offset 0, 14336 bytes should have been written, only 0 were written. Operating system error number 22. Check that your OS and file system support files of this size. Check also that the disk is not full or a disk quota exceeded.
2019-12-02T02:27:10.274104Z 8 [ERROR] [MY-012640] [InnoDB] Error number 22 means 'Invalid argument'
2019-12-02T02:27:10.274140Z 8 [ERROR] [MY-013133] [Server] Create table/tablespace 't1' failed, as disk is full.

The reason is that O_DERICT requires writing with aligned block size which is 4k on my dev machine. I think it should be prechecked before creating tables.

How to repeat:
described as above.

Suggested fix:
I'd suggest modifying the error message to make it more clear. Also precheck block size of system before creating table or writing something.
[3 Dec 2019 13:03] MySQL Verification Team
HI Mr. weixiang,

Thank you for your bug report.

However, this is not a bug.

The error message has been changed several times, so far in order to make it perfectly easy to understand, which is what we have now.

Also, checking for free disk space has been denied for many, many times since year 2000, for a very, very good reason. Simply, another connection, or (altogether) another program could be writing new data or removing old files simultaneously with that particular InnoDB thread.

Not a bug.
[4 Dec 2019 2:23] zhai weixiang
Hey, Sinisa
thank you for your comment. 

Actually my point is: it should give a more clear message. because people may get confused by it since the disk is actually not full. And the reason leading to failure is very clear: the block size is 4k and O_DIRECT requires aligned write. It should throw proper error message in this case.
[4 Dec 2019 13:11] MySQL Verification Team
Well, it simply can't be done.

This is due to the fact that the operating system returns the same errno whether it is out of disk space , has problem with alignments, runs out of quota, etc, etc ......