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

Breaking change with conninfo_hash with 1.4.4 #490

Closed
ankane opened this issue Nov 9, 2022 · 3 comments
Closed

Breaking change with conninfo_hash with 1.4.4 #490

ankane opened this issue Nov 9, 2022 · 3 comments

Comments

@ankane
Copy link

ankane commented Nov 9, 2022

Hi, it looks there was recently a breaking change with the results of the conninfo_hash method (likely related to #485).

require "pg"

p PG.connect("postgres://localhost/postgres").conninfo_hash.slice(:host, :port, :hostaddr)

1.4.4

{:host=>"localhost,localhost", :port=>"5432,5432", :hostaddr=>"::1,127.0.0.1"}

1.4.3

{:host=>"localhost", :port=>"5432", :hostaddr=>"::1"}

Ref: open-telemetry/opentelemetry-ruby-contrib#142 and ankane/pgsync#169

@cbandy
Copy link
Contributor

cbandy commented Nov 10, 2022

I believe the OpenTelemetry code you linked is using the wrong methods to interrogate the active connection. The conninfo and conninfo_hash methods return information about the connection string (possible connections), while the host, hostaddr, port, etc methods return the [one] current/active connection details.

@larskanis
Copy link
Collaborator

I agree with @cbandy - the right fix in both cases is to use PG::Connection#host and port instead of dedup the conninfo_hash.

It might be unexpected, to get a different conninfo_hash than arguments given to PG.connect, but we always have been adding some particular items to it by the pg.gem. New is that we resolve the host to multiple IP addresses as described in #485.

@ankane
Copy link
Author

ankane commented Nov 11, 2022

Thanks for the responses - will consider going that direction.

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

3 participants