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

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, 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-11 06:28:06
Message-ID: CAFiTN-tcZfyo2CtfqSNY-6ogfc9PTf-QDmaEgbqZuis0gWi6EA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 10, 2025 at 2:24 PM Mahendra Singh Thalor
<mahi6run(at)gmail(dot)com> wrote:
>
> Hi,
> (refer file src/bin/pg_dump/pg_backup_utils.c)
>
> 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.
>
> Apart from the attached patch solution, we thought of some more solutions.
> Solution 1: reset array index with each database restore, but this might break some other things.
> Solution 2: for each database, we can keep the index of the on_exit_nicely_list array and after restoring a particular database we can reset the index to old value but this looks like a hack.
>
> Here, I am proposing a patch which will dynamically enlarge the on_exit_nicely_list array by doubling the previous size.
>
> Thoughts?

This reply might belong in another thread, but since you raised the
issue here, instead of registering multiple functions with
exit_nicely, why not modify the argument of the exit function
(archive_close_connection()) to handle multiple arguments? In short,
you could change ShutdownInformation[1] so that, instead of holding a
single "Archive," it holds a list, allowing you to append different
Archive handles to the list.

[1]
typedef struct ShutdownInformation
{
ParallelState *pstate;
Archive *AHX; -> change this to List of Archive*
} ShutdownInformation;

--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-03-11 06:50:11 Re: Query ID Calculation Fix for DISTINCT / ORDER BY and LIMIT / OFFSET
Previous Message Bertrand Drouvot 2025-03-11 06:23:43 Re: per backend WAL statistics