Re: Checkpoints stuck after a failed bulk write inside a savepoint

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: surya poondla <suryapoondla4(at)gmail(dot)com>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Joao Rito <joaovictor(dot)rito(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: Checkpoints stuck after a failed bulk write inside a savepoint
Date: 2026-11-23 23:02:53
Message-ID: awTGHAmcwe_3JErP@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 21, 2026 at 09:49:28AM -0800, surya poondla wrote:
> Regarding the backpatch, I agree that the error itself is rare. But no
> explicit SAVEPOINT is
> needed, a PL/pgSQL EXCEPTION block around the DDL is enough, and that
> pattern is common. When it happens, no checkpoint can complete until the
> transaction ends.

The error is not only rare, it could only be caused due to an
environment-related issue and would never be seen under normal running
conditions:
- smgrregistersync() is the only path that can fail (okay,
mdregistersync(), most likely depending on what's registered).
- mdnblocks() after a FileSize(), seek failure.
- Some OOMs, around paths with some repalloc or simpler pallocs.
One that may be the most problematic is indeed when the sync request
is pushed with roughly register_dirty_segment() ->
ForwardSyncRequest(), but that's also unlikely.

So as a whole I'm content with leaving that as a HEAD-only
improvement, as any fixes in this realm like OOMs that can only be hit
in a dedicated path. If there are more voices in favor of a
backpatch, let's re-evaluate that later if required.

I was also wondering if resetting the flag in some of the
sub-transaction failure paths would be an interesting thing to do, but
I cannot get much excited about that, as all the other code paths
using the checkpoint flags are already under some critical section
anyway. So it would not buy much. Or we could just backpatch what's
now 9931482364a9 down to v17, to discard the whole set of issues..

Hence, applied only on HEAD for now.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2026-11-23 23:05:02 Re: pg_regress: schedule multi-line test groups
Previous Message Peter Smith 2026-11-23 22:55:35 Re: Include schema-qualified names in publication error messages (generalised to all of LR).