Re: walsender doesn't send keepalives when writes are pending - Mailing list pgsql-hackers

From Andres Freund
Subject Re: walsender doesn't send keepalives when writes are pending
Date
Msg-id 20140221090648.GA30593@awork2.anarazel.de
Whole thread Raw
In response to Re: walsender doesn't send keepalives when writes are pending  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: walsender doesn't send keepalives when writes are pending  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
On 2014-02-21 10:08:44 +0530, Amit Kapila wrote:
> On Fri, Feb 14, 2014 at 5:35 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> > Hi,
> >
> > In WalSndLoop() we do:
> >
> >     wakeEvents = WL_LATCH_SET | WL_POSTMASTER_DEATH | WL_TIMEOUT |
> >         WL_SOCKET_READABLE;
> >
> >     if (pq_is_send_pending())
> >         wakeEvents |= WL_SOCKET_WRITEABLE;
> >     else if (wal_sender_timeout > 0 && !ping_sent)
> >     {
> > ...
> >         if (GetCurrentTimestamp() >= timeout)
> >             WalSndKeepalive(true);
> > ...
> >
> > I think those two if's should simply be separate. There's no reason not
> > to ask for a ping when we're writing. On a busy server that might be the
> > case most of the time.
> 
> I think the main reason of ping is to detect n/w break sooner.
> On a busy server, wouldn't WALSender can detect it when next time it
> will try to send the remaining data?

Well, especially on a pipelined connection, that can take a fair
bit. TCP timeouts aren't fun. There's a reason we have the keepalives,
and that they measure application to application performance. And
detecting systems as down is important for e.g. synchronous rep.

Greetings,

Andres Freund

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



pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: inherit support for foreign tables
Next
From: Sandro Santilli
Date:
Subject: Uninterruptable regexp_replace in 9.3.1 ?