Re: change on_exit_nicely_list array to the dynamic array to increase slots at run time for pg_restore

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: Re: change on_exit_nicely_list array to the dynamic array to increase slots at run time for pg_restore
Date: 2025-03-10 13:43:08
Message-ID: 749623.1741614188@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mahendra Singh Thalor <mahi6run(at)gmail(dot)com> writes:
> While doing some code changes with pg_dumpall and pg_rsetore[1], we noticed
> that on_exit_nicely_list array has only fixed slots (MAX_ON_EXIT_NICELY=20)
> but in some cases, we need more slots for pg_restore.

> *Ex: restore more than 20 databases by single pg_restore command.*
> We are working on a patch[1] which dumps all the databases in non-text mode
> by pg_dumpall and then we are restoring those dumps by pg_restore. So we
> need more slots due to multiple databases.

I can't help thinking that this means you're doing it wrong.

That on_exit infrastructure is quite rickety --- see the comments for
exit_nicely() itself --- so I don't think I trust the idea of
dynamically adding callbacks. In the present usage there is actually
only *one* callback and it's registered very near the start of either
pg_dump or pg_restore. That avoids the platform-dependent hazards
mentioned in the comment, but adding more callbacks later might not.

I think you'd be better off tracking the cleanup work you have to do
in some other place.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2025-03-10 13:56:44 Re: FSM doesn't recover after zeroing damaged page.
Previous Message Kirill Reshke 2025-03-10 13:33:15 Re: Vacuum statistics