pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PG replicas and transactions atomicity
5+ messages / 3 participants
[nested] [flat]

* PG replicas and transactions atomicity
@ 2023-01-05 20:07  Louis Laborde <louis.laborde@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Louis Laborde @ 2023-01-05 20:07 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

Are PG replicas updated atomically following the same transactions
boundaries as the source DB ?
For example, if 2 rows from a named table are updated atomically (with a
transaction) in the source DB, is there a guarantee that both
changes will be done atomically in a replica, or is there a time window
where only one changed row could be visible in the replica ?

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG replicas and transactions atomicity
@ 2023-01-05 20:09  Christophe Pettus <xof@thebuild.com>
  parent: Louis Laborde <louis.laborde@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Christophe Pettus @ 2023-01-05 20:09 UTC (permalink / raw)
  To: Louis Laborde <louis.laborde@gmail.com>; +Cc: pgsql-general@lists.postgresql.org



> On Jan 5, 2023, at 12:07, Louis Laborde <louis.laborde@gmail.com> wrote:
> 
> Are PG replicas updated atomically following the same transactions boundaries as the source DB ?

Yes.  The same transactional guarantees apply to the replica as do to the original transactions on the primary.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG replicas and transactions atomicity
@ 2023-01-06 00:03  Ron <ronljohnsonjr@gmail.com>
  parent: Christophe Pettus <xof@thebuild.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Ron @ 2023-01-06 00:03 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 1/5/23 14:09, Christophe Pettus wrote:
>> On Jan 5, 2023, at 12:07, Louis Laborde <louis.laborde@gmail.com> wrote:
>>
>> Are PG replicas updated atomically following the same transactions boundaries as the source DB ?
> Yes.  The same transactional guarantees apply to the replica as do to the original transactions on the primary.

Even in asynchronous replication?

-- 
Born in Arizona, moved to Babylonia.





^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG replicas and transactions atomicity
@ 2023-01-06 00:04  Christophe Pettus <xof@thebuild.com>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Christophe Pettus @ 2023-01-06 00:04 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org



> On Jan 5, 2023, at 16:03, Ron <ronljohnsonjr@gmail.com> wrote:
> 
> Even in asynchronous replication?

Yes.  Asynchronous replication controls when the client doing the transaction is told that the transaction is complete; it doesn't allow for dirty reads on either the primary or secondary.




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: PG replicas and transactions atomicity
@ 2023-01-06 03:46  Christophe Pettus <xof@thebuild.com>
  parent: Christophe Pettus <xof@thebuild.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Christophe Pettus @ 2023-01-06 03:46 UTC (permalink / raw)
  To: Bhautik Chudasama <bhautikrchudasama@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>



> On Jan 5, 2023, at 19:38, Bhautik Chudasama <bhautikrchudasama@gmail.com> wrote:
> 
> Does it mean when we commit transaction, client will wait until all replicas successfully committed the transaction.

It depends.  If all the settings are the defaults, no, the client won't wait for the replicas to acknowledge the commit of the transaction.  This is asynchronous replication.

Synchronous replication can be set up, though, in which case the client will wait until some or all of the replicas have reported back that they've committed, depending on how it is configured.  The documentation explains the detailsl:

	https://www.postgresql.org/docs/current/warm-standby.html#SYNCHRONOUS-REPLICATION




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2023-01-06 03:46 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 20:07 PG replicas and transactions atomicity Louis Laborde <louis.laborde@gmail.com>
2023-01-05 20:09 ` Christophe Pettus <xof@thebuild.com>
2023-01-06 00:03   ` Ron <ronljohnsonjr@gmail.com>
2023-01-06 00:04     ` Christophe Pettus <xof@thebuild.com>
2023-01-06 03:46       ` Christophe Pettus <xof@thebuild.com>

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