Skip to content

Upgrade to 26 fails with 'ERROR: index "idx_us_sess_id_on_cl_sess" does not exist' #33780

Closed
@koelle25

Description

@koelle25

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

The migration introduced in PR #32665 fails if the index is not existing in the first place. This in turn prohibits the startup of Keycloak.

Docker container logs:
keycloak     | 2024-10-10 13:56:35,248 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
keycloak     | 2024-10-10 13:56:35,248 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to update database
keycloak     | 2024-10-10 13:56:35,248 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException: Migration failed for changeset META-INF/jpa-changelog-26.0.0.xml::26.0.0-32583-drop-redundant-index-on-client-session::keycloak:
keycloak     |      Reason: liquibase.exception.DatabaseException: ERROR: index "idx_us_sess_id_on_cl_sess" does not exist [Failed SQL: (0) DROP INDEX public.IDX_US_SESS_ID_ON_CL_SESS]
keycloak     | 2024-10-10 13:56:35,249 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.MigrationFailedException: Migration failed for changeset META-INF/jpa-changelog-26.0.0.xml::26.0.0-32583-drop-redundant-index-on-client-session::keycloak:
keycloak     |      Reason: liquibase.exception.DatabaseException: ERROR: index "idx_us_sess_id_on_cl_sess" does not exist [Failed SQL: (0) DROP INDEX public.IDX_US_SESS_ID_ON_CL_SESS]
keycloak     | 2024-10-10 13:56:35,249 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Migration failed for changeset META-INF/jpa-changelog-26.0.0.xml::26.0.0-32583-drop-redundant-index-on-client-session::keycloak:
keycloak     |      Reason: liquibase.exception.DatabaseException: ERROR: index "idx_us_sess_id_on_cl_sess" does not exist [Failed SQL: (0) DROP INDEX public.IDX_US_SESS_ID_ON_CL_SESS]
keycloak     | 2024-10-10 13:56:35,249 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: index "idx_us_sess_id_on_cl_sess" does not exist [Failed SQL: (0) DROP INDEX public.IDX_US_SESS_ID_ON_CL_SESS]
keycloak     | 2024-10-10 13:56:35,249 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: index "idx_us_sess_id_on_cl_sess" does not exist
keycloak     | 2024-10-10 13:56:35,249 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) For more details run the same command passing the '--verbose' option. Also you can use '--help' to see the details about the usage of the particular command.
keycloak exited with code 0

Version

25.0.6 -> 26.0.0

Regression

  • The issue is a regression

Expected behavior

If the index is not there, deleting it should not fail the migration and instead treat it like succeeding.

Actual behavior

Migration fails, Keycloak doesn't start.

How to Reproduce?

  1. Have a running instance <26 where the index does not exist (for whatever reason).
  2. Try to upgrade to 26.0.0.

Anything else?

In another migration (jpa-changelog-24.0.2.xml) there is some extra XML to catch this exception, which marks the migration as completed instead.
I will create a PR which does this for jpa-changelog-26.0.0.xml, too.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions