Hi,
On Wed, 23 Sept 2026 at 15:18, shihao zhong <zhong950419@gmail.com> wrote:
>
> 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.
You are right that SMgrRelationHash is local and not partitioned, I
missed that. Then, I think using the 'number of unpinned entries'
makes more sense because the IO count won't work well when multiple
IOs use the same relation. I introduced the smgrnumentries() function
in v3 to get the number of cached SMgrRelation objects.
> 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.
Done.
One thing remains: if the cache doesn't grow enough and the worker
doesn't go idle (i.e. all IOs process less than
PGAIO_WORKER_SMGR_CLEANUP_THRESHOLD relation), we don't clear the SMGR
objects but I think this is a correct behavior.
--
Regards,
Nazir Bilal Yavuz
Microsoft