Bug #97871 the keep adjacent block in the same local segment should consider different file
Submitted: 3 Dec 2019 22:37 Modified: 11 Dec 2019 9:20
Reporter: Zongzhi Chen (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

[3 Dec 2019 22:37] Zongzhi Chen
Description:
The code version of MySQL is 8.0.17

In the AIO module, InnoDB try to keep adjacent blocks in the same local segment. However, it doesn't consider the different file with adjacent blocks.
In it's hash function:

  local_seg = (offset >> (UNIV_PAGE_SIZE_SHIFT + 6)) % m_n_segments;

if there is two AIO operations with two file, however the offset is almost the same, then these two AIO operation will be put in the adjacent slots, that is not what we want..

How to repeat:
read the code 

Suggested fix:
The hash function to find the segment should consider different file

  local_seg = (offset >> (UNIV_PAGE_SIZE_SHIFT + 6)) % m_n_segments;

such as add file space id in the hash function
[4 Dec 2019 13:31] MySQL Verification Team
Hello Mr. zongzhi,

Thank you for your bug report.

This proposition of yours also has problems. Next file could be far away from the first file on the disk. Not all of our customers and users use SSD. 

Hence, this would be a huge performance penalty.
[5 Dec 2019 13:13] MySQL Verification Team
Hi,

I have discussed this with a colleague and the conclusion is that I am right.

Hence, not a bug.
[5 Dec 2019 16:56] Zongzhi Chen
No,  You may not understanding me..

Such as there is file a and b.

we will write a's two offsets such    1024,  1025
and we also wan't to write b's offset 1024

In the implementation right now.
a's 1024 and b's 1024 will be put in the adjacent slot. since the function won't consider the different file with almost same write address

  local_seg = (offset >> (UNIV_PAGE_SIZE_SHIFT + 6)) % m_n_segments;

Actually, we want put the write slot of a's offset 1024 and a's offset 1025  in adjacent, not with b's offset 1024
[10 Dec 2019 16:21] Zongzhi Chen
Hello,  what's going on with this issue..
I still think we need modify the hash function..
[10 Dec 2019 16:25] MySQL Verification Team
Not going anywhere.

Entire team dealing with this subject has agreed that this is not a good idea.

Not a Bug.