Hi,
Thanks for the report! I can reproduce this bug on master and your patch fixes it.
> 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.
I also verify that only the postmaster will call this callback because all children
of the postmaster will reset postmaster's callback.
My another thought is that add a shmem_cleanup callback to IoMethodOps and
do cleanup in this callback. Not sure which is better.
--
Regards,
ChangAo Chen