From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: David Wheeler <hippysoyboy@gmail.com>
Cc: Siddharth Jain <siddhsql@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: what happens if a failed transaction is not rolled back?
Date: Mon, 24 Apr 2023 17:20:13 -0400
Message-ID: <548096.1682371213@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZ+i6LMi0DyD6=H_FrmbErpK7q39Tq7GypZ_6FZ6FRNFw@mail.gmail.com>
References: <CAKFQuwZLqqiwmNjzO=RxztMqTQ+FBu8ti9p0Gb00ZS7iW4tM7w@mail.gmail.com>
<5AE892DD-A808-4874-AAD4-C47E5C92E28D@gmail.com>
<CAKFQuwZ+i6LMi0DyD6=H_FrmbErpK7q39Tq7GypZ_6FZ6FRNFw@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Apr 24, 2023 at 12:56 PM David Wheeler <hippysoyboy@gmail.com>
> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, hippysoyboy@gmail.com, siddhsql@gmail.com
Subject: Re: what happens if a failed transaction is not rolled back?
In-Reply-To: <548096.1682371213@sss.pgh.pa.us>
References: <CAKFQuwZLqqiwmNjzO=RxztMqTQ+FBu8ti9p0Gb00ZS7iW4tM7w@mail.gmail.com> <5AE892DD-A808-4874-AAD4-C47E5C92E28D@gmail.com> <CAKFQuwZ+i6LMi0DyD6=H_FrmbErpK7q39Tq7GypZ_6FZ6FRNFw@mail.gmail.com> <548096.1682371213@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox