Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFhRo-0005q5-L9 for pgsql-hackers@arkaria.postgresql.org; Tue, 30 May 2017 13:44: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 1dFhRo-0001MS-7y for pgsql-hackers@arkaria.postgresql.org; Tue, 30 May 2017 13:44:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dFhRn-0001M2-BF for pgsql-hackers@postgresql.org; Tue, 30 May 2017 13:44:31 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dFhRj-0000Tl-LH for pgsql-hackers@postgresql.org; Tue, 30 May 2017 13:44:30 +0000 Received: by mail-wm0-x234.google.com with SMTP id d127so98283762wmf.0 for ; Tue, 30 May 2017 06:44:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=DZ/igpp3EYatHn8AGqT6sY0VgQCP0hPPNH3UUexRHC0=; b=nZKXSFvFpLNt3zTDeT19BuFev2e7/eFU6pt94W7MjnnxzVyj2nZ4j0cx20fCFWRnWc PDZzvxPuNx/C1DInST0ZlmMyumSy2nKDaYhiZxh9bsvyvWf7KDFR8lDizsF9WX/nnPBr 9jLrn53ePZ3Qf/ObPCZvkh6pF1XdverBrPzHbXYDMNtIR4nuVgtoHSpwZ9RibBlbzNZX JA8yr3Tk8rsSzIh5N3JJl+VbdLlkQUgxyWSuVMkk3RvaE1YTPMhdAo0ErY/zMGX9cLfS CMURxZR/vBmke08BDKFippDWMnSVNL5K235rDXDW3LMJSCsBToYLTz+Fbvn98TXpC50u gMBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=DZ/igpp3EYatHn8AGqT6sY0VgQCP0hPPNH3UUexRHC0=; b=bcf2H+uMNbMDvZRDrEo8/msLKVJ9eRL829tlzGWfEfpSGR/tyoL4HZ+Q6z/cD118A2 LBM9EM60blVYrxq4382uhmkmG8zeF7W2ebYD7CDjP/YRm0Ax+UJ4Hs/FDo/oe2vYpQsY 4vHBMs6QQQmJDSIHisVqL0tCAUYcArAxS/BIWuanfUU8O9CtooOMqM63BBd0vVjxznqU VzWw6n3d4MvDk/ApOrz4yJEJ7egY0wJnVqVVOmBwemwT1WXfqgchU5phUFgrgqwdRsnm qincWEGwwOfY89q3zSZ3QhobnbNhUfTwL3J0wnAFSG5HM4AuCDIWq7VqEjN2rh4VUHf5 zg0w== X-Gm-Message-State: AODbwcDOxqvkTAdtMcVBEn0jgWrLyCvVrQZNsUQysFuy4WpPJ6TSirSi 9o9rzkRMAtZySUPi47gTVw== X-Received: by 10.28.175.84 with SMTP id y81mr2004300wme.25.1496151866579; Tue, 30 May 2017 06:44:26 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id l30sm8624577wre.25.2017.05.30.06.44.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 06:44:25 -0700 (PDT) Subject: Re: Walsender timeouts and large transactions To: Kyotaro HORIGUCHI References: <20170530.180219.188282269.horiguchi.kyotaro@lab.ntt.co.jp> Cc: pgsql-hackers@postgresql.org, andres@anarazel.de From: Petr Jelinek Message-ID: <97e5e70a-87d2-dee1-0482-7e3609822095@2ndquadrant.com> Date: Tue, 30 May 2017 15:44:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170530.180219.188282269.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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 On 30/05/17 11:02, Kyotaro HORIGUCHI wrote: > At Thu, 25 May 2017 17:52:50 +0200, Petr Jelinek wrote in >> 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? > > + TimestampTz now = GetCurrentTimestamp(); > > I think it is not recommended to read the current time too > frequently, especially within a loop that hates slowness. (I > suppose that a loop that can fill up a send queue falls into that Yeah that was my main worry for the patch as well, although given that the loop does tuple processing it might not be very noticeable. > category.) If you don't mind a certain amount of additional > complexity for eliminating the possible slowdown by the check, > timeout would be usable. Attached patch does almost the same > thing with your patch but without busy time check. > > What do you think about this? > I think we could do it that way. > # I saw that SIGQUIT doens't work for active publisher, which I > # think mention in another thread. Ah missed that email I guess, but that's the missing CHECK_INTERRUPTS(); in the fast-path which btw your updated patch is missing as well. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers