question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keycloak server fails to start when using different named schema

See original GitHub issue

Describe the bug

Keycloak fails to start with the following error when using a different schema than default ‘public’ when running postgres

2022-05-27 12:55:27,356 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode 2022-05-27 12:55:27,357 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.hibernate.exception.SQLGrammarException: could not extract ResultSet 2022-05-27 12:55:27,359 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: could not extract ResultSet 2022-05-27 12:55:27,359 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: relation "migration_model" does not exist Position: 121

Looks like it is searching for table migration_model in the public default schema. The tables exist on the named schema

Version

18.0.0

Expected behavior

Keycloak server to start successfully

Actual behavior

keycloak fails to start with error relation “migration_model” does not exist

How to Reproduce?

Use the following config specifying DB schema and start keycloak bat/sh

Basic settings for running in production. Change accordingly before deploying the server.

Database

The database vendor.

db=postgres

The username of the database user.

db-username=postgres

The password of the database user.

db-password=postgres

db-schema=kc

The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.

db-url=jdbc:postgresql://localhost:5432/kcnew?ssl=false

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dasnikocommented, Jun 1, 2022

FWIW: a possible workaround can be to append the query parameter currentSchema=kc to the JDBC url. This is what helped at one of my customers. Just to leave this here in case anybody else stumble over it until it is fixed in the next release.

0reactions
dasnikocommented, Jun 3, 2022

@pedroigor The currentSchema Query parameter is postgres specific (see here. Other databases may offer a similar option if they are providing a “schema”, apart from only “database”. Different DB vendors are handling this differently, afaik there’s no standard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keycloak Starting with separate DB_SCHEMA an error occured
Postgres container is loaded with initial script to create schema and keycloak tables are generated in schema specified.
Read more >
Keycloak server not able to start with the postgres DB server
Hello, i'm not able to start the keycloak with the postgres server using docker image. when i tried it with local postgres database...
Read more >
Configuring the database - Server - Keycloak
This command includes the minimum settings needed to connect to the database. The default schema is keycloak , but you can change it...
Read more >
keycloak with postgres as database crashloops because of ...
Hi, i deployed the current keycloak helm chart with postgres support, but keycloak doesn't come up because it can't connect to postgres ...
Read more >
Problems upgrading from 17.0.1 to 18.0.0 - Google Groups
Before that, it was complaining with `Schema "KEYCLOAK" not found` error message. Now I'm trying to upgrade KC 17.0.1 to KC 18, following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found