aio: worker: Free SMGR objects when idle

Started by Nazir Bilal Yavuz2 days ago1 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

appliessuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t253831
psql -h localhost -U postgres

Built from patchset v1 (message #1), September 20, 2026 at 07:46 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t253831_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t253831_1 && git checkout t253831_1

Patchset v1 (message #1) is on t253831_1

Jump to latest
#1Nazir Bilal Yavuz
byavuz81@gmail.com

Hi,

IO worker processes call smgropen with smgr_aio_reopen() -> smgropen()
path. smgropen() has a comment mentioning:

/*
* If this function is called
* outside of a transaction, the object remains valid until smgrdestroy() or
* smgrdestroyall() is called.
/*

Since, IO workers call this function outside of a transaction,
smgrdestroy() needs to be called. Attached patch calls smgrdestroy()
when the IO worker is idle. There is a chance that IO workers won't be
idle forever, so we might want to trigger this after #n number of IOs
too but I didn't implement like that for the sake of simplicity.

--
Regards,
Nazir Bilal Yavuz
Microsoft

Attachments:

t253831_1
v1-0001-aio-worker-Free-SMGR-objects-when-idle.patchtext/x-patch; charset=US-ASCII; name=v1-0001-aio-worker-Free-SMGR-objects-when-idle.patchDownload+12-1