| From: | Sami Imseih <samimseih(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: [Proposal] Adding callback support for custom statistics kinds |
| Date: | 2026-07-14 04:30:29 |
| Message-ID: | CAA5RZ0uLWTyYG8xC13FWEa-uQ14nkwga1ZubqSG2qaqRQfdgUQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> > 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.
When an error is returned from a callback, the error block in 0002 only
discards the core stats temp file and then moves on to call the finish
callback for every extension that registered one ( and they better register
one to perform cleanups ). So, the proposed will not cause any missed
cleanups of auxiliary files.
--
Sami
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Suraj Kharage | 2026-07-14 04:38:59 | Re: [PATCH] Add support for INSERT ... SET syntax |
| Previous Message | jian he | 2026-07-14 04:15:43 | Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object |