Postgres connection string not printed if connection fails because database does not exist
See original GitHub issueEnvironment
Liquibase Version: 3.5.5
Database Vendor & Version: Postgres:latest (12.4)
Operating System Type & Version: Linux Pop_OS 20.04, Docker 19.03
Description
Attempting to Debug a connection can be difficult as the connection string is only printed if the database exists.
Steps To Reproduce
The following docker-compose file (using keycloak as it is where I encountered the issue) should produce the unsuccessful connection. Piping the logs to a file, lines 223-224 should be the lines posted in the description section (assuming fresh data volumes). Setting DB_DATABASE: public
should give the “connected to” example, while DB_DATABASE: keycloak
(or anything else) will produce the “database does not exist” example.
version: "3"
services:
postgres:
image: "postgres"
ports:
- "5433:5432"
environment:
POSTGRES_DB: public
POSTGRES_USER: admin
POSTGRES_PASSWORD: password
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- "postgres_data:/var/lib/postgresql/data/pgdata"
postgres_wait:
image: dadarek/wait-for-dependencies
depends_on:
- postgres
command: postgres:5432
keycloak:
image: "quay.io/repository/keycloak/keycloak"
depends_on:
- postgres_wait
ports:
- "8080:8080"
environment:
KEYCLOAK_LOGLEVEL: ALL
DB_VENDOR: POSTGRES
DB_USER: admin
DB_PASSWORD: password
DB_DATABASE: keycloak
DB_SCHEMA: public
DB_ADDR: postgres
volumes:
- "keycloak_data:/keycloak"
volumes:
postgres_data:
driver: local
keycloak_data:
driver: local
Actual Behavior
No Connection string is printed. The following lines are printed instead.
keycloak_1 08:28:36,617 DEBUG [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool – 63) Added package org.keycloak.connections.jpa.updater.liquibase.lock to liquibase
postgres_1 2020-08-22 08:28:36.859 UTC [74] FATAL: database "keycloak" does not exist
Expected/Desired Behavior
Even if the database does not exist, the connection string is printed like in the following log lines, after which point the database does not exist error would then happen.
keycloak_1 07:14:31,038 DEBUG [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool – 67) Added package org.keycloak.connections.jpa.updater.liquibase.lock to liquibase
keycloak_1 07:14:31,337 TRACE [org.keycloak.connections.jpa.updater.liquibase.conn.DefaultLiquibaseConnectionProvider] (ServerService Thread Pool – 67) Connected to admin@jdbc:postgresql://postgres:5432/public?schema=keycloak
Additional Context
First Line of logs (keycloak) is located in keycloak here and the connection string is logged (via liquibase) here.
Originally reported to keycloak here but closed as successful connection string is printed by liquibase. I have grabbed the environment data to the best of my ability given i’m working with keycloak, not on keycloak.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Hi @karuppiah7890 I would say go for it.
Thanks @karuppiah7890 for the detailed description and where the bug happens to be. Going to close this as needing to be fixed in keycloak code. Really appreciate the thorough details on the issue.