On Tue, Jul 14, 2026 at 11:31:33AM -0500, Sami Imseih wrote:
> .. and you just made me realize that there is an existing bug in
> cleanup.

Bug that becomes real once 0002 is on the stack, especially with the
two error conditions I've mentioned upthread as we would still discard
the files in the WRITE case as we would likely have an ferror()
encounter.

> In the pgstat_write path, STATS_WRITE is passed unconditionally to finish()
> regardless of the outcome of the write to the core temp stats file, and in the
> pgstat_read path, the finish() is completely skipped in the case the
> core permanent
> stats file is missing. So, in both cases we need to track if the respective 
> core
> files are in a proper state and if not pass STATS_DISCARD to finish().
> 
> See the attached:
> 
> 0001 - reverts ed823da12891

Fixed this confusion as 381b3cfe2be0, based on Peter's feedback.

> 0002 - Ensures that the callbacks receive the correct STATS_DISCARD when
> there is core file failures so the extensions can perform the proper cleanup.
> This is the existing cleanup handling bug.
> 
> 0003 - Changes to_serialized_data to return a bool. It handles this case
> by removing the temp core stats file, but unlike v1 it does not need to
> do so by jumping to a new "error" block.

Even after writing the sentence in the first paragraph, the symmetry
has value once 0003 is added, so I have merged 0002 and 0003 together,
and applied the result after a few minor tweaks.  Thanks.
--
Michael

Attachment: signature.asc
Description: PGP signature

Reply via email to