Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dDv5s-0008Kx-E6 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 May 2017 15:54:32 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dDv5r-0003Xl-Vh for pgsql-hackers@arkaria.postgresql.org; Thu, 25 May 2017 15:54:32 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dDv4K-0007EP-J6 for pgsql-hackers@postgresql.org; Thu, 25 May 2017 15:52:56 +0000 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dDv4I-0002EZ-1y for pgsql-hackers@postgresql.org; Thu, 25 May 2017 15:52:55 +0000 Received: by mail-wm0-x230.google.com with SMTP id e127so111507833wmg.1 for ; Thu, 25 May 2017 08:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=to:from:subject:message-id:date:user-agent:mime-version; bh=d77fNaDSRgFD4y91zyKvi8w9+wbQnh2gx+hDiHP/E24=; b=H3cnyDNlOc46YPz1Uftfsa3OZEDPoo0vwdsxASoPnSKysKQRNi0TyMBLgobktCd9/r 6nM1ouCq96LUTXeYmJiTio5m7cQ61Wzy40vhpKv288GF7XY3CZYWpTMzZ4tUuUaF4K9X 8PE8/tZkC3X9pWmU7GPXZaR9YvaWXa4kbFrpM0P/hzc7kg1IhYA/iQsU5e9xZ+RmS1Fi VEE2VMHXVWScM/zQC9nP2A7NhPluX1VRJqe+W27ZTQ3b8UIqt5ucB5/MdPzVmfWBKl7y s/OswJEEcAzHkYzONblil6SGiLYKs7Gseoruu6GTPKDIQM9mZKZS8XtsP7D5iK4yxbNN 3kMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=d77fNaDSRgFD4y91zyKvi8w9+wbQnh2gx+hDiHP/E24=; b=PwjkZhWSuzAm2sfb4prCQmRdwUg1gDVUeS0J6A6p59uBJrbP2jKzTOTOOSPmPLLIFf +cCFPk3DMI8c9VJ0lQLOexfCczLwsCMLMU0QdL6VM5XeA5B7KjFfIqlIgciFBwL/C21G RlS7TT5e7qiBnK19p3bZ+krnJkvh1cWqLcDhWRgFN/8UsKYWNtb/RQkxvlzHaSVDls7K gO6scuicY4jQistcinHFmFM6urEML8OwyIjWOACO16j/LuYvMyvkgjtJUZ+LtJxhfZ/K XtMSPpnl0AQUONUzoJLR0MakS2XVYSddZ4ejin1g3J1dL8iUD7pyAyxXq3zDKrxlmlh8 XfEQ== X-Gm-Message-State: AODbwcCCZTw//7G3MTkhteUZA3VAJ8K+F4Yw9gQpbiYJvlqde36J9J4S LhRgfNTt2CaihAcq X-Received: by 10.223.160.148 with SMTP id m20mr23739084wrm.176.1495727572430; Thu, 25 May 2017 08:52:52 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id 4sm12986097wrv.33.2017.05.25.08.52.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 08:52:51 -0700 (PDT) To: PostgreSQL-development , Andres Freund From: Petr Jelinek Subject: Walsender timeouts and large transactions Message-ID: Date: Thu, 25 May 2017 17:52:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8454D05B284FCB7B9D55151C" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------8454D05B284FCB7B9D55151C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 --------------8454D05B284FCB7B9D55151C Content-Type: binary/octet-stream; name="0001-Fix-walsender-timeouts-when-decoding-large-transacti.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Fix-walsender-timeouts-when-decoding-large-transacti.pa"; filename*1="tch"