Обсуждение: [Proposal] Adding Log File Capability to pg_createsubscriber

Поиск
Список
Период
Сортировка

[Proposal] Adding Log File Capability to pg_createsubscriber

От
Gyan Sreejith
Дата:

Background:

  • pg_createsubscriber currently outputs all messages (internal validation messages, standby server start/stop logs, recovery progress output, and output from utilities) directly to the console. As a result, users may find debugging and handling errors difficult. It would be more convenient if messages were separated and stored in different log files. There is already a similar implementation in pg_upgrade.

Proposed Solution:

  • Based on issues mentioned previously, I would like to propose a new argument -l <logdir> which can be specified for pg_createsubscriber. Using it would create the following log files:

    • logdir/pg_createsubscriber_server.log which captures all logs related to starting and stopping the standby server.

    • logdir/pg_createsubscriber_resetwal.log which captures the output of pg_resetwal

    • logdir/pg_createsubscriber_internal.log which captures internal diagnostic output from pg_createsubscriber (validations, checks, etc.)

Overall, this proposed solution could make the pg_createsubscriber command output messages more organized. The command would be easier to use as users will only have to read individual log files rather than parse through lots of possibly irrelevant output messages. I have attached the patch for this change. 

Special thanks to Vignesh C. for his offlist guidance on this project. 


Regards, Gyan Sreejith



Вложения

Re: [Proposal] Adding Log File Capability to pg_createsubscriber

От
Peter Smith
Дата:
On Wed, Dec 10, 2025 at 9:17 AM Gyan Sreejith <gyan.sreejith@gmail.com> wrote:
>
> Background:
>
> pg_createsubscriber currently outputs all messages (internal validation messages, standby server start/stop logs,
recoveryprogress output, and output from utilities) directly to the console. As a result, users may find debugging and
handlingerrors difficult. It would be more convenient if messages were separated and stored in different log files.
Thereis already a similar implementation in pg_upgrade. 
>
> Proposed Solution:
>
> Based on issues mentioned previously, I would like to propose a new argument -l <logdir> which can be specified for
pg_createsubscriber.Using it would create the following log files: 
>
> logdir/pg_createsubscriber_server.log which captures all logs related to starting and stopping the standby server.
>
> logdir/pg_createsubscriber_resetwal.log which captures the output of pg_resetwal
>
> logdir/pg_createsubscriber_internal.log which captures internal diagnostic output from pg_createsubscriber
(validations,checks, etc.) 
>
> Overall, this proposed solution could make the pg_createsubscriber command output messages more organized. The
commandwould be easier to use as users will only have to read individual log files rather than parse through lots of
possiblyirrelevant output messages. I have attached the patch for this change. 
>
> Special thanks to Vignesh C. for his offlist guidance on this project.
>
>
> Regards, Gyan Sreejith
>

Hi Gyan.

I haven't yet looked at this patch in any detail, but here are some
quick comments:

======

