-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Connection String with multiple hosts is not being parsed as expected #2308
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
Comments
I have just raised a similar issue to pg-native library: # |
Probably will be easier to use a middleware like pgpool or pgbouncer for this. |
The functionality that is important is that if I need to failover a database, I can do so without updating connection strings because the library will automatically choose a server that is the primary. I can't see that pgbouncer or pgpool have this functionality. |
You can achieve that with a generic TCP reverse proxy, like HAProxy. First result in ddg for dynamically changing servers in haproxy: https://stackoverflow.com/a/53294153 But you get more features from postgres-aware programs, like pgpool: I've never set something like this up before, the last time I've done postgres HA, it was with virtual IPs, but that usually isn't a good option in cloud environments. |
If this option is available, then it can do switchover by itself, as |
This PR updates the docs to clarify that we don't support multi-host strings in the databaseUrl configuration variable. The docs used to just mention that we accept libpq strings, but as reported in #3221, we **don't** support multi-host strings. I did some digging and found that this is because [node-postgres -- the library we use to connect to postgres -- itself does not support multi-host strings](brianc/node-postgres#2308). To fix this, we would need to replace the library we use or otherwise wrap it. While this would be a better long-term solution, we don't have the capacity to it right now. But we can update the docs to better reflect reality.
Hi There,
According to PG docs multiple hosts can be supplied in connection string.
for example:
If I supply connectionString as
postgres://user:@localhost:6432,localhost:5432/db_name
it is being parsed as this:
above is throwing error. as the connection which gets constructed from this is wrong. This is the issue with
pg-connection-string
.Also, I am curious, why do we need to parse a connection-string, why can't we directly pass it to
libpq
?Will you accept a PR for this?
The text was updated successfully, but these errors were encountered: