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

Skip to content

Lack of coordination in database creation in 26.3.0 causes deployment failures #41048

@mvk37

Description

@mvk37

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

core

Describe the bug

During deployment, we starting multiple Keycloak pods simultaneously. Before version 26.3.0, the process was stable:

  • One pod was designated as the coordinator and performed database initialization
  • Other pods waited for the database to be created before proceeding

In Keycloak 26.3.0, there is no attempt to coordinate database initialization. Initialization begin when Infinispanis not even started. As a result, one pod is doing database initialization, while all other pods fail with the following error:

2025-07-09 23:40:35,460 INFO  [org.keycloak.quarkus.runtime.storage.database.liquibase.QuarkusJpaUpdaterProvider] (main) Updating database. Using changelog META-INF/jpa-changelog-master.xml
2025-07-09 23:40:35,797 WARN  [org.mariadb.jdbc.message.server.ErrorPacket] (main) Error: 1068-42000: Multiple primary key defined
2025-07-09 23:40:35,800 INFO  [com.arjuna.ats.jbossatx] (main) ARJUNA032014: Stopping transaction recovery manager
2025-07-09 23:40:35,879 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
2025-07-09 23:40:35,879 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to update database
2025-07-09 23:40:35,879 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: (conn=39) Multiple primary key defined [Failed SQL: (1068) ALTER TABLE db4keycloak.DATABASECHANGELOG ADD PRIMARY KEY (ID, AUTHOR, FILENAME)]

I reproduced it on starting 2 Keycloak dockers in parallel. Example is in attached file. (if you use 26.2.5 dockers it won't be this error)

I know that pods could start sequentially. But performance impact is significant. And for projects which are using not cluster deployments it is even bigger problem to coordinate instances start order.

Could you address it in next patch, if possible, please?

Version

26.3.0

Regression

  • The issue is a regression

Expected behavior

Several Keycloaks instances can be deployed simultaniously, as it was before 26.3.0

Actual behavior

See description.

How to Reproduce?

Start two 26.3.0 Keycloak dockers in parallel in production mode. See attached file 26.3.0 deployment failure.txt

Anything else?

26.3.0 deployment failure.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions