Skip to content

aio: worker: Free SMGR objects when idle - #428

Open
pg-hub-mirror[bot] wants to merge 1 commit into
masterfrom
pg-hub/mirror-patch-afd43d5d9f3db835
Open

pg-hub-mirror[bot] wants to merge 1 commit into
masterfrom
pg-hub/mirror-patch-afd43d5d9f3db835

Conversation

@pg-hub-mirror

@pg-hub-mirror pg-hub-mirror Bot commented Sep 18, 2026

Copy link
Copy Markdown

Read-only mirror. Reply and review on pgsql-hackers; activity here is not sent upstream.

  • Original author: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
  • Mailing list: pgsql-hackers
  • Message-ID: CAN55FZ2BesKUnajdgpw1fPSe3S6_CHOugryaUEtD7vdP=dRKEQ@mail.gmail.com
  • Original email

Patch files:


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

IO workers create SMGR objects when reopening relations, but don't have
a transaction-end cleanup to destroy them. Long-lived workers can
therefore retain entries for an increasing number of relations,
including dropped ones.

Destroy these objects when when a completed checkpoint is observed and
when the worker is idle. At this point no borrowed descriptors or SMGR
references remain in use.
@pg-hub-mirror pg-hub-mirror Bot added area:storage Storage, access methods, buffers, or I/O source:pgsql-hackers Mirrored from pgsql-hackers type:patch Mail thread contains a PostgreSQL patch labels Sep 18, 2026
@pg-hub-mirror pg-hub-mirror Bot locked and limited conversation to collaborators Sep 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area:storage Storage, access methods, buffers, or I/O source:pgsql-hackers Mirrored from pgsql-hackers type:patch Mail thread contains a PostgreSQL patch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant