Re: aio: worker: Free SMGR objects when idle

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: aio: worker: Free SMGR objects when idle
Date: 2026-09-23 12:17:50
Message-ID: CAGRkXqToSdggTG7q9yBh0NRaD8jrtE2PxMRj=G3mS3Fv2fE+UA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Nazir,

On the entry count. Nothing is pinned in an IO worker, only the
relcache calls smgrpin(), which also answers Alexandre's question. So
the unpinned count is just hash_get_num_entries(), and that only reads
a counter. SMgrRelationHash is local and not partitioned. The IO
counter is fine with me too though.

One gap in v2. v1 cleaned up when the worker went idle, v2 does not.
A worker that does fewer than 1024 IOs and then sleeps keeps those
entries and their descriptors until it gets busy again. #19622 has
that case, workers idle for 51 minutes still holding descriptors of
dropped tables. Maybe also clean up in the idle branch when
ios_since_smgr_cleanup > 0. That needs no lock either.

Thanks,
Shihao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-09-23 12:23:33 Re: [PATCH] Two remaining shmem attachment issues in single-user mode
Previous Message shihao zhong 2026-09-23 12:08:31 Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten