Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgbNs-0001fJ-GQ for pgsql-bugs@arkaria.postgresql.org; Tue, 11 May 2021 23:01:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lgbNp-0001rv-Nz for pgsql-bugs@arkaria.postgresql.org; Tue, 11 May 2021 23:01:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgbNp-0001rm-HX for pgsql-bugs@lists.postgresql.org; Tue, 11 May 2021 23:01:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lgbNm-0001TB-MG for pgsql-bugs@lists.postgresql.org; Tue, 11 May 2021 23:01:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14BN1YxC912291; Tue, 11 May 2021 19:01:34 -0400 From: Tom Lane To: Andres Freund cc: a.wicht@gmail.com, pgsql-bugs@lists.postgresql.org, Peter Eisentraut Subject: Re: BUG #15990: PROCEDURE throws "SQL Error [XX000]: ERROR: no known snapshots" with PostGIS geometries In-reply-to: <20190904105618.j5l6fhyesmprmstf@alap3.anarazel.de> References: <15990-eee2ac466b11293d@postgresql.org> <20190904105618.j5l6fhyesmprmstf@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 04 Sep 2019 03:56:18 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <912289.1620774094.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 11 May 2021 19:01:34 -0400 Message-ID: <912290.1620774094@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > This looks like it might be a procedure related bug to me. Peter? Somebody reported this same bug again today [1] ... why has it still not been dealt with? After an admittedly cursory look-around, it seems like the problem can be stated as "init_toast_snapshot expects that there already is a transaction snapshot, which there is not because we just committed and nothing has re-established a transaction snapshot". So the question is, where shall we force a new transaction snapshot to be created after a COMMIT/ROLLBACK inside a procedure? The most localized fix would be to let init_toast_snapshot itself do that, but that seems like a bit of a layering violation; plus I'm not quite convinced that's the only place with the issue. (However, it *is* the only caller of GetOldestSnapshot() AFAICS. So maybe everyplace else is calling GetTransactionSnapshot() to begin with, in which case this could do likewise I should think.) It really seems to me like _SPI_commit() should have started a new transaction --- why is it okay to delay that? BTW, why is this not caught by the plpgsql-toast.spec isolation test? Seems like that's doing almost exactly the same thing as the trouble reports. regards, tom lane [1] https://www.postgresql.org/message-id/dae29212-ad31-8701-ef16-dd7420bf= aa56%40perfexpert.ch