Uploaded image for project: 'Red Hat build of Keycloak'
  1. Red Hat build of Keycloak
  2. RHBK-2455

Upgrade 24 to 25 fails because db jpa changes drop nonexisting indexes. [GHI#34899]

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Before reporting an issue

      [X] 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

      When upgrading from keycloak 24 to keycloak 25 the migration fails because the jpa upgrade script has DROP INDEX instructions from columns who do not exist on PRODUCTION environment only.
      THis because keycloak doesn't create indexes if nr of records above a limit. Therefore OTA succeeded.

      Its not the first time our upgrade failed and we had to generate sql scripts via other upgrade method...

      It whould be handy to check if indexes exist in the jpa instructions, to avoid migration failure.

      Version

      24.0.2

      Regression

      [ ] The issue is a regression

      Expected behavior

      Migration doesn't fail if indexes that are dropped in jpa do NOT exist.

      Actual behavior

      Failure on drop instructions:

      ERROR: Can't DROP 'IDX_OFFLINE_USS_CREATEDON'; check that column/key exists [Failed SQL: (1091) DROP INDEX IDX_OFFLINE_USS_CREATEDON ON keycloak_prod.OFFLINE_USER_SESSION]

      the following columns do only exist on our ota environment and NOT on production, since production has records above the limit that keycloak creates indexes:

      <dropIndex tableName="OFFLINE_USER_SESSION" indexName="IDX_OFFLINE_USS_CREATEDON" />

          <dropIndex tableName="OFFLINE_USER_SESSION" indexName="IDX_OFFLINE_USS_PRELOAD" />
          <dropIndex tableName="OFFLINE_USER_SESSION" indexName="IDX_OFFLINE_USS_BY_USERSESS" />
          <dropIndex tableName="OFFLINE_CLIENT_SESSION" indexName="IDX_OFFLINE_CSS_PRELOAD" />
          
          
          
      

      How to Reproduce?

      remove above indexes and upgrade from keycloak 24 to 25..

      (othere upgrade versions had this issue before, so therefore report it now).

      Anything else?

      No response

              Unassigned Unassigned
              pvlha Pavel Vlha
              Keycloak Core IAM
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: