Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pooler Error: Unsupported startup parameter: extra_float_digits #475

Open
tsachih opened this issue Jul 20, 2016 · 12 comments
Open

Pooler Error: Unsupported startup parameter: extra_float_digits #475

tsachih opened this issue Jul 20, 2016 · 12 comments

Comments

@tsachih
Copy link

tsachih commented Jul 20, 2016

When using the pq library along with pgbouncer, the following error is generated:
Pooler Error: Unsupported startup parameter: extra_float_digits

As a workaround, one could follow the instructions in Athou/commafeed#559

However, better control over the sent configuration would be a better approach.

i.e. existing library is hard-coding the following :
o.Set("extra_float_digits", "2")

which is the suspected cause for the issue.

@ajvb
Copy link

ajvb commented Jul 20, 2016

@tsachih I believe this can be solved by implementing a custom dialer: #470 (comment)

@tsachih
Copy link
Author

tsachih commented Jul 21, 2016

Yes, implementing a custom dialer would provide a possible solution for this issue.However, note that the problem is more parameters setting related rather then dialing related.
If we could have had a pre-dial custom filter that would have the ability to update the connection options map, it would be even better. ( which doesn't conflict with having a custom dialer )
Tsachi
Date: Wed, 20 Jul 2016 14:53:12 -0700
From: notifications@github.com
To: pq@noreply.github.com
CC: tsachih@hotmail.com; mention@noreply.github.com
Subject: Re: [lib/pq] Pooler Error: Unsupported startup parameter: extra_float_digits (#475)

@tsachih I believe this can be solved by implementing a custom dialer: #470 (comment)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@jchamberlain
Copy link

Just ran into this myself. Is there a reason extra_float_digits needs to be hardcoded into the driver? I see that parseOpts() lets me set options in the DSN, so I can easily override the value, e.g.,

sql.Open("host=hostname port=5432 sslmode=disable extra_float_digits=3")

Problem is, even though I can set it back to its default value, I can't remove it entirely. What in the driver requires it?

@johto
Copy link
Contributor

johto commented Jul 21, 2016

Problem is, even though I can set it back to its default value, I can't remove it entirely. What in the driver requires it?

Getting out correct values for floats from the database.

You'll see that other drivers (such as the JDBC one) send the same setting over, so it's not like pq is doing anything out of the ordinary here. I don't think this is really worth changing.

@jchamberlain
Copy link

I see this has been discussed before (#205) so I won't belabor the point. I'm just surprised the driver needs to hard code this when it's trivial to configure in at least two other places, the DSN and postgresl.conf.

Also, I'm guessing what pgJDBC is doing isn't entirely usual as I don't have this problem in PHP and I can't find a reference to extra_float_digits in the Python driver either.

But I'll go ahead and use ignore_startup_parameters.

@tsachih
Copy link
Author

tsachih commented Jul 22, 2016

Is the DSN string is a known standard ? i.e. can we set it with some custom instrumentation values so that the dialer doesn't add that string ?
few ideas :
sql.Open("host=hostname port=5432 sslmode=disable -extra_float_digits")
sql.Open("host=hostname port=5432 sslmode=disable no_extra_float_digits=true")
sql.Open("host=hostname port=5432 sslmode=disable pgexclude=extra_float_digits")

The last one is the most versatile.

Note that for my application, I cannot use ignore_startup_parameters since that particular pgbouncer is used by other clients. I don't want to modify the behavior of these clients.

Note that the default value for extra_float_digits is zero. (https://www.postgresql.org/docs/9.0/static/datatype-numeric.html#DATATYPE-FLOAT)

@tsachih
Copy link
Author

tsachih commented Jul 26, 2016

Another option which I didn't include above is to pass
sql.Open("host=hostname port=5432 sslmode=disable extra_float_digits=-1")

Since the extra_float_digits is a positive integer number, we can use this value to indicate that we want to use the default value.

@miladz68
Copy link

miladz68 commented Dec 3, 2017

@tsachih
I think your suggestions are sound.
I tried to implement a custom dialer but got lost in the complexity of all the different things that I needed to implement again. So I simply removed o["extra_float_digits"] = "2" from the source code and it worked like a charm.

@igorwwwwwwwwwwwwwwwwwwww
Copy link
Contributor

Just ran into this problem as well. +1 for making this behaviour optional.

@archfish
Copy link

archfish commented Jan 9, 2019

from https://github.com/pgbouncer/pgbouncer/blob/master/NEWS.rst
2008-07-29 - PgBouncer 1.2 - "Ordinary Magic Flute"

New config var 'ignore_startup_parameters' to allow and ignore extra parameters in startup packet. By default only 'database' and 'user' are allowed, all others raise error. This is needed to tolerate overenthusiastic JDBC wanting to unconditionally set 'extra_float_digits=2' in startup packet.

just enable ignore_startup_parameters = extra_float_digits in pgbouncer config.

;
; Comma-separated list of parameters to ignore when given
; in startup packet.  Newer JDBC versions require the
; extra_float_digits here.
;
ignore_startup_parameters = extra_float_digits

lawrencejones added a commit to gocardless/stolon-pgbouncer that referenced this issue Apr 16, 2019
[^1]: lib/pq#475

lib/pq sends extra_float_digits as a startup parameter [^1] whenever
initialising a Postgres connection. PgBouncer doesn't recognise this
parameter and will fail whenever you send it.

To prevent this, we ensured pgsql-cluster-manager would ban PgBouncer
configuration that didn't explicitly ignore this parameter. This is
likely irrelevant after we moved to pgx though, so we should remove this
constraint.
swhmirror pushed a commit to SoftwareHeritage/puppet-swh-site that referenced this issue Jan 16, 2020
This is a workaround for lib/pq#475 which happens when
using the PostgreSQL JDBC connector.
@pateljoel
Copy link

I'm using a managed postgres service that doesn't allow me to edit the pgbouncer config.

I have found that @miladz68 solution works and takes only < 2 mins to fix and I see no reason why this line was included in the first place.

Please make this optional.

@NKame
Copy link

NKame commented Nov 7, 2024

8 years later: no, changing the server configuration you have no authority over is not the right place to "fix" a client decision to disregard the server's choice. https://www.postgresql.org/docs/8.4/datatype-numeric.html#DATATYPE-FLOAT extra_float_digits has been formally introduced in 8.4 to increase the precision sent from the server to the client ; since 11, it's here to decrease that precision. In no way a client should have a hard coded confing trying to guess the application need regarding a lossy datatype, especially when it creates a bug with the widespread PgBouncer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants