Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: Lucas DRAESCHER <git(at)draescher(dot)fr>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Laetitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>, "tanswis42(at)gmail(dot)com" <tanswis42(at)gmail(dot)com>, cca5507 <cca5507(at)qq(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Date: 2026-11-05 14:37:16
Message-ID: CAHGQGwF526BUM+Pur9KZWW0rRs-xsbaPMLuWhE0OgoVrXL7C2w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 5, 2026 at 6:25 PM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
> I could
> write a follow-up patch or review it if you already did.

I tried to write a patch that keeps postmaster-local copies of the io_uring
descriptors and passes them to io_uring_queue_exit() for cleanup. Attached.

Per [1], io_uring_queue_exit() seems to use sq.kring_entries. Since this is
a pointer [2], simply copying the descriptor would leave it pointing into
shared memory. So, the patch also saves the pointed-to value locally.

But, I'm not sure this is the right approach... It relies on liburing's
implementation rather than a documented guarantee, so future liburing changes
would be really easily able to break it. This seems very fragile. Thought?
Is there a better approach?

Regards,

[1] https://github.com/axboe/liburing/blob/liburing-2.7/src/setup.c#L430-L445
[2] https://github.com/axboe/liburing/blob/liburing-2.7/src/include/liburing.h#L77-L83

--
Fujii Masao

Attachment Content-Type Size
v1-0001-Use-postmaster-local-metadata-for-io_uring-cleanu.patch application/octet-stream 4.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-05 14:41:31 Re: Unlogged bloom indexes break after crash recovery
Previous Message Nazir Bilal Yavuz 2026-11-05 14:22:36 Re: ci: Follow-up CI patches