Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stop using H2 DB in prod environment #14811

@deathwaiting

Description

@deathwaiting

Description

H2 should never run on production!

Discussion

No response

Motivation

I met a very strange behavior while running keycloak image on GCP.
I was trying to connect KC to a managed postgres instance on google cloud SQL, which required setting the DB configurations using env variables.

The problem is, I missed setting KC_DB to postgres, this is not an issue by itself, as I expect KC to just fail at startup, instead, it just worked normally and used H2 to run !!!!

I believe this is really a confusing behavior, specially in a production environment where H2 should never run!
This can be disastrous if it happened undetected on production environment, because all the registered users will be wiped out when the instance is stopped.

This also costed me a lot of wasted time on debugging, and even was confusing when running a local dev environment on postgres, as I assumed KC was configured correctly while in fact it was running its own DB.

Details

Please stop H2 on production profile and it will be nice to show in the logs some info about the current DB to avoid such confusions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementCategorizes a PR related to an enhancement

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions