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

From: Laetitia Avrot <laetitia(dot)avrot(at)gmail(dot)com>
To: Lucas DRAESCHER <git(at)draescher(dot)fr>
Cc: 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-06-05 15:16:21
Message-ID: CAB_COdgSDb8yFxUkNhUXmY8xhJgUMBn5Rt-W1h6RNH+WXZWafQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Lucas,

I reviewed v3 on Debian, kernel 6.17.13, liburing 2.14.

I reproduced the bug on unpatched master: fd count doubles from 142 to 284
after killing a backend. With the patch applied, the count stays stable.
The fix works.

Build was clean, no new warnings. All 245 regression tests pass, make
check-world passes, and all 39 TAP tests pass.

The code is clean and follows PostgreSQL conventions. The null guard before
registering the callback is correct, the wrapper satisfies the
on_shmem_exit() signature, and setting pgaio_uring_contexts to NULL after
cleanup prevents a double-free.

One note for the committer: on_shmem_exit() callbacks fire in LIFO order,
so this callback runs before anything registered earlier in AioShmemInit(),
which is the safe direction. Worth confirming that no earlier-registered
callback could invalidate pgaio_uring_contexts before this one runs.

On the v1 vs v2 design question: I favour v2. The Table AM precedent
suggests PostgreSQL prefers clean interface boundaries even with a single
implementor, and Andres Freund has been explicit about this in the past.

Marking as Ready for Committer.

Regards,

Lætitia

Le ven. 5 juin 2026 à 17:15, Lucas DRAESCHER <git(at)draescher(dot)fr> a écrit :

> I have attached v3 which rebases v2 on top of master.
>
> v1 still applies cleanly.
>
> Regards,
>
> Lucas

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Lætitia AVROT 2026-06-05 15:17:16 Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Previous Message Tom Lane 2026-06-05 14:43:16 Re: Prevent remote libpq notices from being sent to clients