pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Petr Jelinek <petr.jelinek@2ndquadrant.com>
To: PostgreSQL-development <pgsql-hackers@postgresql.org>
To: Andres Freund <andres@anarazel.de>
Subject: Walsender timeouts and large transactions
Date: Thu, 25 May 2017 17:52:50 +0200
Message-ID: <e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Hi,

We have had issue with walsender timeout when used with logical decoding
and the transaction is taking long time to be decoded (because it
contains many changes)

I was looking today at the walsender code and realized that it's because
if the network and downstream are fast enough, we'll always take fast
path in WalSndWriteData which does not do reply or keepalive processing
and is only reached once the transaction has finished by other code. So
paradoxically we die of timeout because everything was fast enough to
never fall back to slow code path.

I propose we only use fast path if the last processed reply is not older
than half of walsender timeout, if it is then we'll force the slow code
path to process the replies again. This is similar logic that we use to
determine if to send keepalive message. I also added CHECK_INTERRUPRS
call to fast code path because otherwise walsender might ignore them for
too long on large transactions.

Thoughts?

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

Attachments:

  0001-Fix-walsender-timeouts-when-decoding-large-transacti.patch (binary/octet-stream, 0B) download

view thread (30+ messages)  latest in thread

Message-ID: <e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com>
Permalink:  ../e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com/
Also on:    postgresql.org/message-id/e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: petr.jelinek@2ndquadrant.com, andres@anarazel.de
  Subject: Re: Walsender timeouts and large transactions
  In-Reply-To: <e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com>
  References: <e082a56a-fd95-a250-3bae-0fff93832510@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox