public inbox for [email protected]
help / color / mirror / Atom feedFrom: Hayato Kuroda (Fujitsu) <[email protected]>
To: 'Chao Li' <[email protected]>
To: Gyan Sreejith <[email protected]>
Cc: Amit Kapila <[email protected]>
Cc: shveta malik <[email protected]>
Cc: Shlok Kyal <[email protected]>
Cc: vignesh C <[email protected]>
Cc: Euler Taveira <[email protected]>
Cc: [email protected] <[email protected]>
Cc: Peter Smith <[email protected]>
Subject: RE: [Proposal] Adding Log File Capability to pg_createsubscriber
Date: Tue, 24 Mar 2026 09:47:07 +0000
Message-ID: <OS9PR01MB12149F1AD9C79A2644753A18AF548A@OS9PR01MB12149.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <[email protected]>
References: <OSOPR01MB1215385EAC6A76650444E40B0F54FA@OSOPR01MB12153.jpnprd01.prod.outlook.com>
<CAEqnbaU=EgqhxEx0ig4TdY8pdt0Vn+vmCJBuoORRHOzovW9dWA@mail.gmail.com>
<TYRPR01MB12156F431E4B83ECFF14034BDF54CA@TYRPR01MB12156.jpnprd01.prod.outlook.com>
<CAEqnbaXb-TKUm7P-=_zrgQ=shRXkkZscPOHEL9OS6Cb2V8YT8Q@mail.gmail.com>
<CAA4eK1JiAzaY7UYnya7uDhX-kAL1PrsOAxBtys7c35t4q4H3_A@mail.gmail.com>
<CAEqnbaVF0yXQk=VVzr-8V23E=iUpUqyah6hxx2fy0ZVJh+CaGA@mail.gmail.com>
<CAJpy0uAwPNG3GN5+jTajnccLe+F1mW6dZh-9112u3QQQYugA=Q@mail.gmail.com>
<CAA4eK1JyYHPgaPTow5co8wBh8Ga+fx=vqHLhk2zHeqdOGYN4Vg@mail.gmail.com>
<OS9PR01MB12149FECFFF25973C167F9CFAF54BA@OS9PR01MB12149.jpnprd01.prod.outlook.com>
<CAEqnbaULSSQcir8Z8KDXduV4o4NZvJLeBMZN0VW3wh5QZjpEnw@mail.gmail.com>
<[email protected]>
Dear Chao,
> One comment on v17.
> ```
> + if (internal_log_file_fp != NULL)
> + {
> + if (fclose(internal_log_file_fp) != 0)
> + report_createsub_fatal("could not
> close %s/%s.log: %m", logdir, INTERNAL_LOG_FILE_NAME);
> + internal_log_file_fp = NULL;
> + }
> ```
>
> As the error is about internal_log_file_fp, meaning it may no longer able to write to
> internal_log_file_fp anymore, we should avoid use report_createsub_fatal to log
> the error again. Maybe just a pg_fatal(), or just log to stderr.
I checked and found [1] in the exit() specification. It means all file descriptors
opened by the process would be closed automatically when the process exits.
So no need to try fclose() and report the failure here. Similarly, pg_upgrade
does not have fclose(log_opts.internal) in case of failures.
[1]:
First, all functions registered by the atexit function are called, in the reverse
order of their registration, except that a function is called after any previously
registered functions that had already been called at the time it was registered.
If, during the call to any such function, a call to the longjmp function is made
that would terminate the call to the registered function, the behavior is
undefined.
Next, all open streams with unwritten buffered data are flushed, all open streams
are closed, and all files created by the tmpfile function are removed.
Best regards,
Hayato Kuroda
FUJITSU LIMITED
view thread (65+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: RE: [Proposal] Adding Log File Capability to pg_createsubscriber
In-Reply-To: <OS9PR01MB12149F1AD9C79A2644753A18AF548A@OS9PR01MB12149.jpnprd01.prod.outlook.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox