Thread: Heartbeat between Primary and Standby replicas

Heartbeat between Primary and Standby replicas

From
fazool mein
Date:
Hello everyone,<br /><br />I am designing a heartbeat system between replicas to know when a replica goes down so that
necessarymeasures can be taken. As I see, there are two ways of doing it:<br /><br />1) Creating a separate heartbeat
processon replicas.<br /> 2) Creating a heartbeat message, and sending it over the connection that is already
establishedbetween walsender and walreceiver.<br /><br />With 2, sending heartbeat from walsender to walreceiver seems
trivial.Sending a heartbeat from walreceiver to walsender seems tricky. Going through the code, it seems that the
walreceiveris always in the PGASYNC_COPY_OUT mode (except in the beginning when handshaking is done).<br /><br />Can
yourecommend the right way of doing this?<br /><br />Thank you.<br /><br />Regards<br /><br
/>---------------------------<br/>Postgres version = 9.0 beta-4<br /> 

Re: Heartbeat between Primary and Standby replicas

From
Fujii Masao
Date:
On Fri, Sep 17, 2010 at 6:49 AM, fazool mein <fazoolmein@gmail.com> wrote:
> I am designing a heartbeat system between replicas to know when a replica
> goes down so that necessary measures can be taken. As I see, there are two
> ways of doing it:
>
> 1) Creating a separate heartbeat process on replicas.
> 2) Creating a heartbeat message, and sending it over the connection that is
> already established between walsender and walreceiver.
>
> With 2, sending heartbeat from walsender to walreceiver seems trivial.
> Sending a heartbeat from walreceiver to walsender seems tricky. Going
> through the code, it seems that the walreceiver is always in the
> PGASYNC_COPY_OUT mode (except in the beginning when handshaking is done).
>
> Can you recommend the right way of doing this?

The existing keepalive feature doesn't help?

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


Re: Heartbeat between Primary and Standby replicas

From
fazool mein
Date:
Apologies. I'm new to Postgres and I didn't see that feature. It satisfies what I want to do.<br /><br />Thanks.<br
/><br/><div class="gmail_quote">On Thu, Sep 16, 2010 at 7:34 PM, Fujii Masao <span dir="ltr"><<a
href="mailto:masao.fujii@gmail.com">masao.fujii@gmail.com</a>></span>wrote:<br /><blockquote class="gmail_quote"
style="margin:0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Fri,
Sep17, 2010 at 6:49 AM, fazool mein <<a href="mailto:fazoolmein@gmail.com">fazoolmein@gmail.com</a>> wrote:<br />
>I am designing a heartbeat system between replicas to know when a replica<br /> > goes down so that necessary
measurescan be taken. As I see, there are two<br /> > ways of doing it:<br /> ><br /> > 1) Creating a separate
heartbeatprocess on replicas.<br /> > 2) Creating a heartbeat message, and sending it over the connection that is<br
/>> already established between walsender and walreceiver.<br /> ><br /> > With 2, sending heartbeat from
walsenderto walreceiver seems trivial.<br /> > Sending a heartbeat from walreceiver to walsender seems tricky.
Going<br/> > through the code, it seems that the walreceiver is always in the<br /> > PGASYNC_COPY_OUT mode
(exceptin the beginning when handshaking is done).<br /> ><br /> > Can you recommend the right way of doing
this?<br/><br /></div>The existing keepalive feature doesn't help?<br /><br /> Regards,<br /><font color="#888888"><br
/>--<br /> Fujii Masao<br /> NIPPON TELEGRAPH AND TELEPHONE CORPORATION<br /> NTT Open Source Software Center<br
/></font></blockquote></div><br/> 

Re: Heartbeat between Primary and Standby replicas

From
fazool mein
Date:
Hello again,

I checked the code for the keepalive feature. It seems that the socket options are only set on the primary's socket connection. The tcp connection created on the secondary for walreceiver does not use the keepalive parameters from the configuration.

Am I correct? Is this intended or some bug?

Thanks.



On Fri, Sep 17, 2010 at 7:05 PM, fazool mein <fazoolmein@gmail.com> wrote:
Apologies. I'm new to Postgres and I didn't see that feature. It satisfies what I want to do.

Thanks.


On Thu, Sep 16, 2010 at 7:34 PM, Fujii Masao <masao.fujii@gmail.com> wrote:
On Fri, Sep 17, 2010 at 6:49 AM, fazool mein <fazoolmein@gmail.com> wrote:
> I am designing a heartbeat system between replicas to know when a replica
> goes down so that necessary measures can be taken. As I see, there are two
> ways of doing it:
>
> 1) Creating a separate heartbeat process on replicas.
> 2) Creating a heartbeat message, and sending it over the connection that is
> already established between walsender and walreceiver.
>
> With 2, sending heartbeat from walsender to walreceiver seems trivial.
> Sending a heartbeat from walreceiver to walsender seems tricky. Going
> through the code, it seems that the walreceiver is always in the
> PGASYNC_COPY_OUT mode (except in the beginning when handshaking is done).
>
> Can you recommend the right way of doing this?

The existing keepalive feature doesn't help?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


Re: Heartbeat between Primary and Standby replicas

From
Fujii Masao
Date:
On Mon, Sep 27, 2010 at 7:46 AM, fazool mein <fazoolmein@gmail.com> wrote:
> I checked the code for the keepalive feature. It seems that the socket
> options are only set on the primary's socket connection. The tcp connection
> created on the secondary for walreceiver does not use the keepalive
> parameters from the configuration.

You can use libpq keepalive parameters for walreceiver.

keepalives_idle
keepalives_interval
keepalives_count
http://developer.postgresql.org/pgdocs/postgres/libpq-connect.html

Those can be set in primary_connection in recovery.conf.

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


Re: Heartbeat between Primary and Standby replicas

From
fazool mein
Date:
Ah, great. I missed looking there.
Thanks.

On Sun, Sep 26, 2010 at 4:19 PM, Fujii Masao <masao.fujii@gmail.com> wrote:
On Mon, Sep 27, 2010 at 7:46 AM, fazool mein <fazoolmein@gmail.com> wrote:
> I checked the code for the keepalive feature. It seems that the socket
> options are only set on the primary's socket connection. The tcp connection
> created on the secondary for walreceiver does not use the keepalive
> parameters from the configuration.

You can use libpq keepalive parameters for walreceiver.

keepalives_idle
keepalives_interval
keepalives_count
http://developer.postgresql.org/pgdocs/postgres/libpq-connect.html

Those can be set in primary_connection in recovery.conf.

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center