From: Antonin Houska <ah@cybertec.at>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Unexpected behavior after OOM errors
Date: Wed, 22 Jul 2026 10:41:10 +0200
Message-ID: <11922.1784709670@localhost> (raw)
In-Reply-To: <62382.1784640502@localhost>
References: <e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com>
<CAEze2Wgktuo+_QWfbALRW-UXXZhbSC+OgGGDFDV9m_BLy5KozQ@mail.gmail.com>
<ajN2DkXPOzzC1GSj@paquier.xyz>
<CAEze2Wj3HUz+Z4A8GaoSQyP1V_qGZEkxhp6dquF3+gNyoAmJNw@mail.gmail.com>
<ajSFcksGRhNJEs5H@paquier.xyz>
<CAEze2Wjh4_VmtD8C54q2drth2HSkCzBtgMZocuwj=z2gLDFcNQ@mail.gmail.com>
<ajUkLyWHxCeFVop_@paquier.xyz>
<ajZFM1XwbDpTQYZV@paquier.xyz>
<95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com>
<alswHQQfAdmC7M4B@paquier.xyz>
<91199.1784569717@localhost>
<CAEze2WjfEW79bA+gyQ1F6ABt6ngQRejhcsLeWzG+obV+Lp8hJg@mail.gmail.com>
<62382.1784640502@localhost>
Antonin Houska <ah@cybertec.at> wrote:
> Nevertheless, on a closer look I concluded that the problem is not related to
> OOM. Rather, *any* ERROR that happens during cache invalidation can cause
> this. Attached here is cache_inval_failure.diff that reproduces the problem
> reliably:
>
> postgres=# CREATE TABLE t1(i int PRIMARY KEY); CLUSTER t1 USING t1_pkey; DROP TABLE t1;
> CREATE TABLE
> ERROR: failure during cache invalidation
> ERROR: attempted to delete invisible tuple
>
> (The Assert(ItemIdIsNormal(lp)) IMO fires only if VACUUM manages to reset the
> item pointer before heap_delete() gets called. With autovacuum=off, I get only
> the "failure during cache invalidation" error.)
>
> So I think we need to make sure that ERROR during cache invalidation becomes
> FATAL.
Maybe something like this?
--
Antonin Houska
Web: https://www.cybertec-postgresql.comAttachments:make_cache_invalidation_fatal.diff (text/x-diff, 664B) downloaddiff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.cindex 30048e153e5..97456e8888d 100644--- a/src/backend/utils/cache/inval.c+++ b/src/backend/utils/cache/inval.c@@ -574,8 +574,15 @@ static void
ProcessInvalidationMessages(InvalidationMsgsGroup *group,
void (*func) (SharedInvalidationMessage *msg))
{
+ bool ExitOnAnyErrorSave = ExitOnAnyError;++ /*+ * Failure to invalidate cache is serious enough for the backend to exit.+ */+ ExitOnAnyError = true;
ProcessMessageSubGroup(group, CatCacheMsgs, func(msg));
ProcessMessageSubGroup(group, RelCacheMsgs, func(msg));
+ ExitOnAnyError = ExitOnAnyErrorSave;
}
/*
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: ah@cybertec.at, boekewurm+postgres@gmail.com, michael@paquier.xyz, exclusion@gmail.com
Subject: Re: Unexpected behavior after OOM errors
In-Reply-To: <11922.1784709670@localhost>
References: <e77acaac-a1b3-40b3-99ee-5769b4e453e4@gmail.com> <CAEze2Wgktuo+_QWfbALRW-UXXZhbSC+OgGGDFDV9m_BLy5KozQ@mail.gmail.com> <ajN2DkXPOzzC1GSj@paquier.xyz> <CAEze2Wj3HUz+Z4A8GaoSQyP1V_qGZEkxhp6dquF3+gNyoAmJNw@mail.gmail.com> <ajSFcksGRhNJEs5H@paquier.xyz> <CAEze2Wjh4_VmtD8C54q2drth2HSkCzBtgMZocuwj=z2gLDFcNQ@mail.gmail.com> <ajUkLyWHxCeFVop_@paquier.xyz> <ajZFM1XwbDpTQYZV@paquier.xyz> <95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com> <alswHQQfAdmC7M4B@paquier.xyz> <91199.1784569717@localhost> <CAEze2WjfEW79bA+gyQ1F6ABt6ngQRejhcsLeWzG+obV+Lp8hJg@mail.gmail.com> <62382.1784640502@localhost> <11922.1784709670@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox