Re: Lag clarification with Sync Replication

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Rui DeSousa <rui(at)crazybean(dot)net>, Raj kumar <rajkumar820999(at)gmail(dot)com>
Cc: Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Lag clarification with Sync Replication
Date: 2020-05-25 06:42:07
Message-ID: 34c00892d4434f4a02b9977c3e710361659d7e09.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Fri, 2020-05-22 at 12:48 -0400, Rui DeSousa wrote:
> > On May 22, 2020, at 12:36 AM, Raj kumar <rajkumar820999(at)gmail(dot)com> wrote:
> >
> > . But, ideally for sync replication, lag should be always 0 right.
>
> Incorrect. Synchronous replication means that a commit will not return until it has been safely written to disk on the primary and the replica. That means the transaction is written to WAL file on
> both primary and replica. On the primary, the transaction is also visible to transactions with a later xmin. On the replica, the transaction has been recorded in the WAL; it still needs to get
> applied to the database for it to become visible to read transactions.

If you set "synchronous_commit = remote_apply", the commit will only return
when the change has been replayed on the synchronous standby server.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2020-05-25 06:47:59 Re: Request to help on Query improvement suggestion.
Previous Message Raj kumar 2020-05-24 15:19:04 Re: Lag clarification with Sync Replication