Re: Make query cancellation keys longer
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: Jelte Fennema-Nio <postgres@jeltef.nl>,
pgsql-hackers <pgsql-hackers@postgresql.org>, Thomas Munro <thomas.munro@gmail.com>
Date: 2024-08-16T12:31:27Z
Lists: pgsql-hackers
On Thu, Aug 15, 2024 at 6:07 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: > Ok, I've read through that thread now, and opined there too. One > difference is with libpq option name: My patch adds "protocol_version", > while Jelte proposes "max_protocol_version". I don't have strong > opinions on that. I hope the ecosystem catches up to support > NegotiateProtocolVersion quickly, so that only few people will need to > set this option. In particular, I hope that there will never be need to > use "max_protocol_version=3.2", because by the time we introduce version > 3.3, all the connection poolers that support 3.2 will also implement > NegotiateProtocolVersion. In Jelte's design, there end up being two connection parameters. We tell the server we want max_protocol_version, but we accept that it might give us something older. If, however, it tries to degrade us to something lower than min_protocol_version, we bail out. I see you've gone for a simpler design: you ask the server for protocol_version and you get that or you die. To be honest, right up until exactly now, I was assuming we wanted a two-parameter system like that, just because being able to tolerate a range of protocol versions seems useful. However, maybe we don't need it. Alternatively, we could do this for now, and then later we could adjust the parameter so that you can say protocol_version=3.2-3.7 and the client will ask for 3.7 but tolerate anything >= 3.2. Hmm, I kind of like that idea. I think it's likely that the ecosystem will catch up with NegotiateProtocolVersion once things start breaking. However, I feel pretty confident that there are going to be glitches. Clients are going to want to force newer protocol versions to make sure they get new features, or to make sure that security features that they want to have (like this one) are enabled. Some users are going to be running old poolers that can't handle 3.2, or there will be weirder things where the pooler says it supports it but it doesn't actually work properly in all cases. There are also non-PG servers that reimplement the PG wire protocol. I can't really enumerate all the things that go wrong, but I think there are a number of wire protocol changes that various people have been wanting for a long while now, and when we start to get the infrastructure in place to make that practical, people are going to take advantage of it. So I think we can expect a number of protocol enhancements and changes -- Peter's transparent column encryption stuff is another example -- and there will be mistakes by us and mistakes by others along the way. Allowing users to specify what protocol version they want is probably an important part of coping with that. The documentation in the patch you attached still seems to think there's an explicit length field for the cancel key. Also, I think it would be good to split this into two patches, one to bump the protocol version and a second to change the cancel key stuff. It would facilitate review, and I also think that bumping the protocol version is a big enough deal that it should have its own entry in the commit log. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Add timingsafe_bcmp(), for constant-time memory comparison
- b282280e9b69 14.23 landed
- 9dcfcb92fff8 15.18 landed
- 1604939b2210 16.14 landed
- 8e34acfda115 17.10 landed
- 09be39112654 18.0 landed
-
Add missing declarations to pg_config.h.in
- b82e7eddb023 18.0 landed
-
docs: Add a new section and a table listing protocol versions
- b05751220b0c 18.0 landed
-
Make cancel request keys longer
- a460251f0a1a 18.0 landed
-
libpq: Add min/max_protocol_version connection options
- 285613c60a7a 18.0 landed
-
libpq: Handle NegotiateProtocolVersion message differently
- 5070349102af 18.0 landed
-
docs: Update phrase on message lengths in the protocol
- 85d799ba8a7f 18.0 landed
-
libpq: Trace all NegotiateProtocolVersion fields
- e87c14b19ed4 18.0 landed
-
libpq: Add PQfullProtocolVersion to exports.txt
- c9d94ea2158b 18.0 landed
-
Move cancel key generation to after forking the backend
- 9d9b9d46f3c5 18.0 landed