Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJRP7-0007hx-Fh for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2017 21:57:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eJRP6-0003gE-PP for pgsql-bugs@arkaria.postgresql.org; Mon, 27 Nov 2017 21:57:28 +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 1eJRP6-0003g1-CV for pgsql-bugs@lists.postgresql.org; Mon, 27 Nov 2017 21:57:28 +0000 Received: from synchrony.wurm.cx ([192.155.92.72]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eJRP1-0006xm-7m for pgsql-bugs@lists.postgresql.org; Mon, 27 Nov 2017 21:57:27 +0000 Received: from localhost (localhost [127.0.0.1]) by synchrony.wurm.cx (Postfix) with ESMTP id 6858D5406B for ; Mon, 27 Nov 2017 15:49:54 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=skarsol.com; s=synchrony; t=1511819394; bh=/b+1HN9Sg9wmWnVgruOyqh4fdWXMVtE2UP5WX/Euw+g=; h=Date:From:To:Subject:In-Reply-To:References; b=pm1YPyxolEJHUIxGsAtt9U4Vcq5Xeo9bICBCBYJ7VC+Gs2KOPtorIiuE00497xckU Vc8tjmvxE2IIxIBu1Lodeo/4EcXbsLCOf9IV09sxYDgF10dSOMj1eeIPgE6VjXtTj/ dhkdUxoR87l/9SfRrnIQlKiiH2E8PHCHf5ydSfCZ5VWJ5macKRJ4BuuNggElwLj/LD jDnZUOVU+XTCeCHFg79fxYiTQjEJqlfM4TZ1kAuIzzAn6J5Aiu9rq5TfeBYqm+EiUb uZxhcIy0jQgDN/74Itz5CI7/k1npSdVo0060UvYWGchZWZyz15wMwspxkgDwc6QOeM MJb5UiuCshS8g== X-Virus-Scanned: amavisd-new at wurm.cx Received: from synchrony.wurm.cx ([127.0.0.1]) by localhost (synchrony.wurm.cx [127.0.0.1]) (amavisd-new, port 10024) with LMTP id rcMuDTr5c14Q for ; Mon, 27 Nov 2017 15:49:53 -0600 (CST) Received: from synchrony.wurm.cx (localhost [127.0.0.1]) by synchrony.wurm.cx (Postfix) with ESMTPA id D77835401E for ; Mon, 27 Nov 2017 15:49:53 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=skarsol.com; s=synchrony; t=1511819393; bh=/b+1HN9Sg9wmWnVgruOyqh4fdWXMVtE2UP5WX/Euw+g=; h=Date:From:To:Subject:In-Reply-To:References; b=p6aga5nuLHkOVkbJedMVLzBeuR6ArX+0sI6EJIqFjchd5S15XgGEnkX1tZyYUG+Yx LryV8U26S5Ep9IkH6Dnavz2eolCk5OIgSVAqyy0Y50qzLTKmbF6iNrFnTUvTJ5oeFg wc9OVw1Or7AkTcdWSJcGmrQAI0eVz5L/9jQRuS3NGcExMswg4T5WTqIGJA6s45Q7xY ZWAYYkoAR1kT0g/n7U3kA2vIFVM3lzVHkN3UwiPbzUCqG+Qvywcf1Zxkw1SU9oi7tq YrZzSg5EzIvgSXAf5RNhGIKIX/8hZUl1/mYc7oiIDo8eO1Xa2uZDCFF2TWnQDaTqAw vnjFgqeT92jjw== MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 27 Nov 2017 15:49:53 -0600 From: Skarsol To: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query. In-Reply-To: <7a22f496-92b5-d199-984e-183965918304@blackducksoftware.com> References: <20171127185700.1470.20362@wrigleys.postgresql.org> <7a22f496-92b5-d199-984e-183965918304@blackducksoftware.com> Message-ID: X-Sender: postgresql@skarsol.com User-Agent: Roundcube Webmail/0.9.5 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk As a workaround for this issue we've dropped the pgbouncer connection lifetime to 60 seconds and that seems to have alleviated this for the most part. No response from pgbouncer about this (either to the recently created issue or the mailing list message last year when I initially reported this). Based on the comments in the past discussions on the postgres cancel protocol it seems that this is not viewed as a big issue because there's no real reports of it causing problems. Are other people just not using pgbouncer in transaction mode with the default settings (or not having two instances of pgbouncer between client and server)? Or typically don't send many cancel requests? Or is there just something silly I'm missing? In one of our medium databases we see 5-15 cancel requests per day and with pgbouncer on the hard coded default setting (3600 second connection lifetime) we would get around 1 or 2 relevant erroneous cancels (one that causes an insert to fail, typically failing a larger transaction) per week. This was up from about 1 a month using the config default of 1800 seconds that we lived with for a long time. Is there something better we should be using other than pgbouncer for connection pooling? On 2017-11-08 22:55, Skarsol wrote: The following bug has been logged on the website: Bug reference: 14891 Logged by: Skarsol Email address: postgresql(at)skarsol(dot)com PostgreSQL version: 9.6.3 Operating system: Linux 4.4.8-hardened-r1 #4 SMP Mon Jun 12 Description: This might be a symptom of the issue discussed in the ToDo "Changes to make cancellations more reliable and more secure" but as it is related to the pgbouncer bug I've opened at https://github.com/pgbouncer/pgbouncer/issues/245 I figured I'd post it over here just to make sure. As the last step of this bug, pgbouncer 1.7.2 presents a cancel request to postgres 9.6.3. This request targets pid 29330 which is connected to pgbouncer on port 33024. That pid then accepts a new query, returns a result set, accepts another new query, and then cancels that one out. Expected behavior would have been for either no cancel (as that pid was between queries at the time) or to cancel the first query. Cancelling the 2nd query is just weird (to me). I have no idea how much of this is related to whatever pgbouncer is doing to delay the cancel in the first place before presenting it to postgres. I'm aware that we're 2 minor versions behind, but I don't see anything that seems relevant to this in the changelogs. Image of the relevant wireshark display at https://user-images.githubusercontent.com/1915152/32578433-d5d4a71c-c4a2-11e7-9d25-f59d5afbb06b.jpg