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 1pr3bf-0007wa-OE for pgsql-general@arkaria.postgresql.org; Mon, 24 Apr 2023 21:20:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pr3be-0004EU-IB for pgsql-general@arkaria.postgresql.org; Mon, 24 Apr 2023 21:20:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pr3be-0004EL-6x for pgsql-general@lists.postgresql.org; Mon, 24 Apr 2023 21:20:18 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pr3bb-001h75-QU for pgsql-general@lists.postgresql.org; Mon, 24 Apr 2023 21:20:16 +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 33OLKDvR548097; Mon, 24 Apr 2023 17:20:13 -0400 From: Tom Lane To: "David G. Johnston" cc: David Wheeler , Siddharth Jain , pgsql-general@lists.postgresql.org Subject: Re: what happens if a failed transaction is not rolled back? In-reply-to: References: <5AE892DD-A808-4874-AAD4-C47E5C92E28D@gmail.com> Comments: In-reply-to "David G. Johnston" message dated "Mon, 24 Apr 2023 13:24:06 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <548095.1682371213.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Mon, 24 Apr 2023 17:20:13 -0400 Message-ID: <548096.1682371213@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Mon, Apr 24, 2023 at 12:56 PM David Wheeler > wrote: >> Now I’m curious. Does it have the same impact on performance that an idle >> in transaction connection has? Eg does it prevent vacuum? Does it still >> hold locks? > Absent documentation to the contrary I would expect the system to at best > be in an idle-in-transaction state as-if the failed command never was > executed. A quick experiment will show you that we release locks as soon as the transaction is detected to have failed. I believe the same is true of other interesting resources such as snapshots (which'd be what affects vacuum) but it's less easy to observe that from the SQL level. At least by intention, a failed transaction won't hold any resources that would impact other sessions. > The concept of savepoints, whether in use in a particular > transaction, would require at least that much state be preserved. Of course, we can't release resources that were acquired by a still-live subtransaction, a/k/a savepoint. regards, tom lane