pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
5+ messages / 3 participants
[nested] [flat]
* BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
@ 2017-11-08 22:55 postgresql@skarsol.com
0 siblings, 0 replies; 5+ messages in thread
From: postgresql@skarsol.com @ 2017-11-08 22:55 UTC (permalink / raw)
To: pgsql-bugs; +Cc: postgresql@skarsol.com
The following bug has been logged on the website:
Bug reference: 14891
Logged by: Skarsol
Email address: postgresql@skarsol.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
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
@ 2017-11-27 21:49 Skarsol <postgresql@skarsol.com>
0 siblings, 0 replies; 5+ messages in thread
From: Skarsol @ 2017-11-27 21:49 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
@ 2017-11-29 18:01 Skarsol <postgresql@skarsol.com>
0 siblings, 1 reply; 5+ messages in thread
From: Skarsol @ 2017-11-29 18:01 UTC (permalink / raw)
To: pgsql-bugs
Well, taking pgbouncer down to a 60 second connection lifetime was
insufficient to completely alleviate this. We had another transaction
get killed yesterday due to a different query being cancelled. I'm still
unsure how this isn't affecting other people.
At this point, we're going to change our application to just abandon the
current postgres connection when a user hits cancel instead of actually
sending the cancel request. Ugly hack, but I'm not sure what else to do
at this point. I'm still open to suggestions though. Or really, any
discussion about this issue at all. Would this belong better on a
different list?
-----
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
@ 2017-12-19 16:43 Greg Stark <stark@mit.edu>
parent: Skarsol <postgresql@skarsol.com>
0 siblings, 1 reply; 5+ messages in thread
From: Greg Stark @ 2017-12-19 16:43 UTC (permalink / raw)
To: Skarsol <postgresql@skarsol.com>; +Cc: pgsql-bugs
If I understand the bug report correctly you have two layers of
pgbouncer and it's only the second layer that is introducing these
latencies? I wonder if that should help point out why these latencies
are happening but I don't have any immediate ideas.
I suppose there are two avenues for addressing this, but they're both
probably large projects, not simple bug fixes....
1) PGBouncer is the one breaking the session <-> tcp stream
correspondence. Perhaps it should learn about cancellation messages
and learn about how to determine whether that backend session is still
allocated to the same incoming session? I'm not sure how that would
happen though since the cancellation request doesn't have any
information about which session is the intended target.
2) The postgres client could include some meta information about what
request the client is intending to cancel. But that has a few gotchas
as well. Clients stream many requests and process the responses as
they arrive. Just because the client has processed up to a certain
point doesn't mean the server hasn't streamed out responses past that.
It's quite common to want to cancel precisely because a stream of
responses are coming.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query.
@ 2017-12-19 16:52 Skarsol <postgresql@skarsol.com>
parent: Greg Stark <stark@mit.edu>
0 siblings, 0 replies; 5+ messages in thread
From: Skarsol @ 2017-12-19 16:52 UTC (permalink / raw)
To: Greg Stark <stark@mit.edu>; +Cc: pgsql-bugs; gsstark@gmail.com
On 2017-12-19 10:43, Greg Stark wrote:
> If I understand the bug report correctly you have two layers of
> pgbouncer and it's only the second layer that is introducing these
> latencies? I wonder if that should help point out why these latencies
> are happening but I don't have any immediate ideas.
To clarify, we also see the issue in cases where there is only one PGB
between the client and the database.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2017-12-19 16:52 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-11-08 22:55 BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query. postgresql@skarsol.com
2017-11-27 21:49 Re: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query. Skarsol <postgresql@skarsol.com>
2017-11-29 18:01 RE: BUG #14891: Old cancel request presented by pgbouncer honored after skipping a query. Skarsol <postgresql@skarsol.com>
2017-12-19 16:43 ` Greg Stark <stark@mit.edu>
2017-12-19 16:52 ` Skarsol <postgresql@skarsol.com>
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