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

From Amit Kapila
Subject Re: walsender doesn't send keepalives when writes are pending
Date
Msg-id CAA4eK1KBwcOo4TZJ79fsjWr6tmxXUc4nWSBUg8E0Rz8NBQ569Q@mail.gmail.com
Whole thread Raw
In response to walsender doesn't send keepalives when writes are pending  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: walsender doesn't send keepalives when writes are pending  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
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?

Each time in below loop, it sleeps for some time and then will again
try to send data and at that time it can detect n/w failure.
if ((caughtup && !streamingDoneSending) || pq_is_send_pending())
{
..

if (wal_sender_timeout > 0)
{
..
sleeptime = 1 + (wal_sender_timeout / 10);
}
..
WaitLatchOrSocket(&MyWalSnd->latch, wakeEvents, MyProcPort->sock, sleeptime);
}

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Selecting large tables gets killed
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: inherit support for foreign tables