public inbox for [email protected]  
help / color / mirror / Atom feed
From: David G. Johnston <[email protected]>
To: Siddharth Jain <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: Question regarding how databases support atomicity
Date: Fri, 3 May 2024 20:10:31 -0700
Message-ID: <CAKFQuwb2MtE02QgMQ3vvLOj7bvGMar6qwnigCBBaYLBKsdk3xg@mail.gmail.com> (raw)
In-Reply-To: <CAPqV3pQquw63Fv_fCJzAAnUWk86qHfg1cH=+mJ2N=4LGdDyrNw@mail.gmail.com>
References: <CAPqV3pRO=u1Mno06WLCFxoyxbzkYTetiqTs7WaW=_fkjRPgYhw@mail.gmail.com>
	<CAPqV3pQquw63Fv_fCJzAAnUWk86qHfg1cH=+mJ2N=4LGdDyrNw@mail.gmail.com>

On Friday, May 3, 2024, Siddharth Jain <[email protected]> wrote:

>
>
> On Fri, May 3, 2024 at 8:00 PM Siddharth Jain <[email protected]> wrote:
>
>> I am trying to sharpen my understanding of databases. Let's say there is
>> an operation foo as part of the public API that internally translates to
>> more than 1 operation - I am sure there are examples like this in postgres.
>> So to do foo we have to do following in order in all or none fashion:
>>
>> 1. Step 1
>> 2. Step 2
>> 3. Step 3
>>
>> The way I understand this is that if there is a failure in-between, we
>> start undoing and reverting the previous operations one by one.
>>
>
Not in PostgreSQL.  All work performed is considered provisional until a
commit succeeds.  At which point all provisional work, which had been
tagged with the same transaction identifier, becomes reality to the rest of
the system, by virtue of marking the transaction live.  If the commit never
happens, either because of error, rollback, or session end, the transaction
ends up being left unalive and eventually is cleaned up.

You need to ensure a “begin” happens before Step 1 and a “commit” after
Step 3.

David J.


view thread (2+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Question regarding how databases support atomicity
  In-Reply-To: <CAKFQuwb2MtE02QgMQ3vvLOj7bvGMar6qwnigCBBaYLBKsdk3xg@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox