| From: | Lucas DRAESCHER <git(at)draescher(dot)fr> |
|---|---|
| To: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | [Bug Report + Patch] File descriptor leak when io_method=io_uring |
| Date: | 2026-03-18 15:11:13 |
| Message-ID: | zHN8Rb7syWYDBPUhCICxKLr_tQmFLg0T024irxVVb6RSSicZcqcA0eT73z2PQy7JmzzqnUzX0Hi3P2dPKRvmNx_jbAqSCLyqJvWjXEypyAI=@draescher.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Release-io_uring-resources-on-shmem-exit.patch | text/x-patch | 1.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Amul Sul | 2026-03-18 15:16:35 | Re: pg_waldump: support decoding of WAL inside tarfile |
| Previous Message | Daniel Gustafsson | 2026-03-18 14:58:02 | Re: Serverside SNI support in libpq |