Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC - Mailing list pgsql-bugs

From Thomas Munro
Subject Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC
Date
Msg-id CA+hUKGLbEARhvBXPL45VniV9O4h5AUocQXJ4YHrMVvK2=0JpFQ@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC  (Alexander Lakhin <exclusion@gmail.com>)
Responses Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC
Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC
List pgsql-bugs
On Thu, Apr 11, 2024 at 6:00 AM Alexander Lakhin <exclusion@gmail.com> wrote:
> 10.04.2024 14:00, PG Bug reporting form wrote:
> > The following bug has been logged on the website:
> >
> > Bug reference:      18426
> > ...
> > A demo test for the issue to follow...

I didn't try your test but your explanation seems clear.
RelationTruncate() logs first, then calls smgrtruncate() which drops
buffers and then truncates files.  The dropping-the-buffers phase is
now interruptible, since commit d87251048a0f.  If you interrupt it
there, the situation is bad: you have logged the truncation, but left
(1) buffers and (2) untruncated files on the primary.  Relation size
being out of sync is a recipe for that PANIC next time the WAL
mentions blocks past the (primary's) end.  First thought is that that
particular wait might need to hold interrupts.  Hmm.  The comments for
RelationTruncate() contemplate but reject a critical section.
Presumably it's waiting for another backend to flush data, and that
other backend will eventually finish doing that or fail/crash.



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18422: Assert in expandTupleDesc() fails on row mismatch with additional SRF
Next
From: Thomas Munro
Date:
Subject: Re: BUG #18426: Canceling vacuum while truncating a relation leads to standby PANIC