Re: how is the WAL receiver process stopped and restarted when the network connection is broken and then restored? - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: how is the WAL receiver process stopped and restarted when the network connection is broken and then restored?
Date
Msg-id CAMsr+YE1Oc7axX=KqSUGn=wQp4gs=VLxO4WFk1YJP4E2X8yomA@mail.gmail.com
Whole thread Raw
In response to how is the WAL receiver process stopped and restarted when the network connection is broken and then restored?  (Rui Hai Jiang <ruihaij@gmail.com>)
Responses Re: how is the WAL receiver process stopped and restarted when the network connection is broken and then restored?  (Rui Hai Jiang <ruihaij@gmail.com>)
List pgsql-hackers
On 22 June 2016 at 23:52, Rui Hai Jiang <ruihaij@gmail.com> wrote:
Hello,

I have one Primary server and one Standby server. They are doing streaming replication well.

I  did some testing. I broke the network connection between them for a few minutes, and then restored the network. I found the both the WAL sender and WAL receiver were stopped and the restarted.

I wonder how WAL receiver process is stopped and restarted. I have checked the code hoping to find out the answer, but I don't have any clue. 

If TCP keepalives are enabled, the TCP connection will break when the keepalives stop arriving.

If wal receiver timeout is enabled, it'll notice that it didn't get any data from the walsender and assume it went away.

If the OS notices that the socket went away - say, it got a TCP RST from the remote peer as it shut down cleanly - it'll close the walreceiver socket and the walreceiver will quit.

Otherwise it won't notice and will wait indefinitely.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Parallelized polymorphic aggs, and aggtype vs aggoutputtype
Next
From: Tom Lane
Date:
Subject: Re: Parallelized polymorphic aggs, and aggtype vs aggoutputtype