Keycloak not starting after reboot of server. Error looks to be related to H2, "Constraint already exists"

Keycloak version 10.0.1

We have been using keycloak in a test environment for a while now with no issues. Recently some OS updates were applied to the server (Ubuntu 16.04) and a reboot was performed and since then we cannot get keycloak to start. As far as we can tell none of the OS updates should have touched anything related to keycloak.

When trying to start keycloak we get this error related to the H2 databse:

Caused by: org.h2.jdbc.JdbcSQLException: Constraint “FK_5HG65LYBEVAVKQFKI3KPONH9V” already exists; SQL statement:
ALTER TABLE PUBLIC.REALM_REQUIRED_CREDENTIAL ADD CONSTRAINT PUBLIC.FK_5HG65LYBEVAVKQFKI3KPONH9V FOREIGN KEY(REALM_ID) REFERENCES PUBLIC.REALM(ID) NOCHECK [90045-197]

I attempted to connect to the H2 database using the web UI for H2 and I get the same error. Unfortunately I know little about Keycloak but need to get this up and running again. Can anyone help with this?

1 Like

Hi,

I have the same error after the upgrade from version 4.8.3 to version 11.0.0 or 11.0.2. The application runs ok up to a possible restart when the same identical exception occurs.

Any advice is more than welcome.

Thank you

1 Like

same on after upgrading from 12.0.4 to 13.0.1 or 14.0.0