Re: BUG #19369: Not documented that io_uring on kernel versions between 5.1 and below 5.6 does not work - Mailing list pgsql-bugs

From surya poondla
Subject Re: BUG #19369: Not documented that io_uring on kernel versions between 5.1 and below 5.6 does not work
Date
Msg-id CAOVWO5q5hoQvLM_xY-yGDyn7kv-s8Dg7uTcTfqqqPHVjFYKJ1Q@mail.gmail.com
Whole thread Raw
In response to Re: BUG #19369: Not documented that io_uring on kernel versions between 5.1 and below 5.6 does not work  (surya poondla <suryapoondla4@gmail.com>)
Responses Re: BUG #19369: Not documented that io_uring on kernel versions between 5.1 and below 5.6 does not work
List pgsql-bugs
Sure Andres, I am working on a patch which emits a useful error message too.


Hi All,


I prepared a patch that implements an early detection of unsupported io_uring operations during PostgreSQL startup, before any I/O is attempted. The patch focuses on

  1. Clear error message at startup instead of cryptic EINVAL during queries.

  2. Immediate failure with actionable hints (upgrade kernel or use io_method=worker)

  3. Prevents PostgreSQL from starting in a broken state


Before the patch:

  1. PostgreSQL started successfully

  2. Connection attempts failed with EINVAL errors


After patch:

  1. PostgreSQL refuses to start

  2. Clear error message that looks like:

    "FATAL: kernel does not support required io_uring operations"
    "DETAIL:  The kernel supports io_uring but lacks one or more of the required opcodes (IORING_OP_READ, IORING_OP_WRITE, IORING_OP_READV, IORING_OP_WRITEV). This typically occurs on Linux kernels older than 5.6."

    "HINT: Either upgrade your kernel to version 5.6 or newer, or

     use io_method=worker"


Modified files in the Patch:

  1. configure.ac: Added io_uring_opcode_supported to AC_CHECK_FUNCS

  2. meson.build: Added corresponding function check for Meson build

  3. src/backend/storage/aio/method_io_uring.c: Added is_uring_read_write_unsupported() function, that is integrated into pgaio_uring_init() and reports clear error with details and hints.


I tested the patch on Ubuntu server with Linux kernel 5.4.0-216-generic, and when io_uring is enabled I see that postgres doesn’t start (expected behavior).


The existing error handling for kernels < 5.1 (ENOSYS) is preserved.


Regards,

Surya Poondla 
Attachment

pgsql-bugs by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update
Next
From: Amit Langote
Date:
Subject: Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update