Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dfQzA-0005bT-2S for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2017 13:25:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dfQz9-0007r2-Ee for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2017 13:25:19 +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 1dfQxc-00056n-B9 for pgsql-hackers@postgresql.org; Wed, 09 Aug 2017 13:23:44 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dfQxZ-0004oY-Fb for pgsql-hackers@postgresql.org; Wed, 09 Aug 2017 13:23:43 +0000 Received: by mail-wm0-x22d.google.com with SMTP id t201so31882917wmt.1 for ; Wed, 09 Aug 2017 06:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=qlKxXzUNsryaPw2vlJABt8PHbx7rMsGXtROdcjulxSo=; b=EnHUqiNcgSPPgORBivLAsqT/eegjAYV97kzS7M1jfhQcShiTP6BNR5Ms6fWoGAl6Cg kvu+lwoLrPcGf8/K0LG2w9R1V/l+z6TFZTuKjIqbDATGVb7I/oR9ew5AI/L0ivFB5fOE fx6Or/YKVWWPcGKgtaZb2dbA7Lk2J5jOgSM5wMTNeVZ3hVCwOuQu4WUvdUnuqMnmSzS0 5OunVR2VLlElD6HL/MQn6ZyjKDm1MdyCqxK6TL38L6jdHPzMvDSf07BiQhnqwtjx/tEZ vuYdl09/X/oH9bz2e4lqdVwQ7W8MT6xmHnm9JAxwl28Usjt2KtdMsDqG7BOnh5cq0ufy W0xA== 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:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qlKxXzUNsryaPw2vlJABt8PHbx7rMsGXtROdcjulxSo=; b=e7x28dMPL7OK6iIZMCgJUM81SAmMu1jq8e7Fh8yzoqV7BGxnm7IxmF//xfnfwQNFxD AGe8MQx5NmyRifqvOhXNyJCMAX+rjU8gBa1GzEF6lG79JIf4vroH0NydQ+Mkufq6TniW VfR0aDRQ8gocoS/JB9hKSWjz+ayMqf5URK41Vh0NJmhg6OR4gu+98NugfRE1mQfXPvmv VpibsYqFFchvgI1mY0r78x1qGnUZLKcawlQ3FKcrmpVv+zXrx7uSozVwhzhuejIl3uyD BvzacijeA8c8zoWZjCcr45Red8orRC6t4XAuZrH4HP0SsK9X7i+qFaX9P13u8VxdPP20 LKyA== X-Gm-Message-State: AHYfb5i+b2I+UV1jEv8ISKAu61LAIi1cTSJ+BWhHthHZoO273ISWSJmZ pF7Z1mo174OVbtqMGn0z2LadXnl7iebwX73PW0HhwDB6yMQ6sUpm0Hp0wgHRwaC/bTsqlf/UXr2 eI9I5a2XT8Bm0PbLFMK+TwCIPZtFfO41E4ylnmpR/cCISZw9DO3R4nhFsXRQk+tdvkf/Oi2jCa2 rH3w== X-Received: by 10.28.184.145 with SMTP id i139mr4732111wmf.98.1502285019290; Wed, 09 Aug 2017 06:23:39 -0700 (PDT) Received: from [192.168.0.199] ([109.235.177.32]) by smtp.gmail.com with ESMTPSA id q21sm3555018wra.86.2017.08.09.06.23.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Aug 2017 06:23:38 -0700 (PDT) Subject: Re: Walsender timeouts and large transactions To: Yura Sokolov , pgsql-hackers@postgresql.org References: <20170802173558.1342.32988.pgcf@coridan.postgresql.org> From: Petr Jelinek Message-ID: <6259a2a9-e683-c3a6-2da8-249b862d8099@2ndquadrant.com> Date: Wed, 9 Aug 2017 15:23:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170802173558.1342.32988.pgcf@coridan.postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit 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 02/08/17 19:35, Yura Sokolov wrote: > The following review has been posted through the commitfest application: > make installcheck-world: tested, passed > Implements feature: not tested > Spec compliant: not tested > Documentation: not tested > > There is no check for (last_reply_timestamp <= 0 || wal_sender_timeout <= 0) as in other places > (in WalSndKeepaliveIfNecessary for example). > > I don't think moving update of 'now' down to end of loop body is correct: > there are calls to ProcessConfigFile with SyncRepInitConfig, ProcessRepliesIfAny that can > last non-negligible time. It could lead to over sleeping due to larger computed sleeptime. > Though I could be mistaken. > > I'm not sure about moving `if (!pg_is_send_pending())` in a body loop after WalSndKeepaliveIfNecessary. > Is it necessary? But it looks harmless at least. > We also need to do actual timeout handing so that the timeout is not deferred to the end of the transaction (Which is why I moved `if (!pg_is_send_pending())` under WalSndCheckTimeOut() and WalSndKeepaliveIfNecessary() calls). > Could patch be reduced to check after first `if (!pg_is_sendpending())` ? like: > > if (!pq_is_send_pending()) > - return; > + { > + if (last_reply_timestamp <= 0 || wal_sender_timeout <= 0) > + { > + CHECK_FOR_INTERRUPTS(); > + return; > + } > + if (now <= TimestampTzPlusMilliseconds(last_reply_timestamp, wal_sender_timeout / 2)) > + return; > + } > > If not, what problem prevents? We should do CHECK_FOR_INTERRUPTS() independently of pq_is_send_pending so that it's possible to stop walsender while it's processing large transaction. -- 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