1.
+ printf(_("  -l, --logdir=LOGDIR             location for the new log
directory\n"));

The patch is missing SGML docs updates for pg_createsubscriber new
option, and any explanation of the split of logfiles.

2.
I might be mistaken, but IIUC it seems the splitting of the logfile
only works when --logdir is specified. Is that correct?
Why should --logdir have any side-effect other than assigning the log
destination folder?

======
Kind Regards,
Peter Smith.
Fujitsu Australia



Re: [Proposal] Adding Log File Capability to pg_createsubscriber

От
Gyan Sreejith
Дата:
Thanks for the feedback, Peter.

I am currently working on the SGML docs update, and will promptly get back with an update. 

For your second point, currently, all output goes directly to the console. I thought it made more sense to break it up into multiple files depending on what was being invoked. Do you have another opinion? 

Thank you once again,
Gyan Sreejith

On Thu, Dec 11, 2025 at 2:29 AM Peter Smith <smithpb2250@gmail.com> wrote:
On Wed, Dec 10, 2025 at 9:17 AM Gyan Sreejith <gyan.sreejith@gmail.com> wrote:
>
> Background:
>
> pg_createsubscriber currently outputs all messages (internal validation messages, standby server start/stop logs, recovery progress output, and output from utilities) directly to the console. As a result, users may find debugging and handling errors difficult. It would be more convenient if messages were separated and stored in different log files. There is already a similar implementation in pg_upgrade.
>
> Proposed Solution:
>
> Based on issues mentioned previously, I would like to propose a new argument -l <logdir> which can be specified for pg_createsubscriber. Using it would create the following log files:
>
> logdir/pg_createsubscriber_server.log which captures all logs related to starting and stopping the standby server.
>
> logdir/pg_createsubscriber_resetwal.log which captures the output of pg_resetwal
>
> logdir/pg_createsubscriber_internal.log which captures internal diagnostic output from pg_createsubscriber (validations, checks, etc.)
>
> Overall, this proposed solution could make the pg_createsubscriber command output messages more organized. The command would be easier to use as users will only have to read individual log files rather than parse through lots of possibly irrelevant output messages. I have attached the patch for this change.
>
> Special thanks to Vignesh C. for his offlist guidance on this project.
>
>
> Regards, Gyan Sreejith
>

Hi Gyan.

I haven't yet looked at this patch in any detail, but here are some
quick comments:

======

1.
+ printf(_("  -l, --logdir=LOGDIR             location for the new log
directory\n"));

The patch is missing SGML docs updates for pg_createsubscriber new
option, and any explanation of the split of logfiles.

2.
I might be mistaken, but IIUC it seems the splitting of the logfile
only works when --logdir is specified. Is that correct?
Why should --logdir have any side-effect other than assigning the log
destination folder?

======
Kind Regards,
Peter Smith.
Fujitsu Australia

Re: [Proposal] Adding Log File Capability to pg_createsubscriber

От
Gyan Sreejith
Дата:
I have included the patch file after making the changes to the SGML docs. 

Thanks for your help,
Gyan Sreejith

On Thu, Dec 11, 2025 at 8:33 PM Gyan Sreejith <gyan.sreejith@gmail.com> wrote:
Thanks for the feedback, Peter.

I am currently working on the SGML docs update, and will promptly get back with an update. 

For your second point, currently, all output goes directly to the console. I thought it made more sense to break it up into multiple files depending on what was being invoked. Do you have another opinion? 

Thank you once again,
Gyan Sreejith

On Thu, Dec 11, 2025 at 2:29 AM Peter Smith <smithpb2250@gmail.com> wrote:
On Wed, Dec 10, 2025 at 9:17 AM Gyan Sreejith <gyan.sreejith@gmail.com> wrote:
>
> Background:
>
> pg_createsubscriber currently outputs all messages (internal validation messages, standby server start/stop logs, recovery progress output, and output from utilities) directly to the console. As a result, users may find debugging and handling errors difficult. It would be more convenient if messages were separated and stored in different log files. There is already a similar implementation in pg_upgrade.
>
> Proposed Solution:
>
> Based on issues mentioned previously, I would like to propose a new argument -l <logdir> which can be specified for pg_createsubscriber. Using it would create the following log files:
>
> logdir/pg_createsubscriber_server.log which captures all logs related to starting and stopping the standby server.
>
> logdir/pg_createsubscriber_resetwal.log which captures the output of pg_resetwal
>
> logdir/pg_createsubscriber_internal.log which captures internal diagnostic output from pg_createsubscriber (validations, checks, etc.)
>
> Overall, this proposed solution could make the pg_createsubscriber command output messages more organized. The command would be easier to use as users will only have to read individual log files rather than parse through lots of possibly irrelevant output messages. I have attached the patch for this change.
>
> Special thanks to Vignesh C. for his offlist guidance on this project.
>
>
> Regards, Gyan Sreejith
>

Hi Gyan.

I haven't yet looked at this patch in any detail, but here are some
quick comments:

======

1.
+ printf(_("  -l, --logdir=LOGDIR             location for the new log
directory\n"));

The patch is missing SGML docs updates for pg_createsubscriber new
option, and any explanation of the split of logfiles.

2.
I might be mistaken, but IIUC it seems the splitting of the logfile
only works when --logdir is specified. Is that correct?
Why should --logdir have any side-effect other than assigning the log
destination folder?

======
Kind Regards,
Peter Smith.
Fujitsu Australia
Вложения

RE: [Proposal] Adding Log File Capability to pg_createsubscriber

От
"Hayato Kuroda (Fujitsu)"
Дата:
Dear Gyan,

+1 for the idea. This point has already been discussed since the initial commit
[1], but it has left till now. I'm happy if you can take initiative.
Of course I can review your patches.

Per my understanding, pg_upgrade puts logfiles at the directory, under
"${PGDATANEW}/pg_upgrade_output.d/${timestamp}". See Note part in [2].
I feel more straightforward way is to follow that approach:

1. pg_createsubscriber creates a directory pg_createsubscriber_output.d/${timestamp}.
   ${timestamp} has the same format as ISO 8601 (%Y%m%dT%H%M%S).
2. pg_craetesubscriber saves outputs under the directory.
3. Outputs can be retained when the command failed or --retain is specified.
   Otherwise, they are removed at the end.

Are there benefits to provide -l option?

Regarding the patch format, our community prefers patches generated by
git format-patch. Can you see the blogpost [3] and try to create patches based on the command?
One benefit is we can easily do versioning.

[1]: https://www.postgresql.org/message-id/60b45b8a-3047-4a21-ba2a-ddb15daa638f%40eisentraut.org
[2]: https://www.postgresql.org/docs/devel/pgupgrade.html
[3]: https://peter.eisentraut.org/blog/2023/05/09/how-to-submit-a-patch-by-email-2023-edition

Best regards,
Hayato Kuroda
FUJITSU LIMITED