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 1nCMhP-0005T5-3Y for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jan 2022 14:21:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nCMhN-0002Tp-H7 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Jan 2022 14:21:29 +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 1nCMhM-0002Tg-Dc for pgsql-hackers@lists.postgresql.org; Tue, 25 Jan 2022 14:21:29 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCMhG-0004Oz-MG for pgsql-hackers@postgresql.org; Tue, 25 Jan 2022 14:21:26 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id AEA6E3201FA1; Tue, 25 Jan 2022 09:21:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 25 Jan 2022 09:21:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=1h7iToIXXuynlELz0czzOiUFVYQL+wKAhIAZb0vHy Lc=; b=SEg9nRzQNfHqOx4KCTjoGQbMkxCtAUuoFUOldunVdqRM4xx35bmuOlNNA HRZCEua5PgzhZAZiJVhbmwYQlUNZiJaaIxDdtYHWW40CGamP/AiaublvEOTYoE9u qz+XIsqx/cdm5iGW+NUs1ax+9EYkqL19mSHXyQMYFwbLkeWuWHHnyiFIdcaeqa23 IQiXdvJO1L9WkBKcyBKAa1OuoLTTN8t6B9cc00rirK4XwdCmytswqMV2oluTj8s6 ioqNYRAjFiaC2pvONfKr48BQyX7EFRrjOaOi45SPqAWPpaSCHyHLnx2E6VzYuKbF vanls6sfI3QTUyeM91tHzRL/6OXTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrvdelgdeiudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthejre dttdefjeenucfhrhhomheprfgvthgvrhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdr vghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomheqnecuggftrfgrth htvghrnhepfeejgeehteeuhfevveduleeufedtjeetiefftedvudfhtdeifefgueettdev gefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepph gvthgvrhdrvghishgvnhhtrhgruhhtsegvnhhtvghrphhrihhsvggusgdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Jan 2022 09:21:17 -0500 (EST) Message-ID: <73daabb7-9fc7-fb7a-5e06-a968c611b032@enterprisedb.com> Date: Tue, 25 Jan 2022 15:21:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: fix crash with Python 3.11 Content-Language: en-US To: Tom Lane Cc: pgsql-hackers References: <3375ffd8-d71c-2565-e348-a597d6e739e3@enterprisedb.com> <3890110.1642373624@sss.pgh.pa.us> From: Peter Eisentraut In-Reply-To: <3890110.1642373624@sss.pgh.pa.us> 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 On 16.01.22 23:53, Tom Lane wrote: > I think a possible fix is: > > 1. Before entering the PG_TRY block, check for active subtransaction(s) > and immediately throw a Python error if there is one. (This corresponds > to the existing errors "cannot commit while a subtransaction is active" > and "cannot roll back while a subtransaction is active". The point is > to reduce the number of system states we have to worry about below.) > > 2. In the PG_CATCH block, after collecting the error data do > AbortOutOfAnyTransaction(); > StartTransactionCommand(); > which gets us into a good state with no active subtransactions. > > I'm not sure that those two are the best choices of xact.c > entry points, but there's precedent for that in autovacuum.c > among other places. AFAICT, AbortOutOfAnyTransaction() also aborts subtransactions, so why do you suggest the separate handling of subtransactions?