Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmSVv-000nSb-2D for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 08:41:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wmSVv-00B5b3-14 for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Jul 2026 08:41:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmSVu-00B5au-2g for pgsql-hackers@lists.postgresql.org; Wed, 22 Jul 2026 08:41:14 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wmSVr-00000001OO3-3Gy4 for pgsql-hackers@postgresql.org; Wed, 22 Jul 2026 08:41:13 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-47f7027ca11so2588890f8f.3 for ; Wed, 22 Jul 2026 01:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1784709671; x=1785314471; darn=postgresql.org; h=message-id:date:content-type:mime-version:comments:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=iiTj5J+AQ8gYVd4WMIXyecBigo1ugSVBjzFsM5U2K1A=; b=ja/iBnCKrrv0UW0J4vwNNvlCFgKmq80ooZYtsHDHhClK6p8X91oFR6G4kBpIaffiEm 5WA1laXkJygEkM5tHVHo//9d2+mwykIJiyXEwdkIXNY7su0f4YSDIfE4QQY4+Q/cgqRp 7AnvrbMt1YvbHJVVWdK2bujMouF9oIsmv3ZOTGN6Kj4DpKcKNUzscquVEwvye1WWKoTU RS+/MFFFZIBbREnCAtagE0zeWzpX97CTsUTxeL1+MiOnSJUFznxoDr2XMzpQl8Y/388R Kro4EUiWaXbbu1u3NebRWZ8zzBRBnNBRCzzRu88uPrHHZy4Hmo1Ompk/rAXvnwuIaXi4 j0eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784709671; x=1785314471; h=message-id:date:content-type:mime-version:comments:references :in-reply-to:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=iiTj5J+AQ8gYVd4WMIXyecBigo1ugSVBjzFsM5U2K1A=; b=VgGdrW4q0R2NEVw74WkiNDF1s59rPhipOWFDXzl43HG/4UIlV+Rsuc9FKbGccVcWWn XbkKGNKuuMJl86dfTYbjSS56ONCwGAAABQ+D7GESeGwna+m+DBAc8OBd3IcSNRmHeiIc VDE+tnh8q9dspwSI9r2UdJnjkVgAOAMC94tX7aCyUkg2C3jli7w5aCocQj9pTj36Gf9y dUm3IwnlUvHwmZJtvfLmvzaoJdVDpWD93/ete9/RPTqSwlZwGrQrVqpXNYt9c5yC4HJF fO15STxobupAMwlvBkt+ArekZvLhOifEKQs2kafEiffkY67X9mAAj9vdgqb00UONHpCN kFUg== X-Forwarded-Encrypted: i=1; AHgh+RrZNNHEi1YNcpFztrSka/gJprg5Hg4z8++PpdJ/xv8mrhxGZCgCSRTvdmUPzkE21tNm+ELcmEe98xp+3TWs@postgresql.org X-Gm-Message-State: AOJu0Yxm3SglI0vY4CxlVCnzdyQqtzxXZqnKbMeQrA3Ajfpx2ZjzzxvD NcYqxPT9ay0+Cp4XJpJT6IPg8GFfzP1J9bZTWhhl0F30xLz+1QtbvcwaV8NA3y6z6ek= X-Gm-Gg: AR+sD13T0eMOvOx59J80a95A1Q18EaW0/lCE4BBn2psL01LOhkkQQxbZ5qYUAH7JKtC xafHyW48qTC/5aVlDwxeWXsWbKs5gvdKNjpuk8sJ91/948MqweO9oFRA+C5QyQNxySNdFTD4YWH Cfi1/Z/Wiaachpg8DrYWgtat4uxuG2iJHSYn5zF57OO+e5EPzdivYEcUqIidAWpuFTWVZocq21w FXQ8WNRDsFEb4NPxrzJ2RKs+gPY7lbcjw9UkVYElfrWQmSL14sxsx33YzuBkYTU/qDqIt+NE9+k qOjckNqpNCnsqHUet0QsEACmuQ65Xq/nl9mCe6XhSKrdsabZ+BGYGLMPPRMcuNaT1Sz+bxt4EZY uTU1J9m5LezX7fXmg+FT6q5j4Q32xlFxE1EHyscRVBkA0sKeVsaKTmNV84MmQlLxMrJg2MCAIWF K3+8TUDGRWzWsCus0= X-Received: by 2002:a05:6000:2dc6:b0:47f:5369:bba with SMTP id ffacd0b85a97d-47f6230c62fmr28853271f8f.15.1784709670971; Wed, 22 Jul 2026 01:41:10 -0700 (PDT) Received: from localhost (109-81-170-190.rct.o2.cz. [109.81.170.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f85bb5127sm4408154f8f.10.2026.07.22.01.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2026 01:41:10 -0700 (PDT) From: Antonin Houska To: Matthias van de Meent Cc: Michael Paquier , Alexander Lakhin , pgsql-hackers Subject: Re: Unexpected behavior after OOM errors In-reply-to: <62382.1784640502@localhost> References: <95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com> <91199.1784569717@localhost> <62382.1784640502@localhost> Comments: In-reply-to Antonin Houska message dated "Tue, 21 Jul 2026 15:28:22 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Wed, 22 Jul 2026 10:41:10 +0200 Message-ID: <11922.1784709670@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Antonin Houska 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.com --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=make_cache_invalidation_fatal.diff diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 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; } /* --=-=-=--