v.21.9Improvement

Remove Complicated Linux AIO in Favor of Simple Synchronous IO with O_DIRECT

Remove complicated usage of Linux AIO with one block readahead and replace it with plain simple synchronous IO with O_DIRECT. In previous versions, the setting min_bytes_to_use_direct_io may not work correctly if max_threads is greater than one. Reading with direct IO (that is disabled by default for queries and enabled by default for large merges) will work in less efficient way. This closes #25997. #26003 (alexey-milovidov).
Simplified direct IO implementation replacing Linux AIO with synchronous IO and O_DIRECT.

Why it matters

This change resolves issues with the min_bytes_to_use_direct_io setting not functioning correctly when max_threads is greater than one, and improves the efficiency and reliability of direct IO reads by removing complicated Linux AIO usage and one block readahead. It ensures more consistent and predictable behavior for direct IO, which is used by default for large merges and optionally for queries.

How to use it

The feature is applied internally by replacing the direct IO mechanism; users can benefit from this fix by configuring the min_bytes_to_use_direct_io and max_threads settings as usual. Direct IO is disabled by default for queries and enabled by default for large merges, so no additional user action is needed unless customizing those settings.