Thread
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix LATERAL references in GRAPH_TABLE with multi-label pattern
- 4cb2a9863d89 19 (unreleased) cited
-
[Bug Report + Patch] File descriptor leak when io_method=io_uring
Lucas DRAESCHER <git@draescher.fr> — 2026-03-18T15:11:13Z
Hello Hackers, I noticed a file descriptor leak when running PostgreSQL 18 with io_method=io_uring. As far as I could tell, it only triggers when the server restarts due to one of the backends being killed. How to reproduce the issue: - Setup a server configured with io_uring - Check the number of open file descriptors: ls -la "/proc/$(head -1 $PGDATA/postmaster.pid)/fd/" | grep "io_uring" | wc -l - SIGKILL a backend to trigger a server restart: kill -9 $(psql -XtA -U postgres -c "SELECT pid FROM pg_stat_activity WHERE backend_type = 'client backend' LIMIT 1") - Check the number of open files descriptors again: Expected: FD count remains the same. Actual: FD count has doubled. Tested on PostgreSQL 18.0, 18.1, 18.2, 18.3 and git master on the following platforms: - Ubuntu Server 24.04: Linux 6.8.0, liburing 2.5 - Exherbo Linux: Linux 6.16.12, liburing 2.12 - Fedora Linux: Linux 6.19.7, liburing 2.13-dev From what I could gather, this happens because pgaio_uring_shmem_init() in src/backend/storage/aio/method_io_uring.c doesn't cleanup the allocated resources on exit. I've attached a patch which registers an on_shmem_exit() callback to close the file descriptors on server exit. I took inspiration from how src/backend/storage/aio/method_worker.c handles cleanup. Regards, Lucas. -
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
cca5507 <cca5507@qq.com> — 2026-03-20T03:17:07Z
Hi, Thanks for the report! I can reproduce this bug on master and your patch fixes it. > I've attached a patch which registers an on_shmem_exit() callback > to close the file descriptors on server exit. I took inspiration > from how src/backend/storage/aio/method_worker.c handles cleanup. I also verify that only the postmaster will call this callback because all children of the postmaster will reset postmaster's callback. My another thought is that add a shmem_cleanup callback to IoMethodOps and do cleanup in this callback. Not sure which is better. -- Regards, ChangAo Chen
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Lucas DRAESCHER <git@draescher.fr> — 2026-03-27T16:57:42Z
Hi ChangAo, Thanks for the review! I've attached v2, which adds a shmem_cleanup callback to IoMethodOps, registered in AioShmemInit(). Like you, I don't know which approach I prefer since the new callback currently has only one implementor. If no other IO method is expected to need cleanup, the simpler v1 approach may be preferable. Happy to hear your thoughts. I've also added this patch to the commitfest app: https://commitfest.postgresql.org/patch/6617/ Regards, Lucas.
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Lucas DRAESCHER <git@draescher.fr> — 2026-04-17T14:43:44Z
I have attached v3 which rebases v2 on top of master. v1 still applies cleanly. Regards, Lucas
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Ilmar Yunusov <tanswis42@gmail.com> — 2026-06-05T12:02:28Z
The following review has been posted through the commitfest application: make installcheck-world: not tested Implements feature: tested, passed Spec compliant: not tested Documentation: not tested Hi, I looked at v3, focusing on the reported io_uring file descriptor leak across backend crash restarts. I used the v3 attachment from Lucas's 2026-04-17 message, on origin/master at 4cb2a9863d89b320f37eb1bd76822f6f65e59311. The patch applies cleanly with git am, and git diff --check reports no issues. I first did a non-liburing build on macOS: ./configure --prefix=.../pg-install --without-readline --without-zlib --without-icu make -s -j8 make -s install That passed. I could not run TAP tests locally there because IPC::Run is not installed, and that build did not have liburing support. I then tested on Linux 6.8.0 with liburing 2.5. I configured with: ./configure --prefix="$PWD/pg-install" --without-readline --without-zlib --without-icu --enable-tap-tests --with-liburing make -s -j3 make -s install configure found liburing and io_uring_queue_init_mem, and the build/install passed. The existing AIO TAP tests passed: make -C src/test/modules/test_aio check Result: All tests successful. Files=4, Tests=780 Result: PASS For the reported leak, I compared unpatched master and v3 using an isolated server configured with io_method=io_uring. In each cycle the script counted the postmaster's /proc/<pid>/fd symlinks containing io_uring, started a client backend running pg_sleep(), killed that backend with SIGKILL, waited for the postmaster to reinitialize after the crash restart, and counted again. On unpatched master: initial_io_uring_fds=52 cycle=1 before=52 after=104 delta=52 cycle=2 before=104 after=156 delta=52 cycle=3 before=156 after=208 delta=52 With v3: initial_io_uring_fds=52 cycle=1 before=52 after=52 delta=0 cycle=2 before=52 after=52 delta=0 cycle=3 before=52 after=52 delta=0 The v3 server log also showed the cleanup running at each reinitialization: DEBUG: cleaning up 52 io_uring processes So the reported leak reproduces for me on master, and v3 fixes it in this reproducer. I did not find a new issue in the checked path. I have not reviewed older stable branches or the backpatching question, and I did not run installcheck-world. Regards, Ilmar Yunusov The new status of this patch is: Ready for Committer
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Lætitia Avrot <laetitia.avrot@gmail.com> — 2026-06-05T15:16:21Z
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@draescher.fr> a écrit : > I have attached v3 which rebases v2 on top of master. > > v1 still applies cleanly. > > Regards, > > Lucas
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Lætitia Avrot <laetitia.avrot@gmail.com> — 2026-06-05T15:17:16Z
The following review has been posted through the commitfest application: make installcheck-world: tested, passed Implements feature: not tested Spec compliant: not tested Documentation: not tested 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
-
Re: [Bug Report + Patch] File descriptor leak when io_method=io_uring
Lucas DRAESCHER <git@draescher.fr> — 2026-06-17T09:09:46Z
Ilmar, Lætitia, Thank you for taking the time to review my patch! > 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. Thanks for the feedback, I'm happy for v2 to be the design we settle on. Thanks again to both of you for your help. Lucas.