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 1nZA2P-0000lA-Bu for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 11:29:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nZA2N-0006Sz-IS for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Mar 2022 11:29:23 +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 1nZA2N-0006Sq-7V for pgsql-hackers@lists.postgresql.org; Tue, 29 Mar 2022 11:29:23 +0000 Received: from ewsoutbound.kpnmail.nl ([195.121.94.186]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nZA2K-0005kl-VH for pgsql-hackers@lists.postgresql.org; Tue, 29 Mar 2022 11:29:22 +0000 X-KPN-MessageId: 72a36a16-af53-11ec-9565-00505699b430 Received: from smtp.kpnmail.nl (unknown [10.31.155.6]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 72a36a16-af53-11ec-9565-00505699b430; Tue, 29 Mar 2022 13:29:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=evUA+zD+79WrLM3a9SuVKASFgZ5gRUTMCr/PI/eij/4=; b=J93abnIi+xNemQEEEMCXXDsb9FK5+jA1BkMQjyDaC2609lAI0jjRULwf2f8kag46L7n1kdd4i192T esxl1aISZl+CUC5N03WGQBjt1pPPDAcMnXs79AxZhrP6FXXTvAhM7q38qD3H6qATsp1R39/XWMerOK ymEAm6xB/+54T0ju5cxZTE5FTGruj67xNMBumEvoNyBD4gDqdOPADOw6atNHTLKFeWV9Siu2odBjak 5ti1TdTnSihnI62/8jA3FxY0y+1ZgkuVEM3xiWhhml4rT6N9x6aMPjCZzZGbAB9NshI5QREjOApXJT lpOEdR502guNm2cfqdhIGf6WCNlfhnw== X-KPN-VerifiedSender: Yes X-CMASSUN: 33|a83PhQbJRgMQDsP1V8IzYeQFBQW27wR5ynkVV1uaCaa1ehUp2QDWu/LGhQiFwmp /bmmlbadxbRVUCoQFBrz7wA== X-Originating-IP: 45.83.234.25 Received: from [192.168.178.20] (unknown [45.83.234.25]) by smtp.xs4all.nl (Halon) with ESMTPSA id 76bc4fd3-af53-11ec-bc0d-00505699772e; Tue, 29 Mar 2022 13:29:19 +0200 (CEST) Message-ID: Date: Tue, 29 Mar 2022 13:29:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: TRAP: FailedAssertion("HaveRegisteredOrActiveSnapshot()", File: "toast_internals.c", Line: 670, PID: 19403) Content-Language: en-US To: Matthias van de Meent , Kyotaro Horiguchi Cc: PostgreSQL Hackers References: <20220328.183646.1041002117568499041.horikyota.ntt@gmail.com> <20220329.170621.2101149643828659444.horikyota.ntt@gmail.com> <20220329.181011.1401235917653600685.horikyota.ntt@gmail.com> From: Erik Rijkers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Op 29-03-2022 om 12:50 schreef Matthias van de Meent: > On Tue, 29 Mar 2022 at 11:10, Kyotaro Horiguchi wrote: >> >> At Tue, 29 Mar 2022 17:06:21 +0900 (JST), Kyotaro Horiguchi wrote in >>> At Mon, 28 Mar 2022 18:36:46 +0900 (JST), Kyotaro Horiguchi wrote in >>> Then, I found that portal->holdSnapshot is that. I came up with the >>> attached. It does the follows: >>> >>> 1. Teach PlannedStmtRequiresSnapshot() to return true for FetchStmt. >>> >>> 2. Use holdSnapshot in RunFromStore if any. >>> >>> >>> The rerpducer is reduced to as small as the following. >>> >>> CREATE TABLE t (a text); >>> INSERT INTO t VALUES('some random text'); >>> BEGIN; >>> DECLARE c CURSOR FOR SELECT * FROM t; >>> FETCH ALL IN c; >>> >>> But I haven't come up with a reasonable way to generate the 'some >>> random text' yet. >> >> I gave up and took a straightforward way to generate one. >> >> I don't like that it uses a fixed length for the random text, but >> anyway it works for now... > > An shorter (?) reproducer might be the following, which forces any > value for 'a' to be toasted and thus triggering the check in > init_toast_snapshot regardless of value length: > > CREATE TABLE t (a text); > ALTER TABLE t ALTER COLUMN a SET STORAGE EXTERNAL; > INSERT INTO t VALUES ('toast'); > BEGIN; > DECLARE c CURSOR FOR SELECT * FROM t; > FETCH ALL IN c; Excellent. That indeed immediately forces the error. (and the patch prevents it) Thanks! > > Enjoy, > > -Matthias