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.94.2) (envelope-from ) id 1vGLFT-00CwTX-1R for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Nov 2025 17:55:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vGLFR-00FkQm-Ve for pgsql-hackers@arkaria.postgresql.org; Tue, 04 Nov 2025 17:55:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vGLEm-00FgeQ-5R for pgsql-hackers@lists.postgresql.org; Tue, 04 Nov 2025 17:54:31 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vGLEi-005yFc-2b for pgsql-hackers@lists.postgresql.org; Tue, 04 Nov 2025 17:54:30 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id B198914000DD; Tue, 4 Nov 2025 12:54:27 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 04 Nov 2025 12:54:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1762278867; x= 1762365267; bh=m5JLvmQY9NcOEfmAfuPfU0GL9IrBJhBNskie01BEdII=; b=E +NoD5OMvHia3G6DuG8LIYLicQhqdnyNM8NEaQlEVI4RDhf1SPLqxQejd6bumlX9j u3g9uazQWwC/gg6f70NhQZPCRHMCjjXeMIUTMMGqHzTsHaFNQQYysoAPNjPRzOBk 01b6RfelWTLZ9VFwHk0mV/t2nOhEQ4bbYd/CFzZwPFOUUkpSD0K3AWDz5+GvjDbY BMiNhdwhRuEnXPR2unKrz0Fs0Fx0tMD8wIHCNskkie2irjKEaH4OitVP973PHSO2 cNu3hBQDiFPOE9Rij74TOg1IKqZ5mKYmYdnvOlQ5evLwQ/8Y9chM13QSS7rf7tT1 5S90lEodaRCiM1NBEauNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1762278867; x=1762365267; bh=m 5JLvmQY9NcOEfmAfuPfU0GL9IrBJhBNskie01BEdII=; b=2A70rPSquY/IsgxNe byNCt8agQkE/+Q7ydIElCGWkYOikKHQvsO7Vj4sv+h5b05sIZEmyTXkUYhbglQOC 8sXekIDiq9NSPenlP+KUMlhV4E05iCwEr8mzDpj3T9/ORlkXs99tDDq/F8U+F7Bh r2Gt2VGTctsrWXQbs4b7CGKwbgPqHhLJs3KNugdpsiZctey9wrqEaiS54u7oqiMi yMeSJ9wcPbpv59L/QSpagr9lfxtvUgXZzoNefyDWAfSWahBx2j/gGnspJ7f2dTgY ZhGgsss2Ohniey1NwzxhBa/MdekPtN1A4Ms+kPWmIUoOSVIQi4QMBpm4igVpAW6p kU71Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddukeduieejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeegudetudejheduveevgeehjeegleevveevvdeutdejtdekuefhheeh geevtdejteenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhg rhgvshhqlhdrohhrghdprhgtphhtthhopehmihgthhgrvghlsehprghquhhivghrrdighi ii X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Nov 2025 12:54:27 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1762277834; bh=MoL4EEUnQOVyMS1PxrKsZEXNbGluz881Bs8xrSRQLr4=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=AKdl0GGCjAAK80856il6b/S0wrXe/ebLGVhpQSCHNOm9ffGatBW63QGAJSg7jGN8Y JQc64R7UJJzMlkmdiL9TtAh1OTA2kIkX9EFiAcbcKkEWCdjmWAP9+UyPt8eDYhWKNr e/eSXYHhHPstucryfbAVyhSwU+VGrWCv8MIYPFkWhPhFFO2bliCp2bvILCEUEQGA6I uUlMLPOdKcMkxuiz0tBH/mMejx1VSCs/BwwM9xgqZFHMQBV64v+O5sJU4dN0RTe523 0gv3p+MRLnjJvIHIODhkJbG8W564tG5vjdGTCT9+8y5ebLsn7uj0S/SIRYz9ElzjhE hkU53UQ7GRWjA== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id EB60776; Tue, 04 Nov 2025 19:37:14 +0200 (EET) Date: Tue, 4 Nov 2025 18:37:14 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Michael Paquier Cc: Pg Hackers Subject: Re: BRIN autosummarization lacking a snapshot Message-ID: <202511041733.vkh6l7rzcwjg@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="lmmys5fo6cezmrdq" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202511041719.wi27m4fjjveo@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --lmmys5fo6cezmrdq Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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) --lmmys5fo6cezmrdq Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-fix-brin-failure.patch" From 6558ceccdb96f37d3f1db8ad426ae02d1d29231c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= 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.c index 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 --lmmys5fo6cezmrdq--