Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs - Mailing list pgsql-hackers
From | Jelte Fennema-Nio |
---|---|
Subject | Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs |
Date | |
Msg-id | CAGECzQTvSvLxi8o11QC0VbYSpaVi_iki9PubGXSChxGmDSfhzg@mail.gmail.com Whole thread Raw |
In response to | Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs (Dave Cramer <davecramer@gmail.com>) |
Responses |
Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
|
List | pgsql-hackers |
On Fri, 5 Apr 2024 at 18:30, Dave Cramer <davecramer@gmail.com> wrote: > On Fri, 5 Apr 2024 at 12:09, Jelte Fennema-Nio <me@jeltef.nl> wrote: >> I'll take a look at redesigning the protocol parameter stuff. To work >> with dedicated functions instead. > > +1 It's been a while, but I now actually took the time to look into this. And I ran into a problem that I'd like to get some feedback on before continuing the implementation: If we're not setting the protocol parameter in the StartupMessage, there's currently no way for us to know if the protocol parameter is supported by the server. If protocol parameters were unchangable then that would be fine, but the whole point of introducing ParameterSet is to make it possible to change protocol parameters on an existing connection. Having the function SupportsProtocolCompression return false, even though you can enable compression just fine, only because we didn't ask for compression when connecting seems quite silly and confusing. I see five ways around this problem and would love some feedback on which you think is best (or if you can think of any other/better ones): 1. Have protocol parameters always be GUC_REPORT, so that the presence of a ParameterStatus message during connection startup can be used as a way of detecting support for the protocol parameter. 2. Make libpq always send each known protocol parameter in the StartupMessage to check for their support, even if the connection string does not contain the related parameters (set them to their default value then). Then the non-presence of the parameter in the NegotiateProtocolVersion message can be used reliably to determine support for the feature. We could even disallow changing a protocol parameter at the server side using ParameterSet if it was not requested in the StartupMessage. 3. Very similar to 1, but require explicit user input in the connection string to request the feature on connection startup by having the user explicitly provide its default value. If it's not requested on connection startup assume its unsupported and disallow usage of the feature (even if the server might actually support it). 4. Make SupportsProtocolCompression return a tri-state, SUPPORTED, UNSUPPORTED, UNKNOWN. If it's UNKNOWN people could send a ParameterSet message themselves to check for feature support after connection startup. We could even recognize this and change the state that SupportProtocolCompression function to return SUPPORTED/UNSUPPORTED on future calls according to the server response. 5. Basically the same as 4 but automatically send a ParameterSet message internally when calling SupportsProtocolCompression and the state is UNKNOWN, so we'd only ever return SUPPORTED or UNSUPPORTED. The above options are listed in my order of preference, below some reasoning why: 1 and 2 would increase the bandwidth used during connection handshake slightly for each protocol parameter that we would add, but they have the best user experience IMHO. I slightly prefer 1 over 2 because there is another argument to be made for always having protocol parameters be GUC_REPORT: these parameters change what message types a client can send or receive. So it makes sense to me to have the server tell the client what the current value of such a parameter is. This might not be a strong argument though, because this value would only ever change due to user interaction. But still, one might imagine scenarios where the value that the client sent is not exactly what the server would set the parameter to on receiving that value from the client. e.g. for protocol compression, maybe the client sends a list of prefered compression methods and the server would send a ParameterStatus containing only the specific compression method that it will use when sending messages to the client. 3 seems also an acceptable option to me. While having slightly worse user experience than 2, it allows the user of the client to make the decision if the extra bandwidth during connection startup is worth it to be able to enable the feature later. 4 assumes that we want people to be able to trigger sending ParameterSet messages for every protocol parameter. I'm not sure we'd want to give that ability in all cases. 5 would require SupportsProtocolCompression to also have a non-blocking version, which bloats our API more than I'd like. Also as a user you wouldn't be able to know if SupportsProtocolCompression will do a network request or not. PS. This is only a problem for feature detection for features relying on protocol parameters, feature-support relying on protocol version bumps are easy to detect based on the NegotiateProtocolVersion message.
pgsql-hackers by date: