-
-
Notifications
You must be signed in to change notification settings - Fork 1k
-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Connection error - Database does not exists after patching to a newer version #2970
Comments
Likely caused by:
@jeanpierre92 Are there special characters in |
@steve-chavez Yes, in the password there are chars like: "=)[&", the host does not have special chars. |
I tested this and the solution should be to change those special characters to percent-encoded characters, e.g. I can confirm that percent-encoding was not needed in In |
Just to clarify. To add the postgrest/src/PostgREST/Config.hs Lines 499 to 505 in a6e3eda
This needs to be fixed somehow, because if previous versions did connect then it was indeed a valid URI. We should aim to behave exactly like Something that's weird is that some special non-urlencoded characters do cause an error when connecting, see: Seems the connection only fails on a non-urlencoded |
I can confirm that with v11.2.0 and the percent-encoding password it is fixed and it gives no longer errors. But, just for information, the percent-encoding did not work with v11.0.1 (like you said, its probably send as a string) |
To solve this issue, I think we can just identify that the connstring is in URI format by detecting the URI scheme designator:
Also note:
Says "generally follow". While our There's a lib for parsing the pg connstring: https://hackage.haskell.org/package/postgresql-simple-opts. Maybe we can use that one. It already covers the key/value format too. Edit: the library has errors jfischoff/postgres-options#8 The libpq logic for checking if it's a URI it's quite simple: |
Environment
Description of issue
From PostgREST version 11.0.1 the api can connect to the database via the config:
PGRST_SERVER_PORT=2888
PGRST_DB_URI=postgres://forecasting:<PW_HERE>@<HOST_HERE>:5432/forecasting
PGRST_DB_SCHEMA=api
PGRST_DB_ANON_ROLE=forecasting
But after patching to the next version I see errors:
26/Sep/2023:13:14:51 +0200: {"code":"PGRST000","details":"connection to server at "<HOST_HERE>" (10.8.106.143), port 5432 failed: FATAL: database "forecasting fallback_application_name='PostgREST 11.2.0'" does not exist\n","hint":null,"message":"Database connection error. Retrying the connection."}
I see the same errors in the logging in the postgresql database logging. The config has not changed between versions.
The text was updated successfully, but these errors were encountered: