On Mon, Jul 13, 2026 at 03:30:43PM -0500, Sami Imseih wrote:
> The attached 0001 reverts ed823da12891. If a strong reason ever comes up
> to turn these into an API, we can do that, but to your point there is no 
> reason
> for this as they are simply wrapper to fread/fwrite.

Fine here.

> 0002 fixes the symmetry of error handling which is a change the callbacks
> that we could still do. This is also cleaner because when an extension signals
> failure, pgstat_write_statsfile() discards the temporary file immediately 
> rather
> than writing bad data that would just be discarded on the next startup anyway.
> 
> Note that I intentionally kept the core write path using deferred error
> checking with ferror(). Core only writes to a single FILE handle, so keeping
> it as one check at the end is sufficient and avoid adding if (!...) goto error
> in about 12 different places.

Hmm.  I also see a point in not having to_serialized_data() return an
error and keep processing all the entries: if we have multiple
auxiliary files across multiple stats kinds, we would be able to let
each stats kind notice that something is wrong and let their FILE
handles be cleaned up in the finish() callback with a ferror() check.
These errors run under the assumption that one error on a file handle
would lost likely lead to other similar errors for the rest of the
files written to.  This means that we could miss opportunities to
clean up auxiliary files with 0002.
--
Michael

Attachment: signature.asc
Description: PGP signature

Reply via email to