From: Álvaro Herrera <alvherre@kurilemu.de>
To: Michael Paquier <michael@paquier.xyz>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: BRIN autosummarization lacking a snapshot
Date: Tue, 4 Nov 2025 18:37:14 +0100
Message-ID: <202511041733.vkh6l7rzcwjg@alvherre.pgsql> (raw)
In-Reply-To: <202511041719.wi27m4fjjveo@alvherre.pgsql>
On 2025-Nov-04, Álvaro Herrera wrote:
> Ah, the problem is that perform_work_item() pushes an active snapshot
> before calling the BRIN function, but because of the error, we
> terminate the transaction before returning, so when we try to Pop that
> snapshot, it doesn't exist anymore. Other ways for this to happen would
> be an autovacuum worker trying to run an item for a dropped table (the
> "goto deleted2" case).
Of course, the answer is just to inquire ActiveSnapshotSet() beforehand.
I tested this by adding an elog(ERROR) in perform_work_item() -- without
this fix, I see a segfault, which disappears with it.
--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Debido a que la velocidad de la luz es mucho mayor que la del sonido,
algunas personas nos parecen brillantes un minuto antes
de escuchar las pelotudeces que dicen." (Roberto Fontanarrosa)
Attachments:
[text/x-diff] 0001-fix-brin-failure.patch (830B, ../202511041733.vkh6l7rzcwjg@alvherre.pgsql/2-0001-fix-brin-failure.patch)
download | inline diff:
From 6558ceccdb96f37d3f1db8ad426ae02d1d29231c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <alvherre@kurilemu.de>
Date: Tue, 4 Nov 2025 18:32:18 +0100
Subject: [PATCH] fix brin failure
---
src/backend/postmaster/autovacuum.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.cindex 59ec45a4e96..ed19c74bb19 100644--- a/src/backend/postmaster/autovacuum.c+++ b/src/backend/postmaster/autovacuum.c@@ -2558,7 +2558,8 @@ deleted:
PushActiveSnapshot(GetTransactionSnapshot());
perform_work_item(workitem);
- PopActiveSnapshot();+ if (ActiveSnapshotSet()) /* transaction could have aborted */+ PopActiveSnapshot();
/*
* Check for config changes before acquiring lock for further jobs.
--
2.47.3
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 using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@kurilemu.de, michael@paquier.xyz, pgsql-hackers@lists.postgresql.org
Subject: Re: BRIN autosummarization lacking a snapshot
In-Reply-To: <202511041733.vkh6l7rzcwjg@alvherre.pgsql>
* 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