public inbox for [email protected]  
help / color / mirror / Atom feed
From: Christophe Pettus <[email protected]>
To: Siddharth Jain <[email protected]>
Cc: [email protected]
Subject: Re: Question regarding how databases support atomicity
Date: Fri, 3 May 2024 20:20:49 -0700
Message-ID: <[email protected]> (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 May 3, 2024, at 20:02, Siddharth Jain <[email protected]> wrote:
> 
> 
> 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. But what if there is a failure and we are not able to revert an operation. How is that situation handled? e.g., something failed when we tried to do Step 3. now we revert Step 2 and succeed. but when we try to revert step 1 we fail. what happens now? To me, it seems its impossible to guarantee true atomicity in general.

PostgreSQL does not "undo" operations as such.  When modifications are made to the database, those modifications (inserts, updates, deletes) are marked with the ID of the transaction that made them.  A COMMIT or ROLLBACK in PostgreSQL just notes if those modifications are now "permanent" (if the transaction committed) or "invisible" (if the transaction rolled back).  This technique in general is called Multi-Version Concurrency Control.  Here's a good presentation that describes how it works in PostgreSQL:

	https://momjian.us/main/writings/pgsql/mvcc.pdf





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: <[email protected]>

* 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