Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s35g6-009Gde-VV for pgsql-general@arkaria.postgresql.org; Sat, 04 May 2024 03:03:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s35g3-00EH4D-8a for pgsql-general@arkaria.postgresql.org; Sat, 04 May 2024 03:03:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s35g2-00EH43-Tj for pgsql-general@lists.postgresql.org; Sat, 04 May 2024 03:03:07 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s35fw-001KxI-VW for pgsql-general@lists.postgresql.org; Sat, 04 May 2024 03:03:06 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-de46b113a5dso289174276.3 for ; Fri, 03 May 2024 20:03:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714791780; x=1715396580; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=N9G07YmsFFhYQMe17GC5XAsqjtDndHtiTJwBcnPRhKQ=; b=bUbsu2Lpy+RkEH8I/seQ3SGTmWfHUKoLOwzldohubaihV7HLGTsVFAc/bg9rV3oOdI BoX4HrXDmkCioMc7jzcHkNMhnYp07AfHbmo1Q7mzqC/wI5mZ1rnrp8HhE6XM+b7fv8yD 9fFP8sOPuhvxLrx9KUUpsEeUBCsDjzywHkk51KCH8fcpVPPXm9ShNSxQDIF7xs6rRaQa zTd+tyxU7aFJh/9kfc0HfewCE0oxRFBYIkdxCyfvP3uKW/tQzLmNT0YCFNnESWd/6cun qHmaqx9SBmuNFbJY0d3JLgC9C67JOW77Qi4/f84eMFQARpRz92Vb404W9zqmvqKEeYga NAGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714791780; x=1715396580; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=N9G07YmsFFhYQMe17GC5XAsqjtDndHtiTJwBcnPRhKQ=; b=C5QAgK6QRtYgLqAy1JuoSc+hKwUNkKxELyqBqr3SOM2xOC2Wpxdrdw1NF38xzpTjTB kyBY+ybnpdknOBIDs6feZG6tBuS1RehPHAaueZ4/TVH4QKels8hwoyBRe/f2X84x0TjG Js2X+I0dUTtW+rqiWsK8w3WMy44oO+FFxNdVXiuefsMGFtTlIm+hsSwyn7vyJE42MyS1 WQkz9x0g4VSWeTQcqoO4xxGGDjm8eqGtWEuu9LawCww7dEOi75M7JNBHYJOTrLLASpNi s5xFdHgXv4ef8b+d33bUMTCTF/qCAB2jSs9zqnSso2j2YDc683dz3xqdIuPXi77TW99j 7+Dg== X-Gm-Message-State: AOJu0YwA8AyTyvNTESTRLUHtDa/q9wafOvRIEDlThDaFeRp6ND28KqVv 9y18jmkGCOjeixCJnVidfjjXk8cZQWQZpg+gW29UhU2XbDp4ryzt86642zBpGFsCyVD9V51rAW/ g6994LK5qOyZRHGNk1o7J9CDxA45wQA== X-Google-Smtp-Source: AGHT+IESfk9gWkuZuwZvWFsmlKtFbWQNpu0r5hwRcwp4codFJcuQlvFh445pC8MJhLjcBN7lZX68EeOKW5cDTAVUBQY= X-Received: by 2002:a25:ae61:0:b0:de6:a3d:265f with SMTP id g33-20020a25ae61000000b00de60a3d265fmr4777002ybe.2.1714791779971; Fri, 03 May 2024 20:02:59 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Siddharth Jain Date: Fri, 3 May 2024 20:02:49 -0700 Message-ID: Subject: Re: Question regarding how databases support atomicity To: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000e8c02306179812c9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e8c02306179812c9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, May 3, 2024 at 8:00=E2=80=AFPM Siddharth Jain = 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 postgre= s. > 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. But what = if > there is a failure and we are not able to revert an operation. How is tha= t > 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. > > S. > --000000000000e8c02306179812c9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Fri, May 3, 2024 at 8:00=E2=80=AFPM Siddharth Jain = <siddhsql@gmail.com> 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 t= o more than 1 operation - I am sure there are examples like this in postgre= s. 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= . 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 tru= e atomicity in general.

S.
--000000000000e8c02306179812c9--