Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-9836

Nifi registry db migration fails if database is postgresql

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.16.0
    • 1.17.0, 1.16.1
    • None
    • None

    Description

      There was an H2 upgrade - https://github.com/apache/nifi/commit/bcc8d03314889e7d2d0724390059d0315efe2a34
      In this pr the following if is refactored: https://github.com/apache/nifi/blob/main/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/CustomFlywayConfiguration.java#L64

      However the

      databaseType.equals(new PostgreSQLDatabaseType())
      

      will not work, because flyway DatabaseType classes doesn’t implement a proper equals method: https://github.com/flyway/flyway/blob/master/flyway-core/src/main/java/org/flywaydb/core/internal/database/postgresql/PostgreSQLDatabaseType.java#L36

      Because of this if the user not use the default database, then not the proper migration locations will be used.

      2022-03-26 12:28:14,593 INFO org.apache.nifi.registry.db.CustomFlywayConfiguration: Determined database type is PostgreSQL
      2022-03-26 12:28:14,593 INFO org.apache.nifi.registry.db.CustomFlywayConfiguration: Setting migration locations to [classpath:db/migration/common, classpath:db/migration/default]
      2022-03-26 12:28:14,616 INFO org.apache.nifi.registry.db.CustomFlywayConfiguration: Using default Flyway configuration table
      ..
      ..
      led; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V6__AddFlowPersistence.sql failed
      -------------------------------------------
      SQL State  : 42704
      Error Code : 0
      Message    : ERROR: type "blob" does not exist
        Position: 951
      Location   : db/migration/default/V6__AddFlowPersistence.sql
      Line       : 16
      Statement  : -- Licensed to the Apache Software Foundation (ASF) under one or more
      -- contributor license agreements.  See the NOTICE file distributed with
      -- this work for additional information regarding copyright ownership.
      -- The ASF licenses this file to You under the Apache License, Version 2.0
      -- (the "License"); you may not use this file except in compliance with
      -- the License.  You may obtain a copy of the License at
      --
      --     http://www.apache.org/licenses/LICENSE-2.0
      --
      -- Unless required by applicable law or agreed to in writing, software
      -- distributed under the License is distributed on an "AS IS" BASIS,
      -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      -- See the License for the specific language governing permissions and
      -- limitations under the License.
      
      CREATE TABLE FLOW_PERSISTENCE_PROVIDER (
          BUCKET_ID VARCHAR(50) NOT NULL,
          FLOW_ID VARCHAR(50) NOT NULL,
          VERSION INT NOT NULL,
          FLOW_CONTENT BLOB NOT NULL,
          CONSTRAINT PK__FLOW_PERSISTENCE_PROVIDER PRIMARY KEY (BUCKET_ID, FLOW_ID, VERSION)
      )
      ..
      ..
      

      Attachments

        Issue Links

          Activity

            People

              taz1988 Zoltán Kornél Török
              taz1988 Zoltán Kornél Török
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m