Re: streaming replication and recovery

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: Anupama Ramaswamy <anumr_0123(at)yahoo(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: streaming replication and recovery
Date: 2014-04-08 20:01:54
Message-ID: CAL_0b1vKBJDbM8yZZ8c-7ysEPNokOM4k+0AqhV-b=v6j+JPMtw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Apr 5, 2014 at 3:48 AM, Anupama Ramaswamy <anumr_0123(at)yahoo(dot)com> wrote:
> Scenario 1
> ----------------
> Suppose the secondary server is lagging behind the primary at the time of
> primary failure, will the secondary completely catch up to the primary
> state, before stopping replication. Or what in the process ensures this
> happens ?

There are two lag types to consider about in case of a normal
streaming replication - delivery lag and replay lag. The secondary
will completely catch up to what have been delivered, but what have
not been is going to be lost. See [1][2].

> Scenario 2
> ------------------
> Both primary and secondary are running.
> Secondary goes down at time t1.
> Now primary goes down at t2. At this point, the trigger file is created.
> Secondary node restarts at time t3.
> What happens to all the transactions that occurred between t1 and t2.

They are going to be lost in case of a normal streaming replication.

Note that there is an ability to setup so called synchronous
replication [3] that guarantees delivery of changes that were commit
in exchange of some performance. Literally, it wont commit until the
changes are transferred.

So, if you have a mission critical or other high importance data you
should to setup synchronous replication, otherwise, if you can
sacrifice some latest commits, normal streaming replication.

[1] http://www.postgresql.org/docs/current/static/monitoring-stats.html#PG-STAT-REPLICATION-VIEW
[2] http://www.postgresql.org/docs/current/static/functions-admin.html#FUNCTIONS-RECOVERY-CONTROL
[3] http://www.postgresql.org/docs/current/static/warm-standby.html#SYNCHRONOUS-REPLICATION

--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
gray(dot)ru(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Elliot S 2014-04-08 20:02:58 Question about isolation level documentation
Previous Message Tom Lane 2014-04-08 19:23:57 Re: is there a way to firmly cap postgres worker memory consumption?