During IoT FND upgrade to 4:10, DB migration fails due to incorrect incremental size. The database schema and IoT FND should
match in order to avoid the failure during DB migrate, and hence the hibernate jars were upgraded in Cisco IoT FND 4.10.0.
The following error message appears when the sequence name (for example, audit_trail_id_seq) in the db is not properly updated:
Current schema version: A.4.9.0.20220809.01
Migrating to version A.4.10.0.20230316.01
Migration completed. Successfully applied 1 migration.
07-18-2023 14:48:43 EDT: INFO: Migration completed.
07-18-2023 14:48:43 EDT: INFO: Performing post migration. This may take a while. Please wait ...
2023-07-18 18:48:47,709:ERROR:main:CgmsDbMigrationDriver: Migration failed. Exception: Reason :
javax.persistence.PersistenceException: [PersistenceUnit: common] Unable to build Hibernate
SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException
(EntityManagerFactoryBuilderImpl.java:1336)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build
(EntityManagerFactoryBuilderImpl.java:1262)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory
(HibernatePersistenceProvider.java:56)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at com.cisco.cgms.tools.CommandLineInit.initDataSource(CommandLineInit.java:57)
at com.cisco.cgms.tools.CommandLineInit.<init>(CommandLineInit.java:26)
at com.cisco.cgms.tools.CgmsDbMigrationDriver.<init>(CgmsDbMigrationDriver.java:41)
at com.cisco.cgms.tools.CgmsDbMigrationDriver.main(CgmsDbMigrationDriver.java:93)
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation:
sequence [cgms_dev.audit_trail_id_seq] defined inconsistent increment-size; found [1000]
but exp ecting [1]
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateSequence
(AbstractSchemaValidator.java:191)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.performValidation
(AbstractSchemaValidator.java:100)
at org.hibernate.tool.schema.internal.AbstractSchemaValidator.doValidation
(AbstractSchemaValidator.java:68)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction
(SchemaManagementToolCoordinator.java:192)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process
(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:316)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:469)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build
(EntityManagerFactoryBuilderImpl.java:1259)
... 6 more
2023-07-18 18:48:47,713:ERROR:main:CgmsDbMigrationDriver: Migration failed. Exception:
07-18-2023 14:48:47 EDT: ERROR: Post migration failed. See log file for more information.
Execute the following query in the DB:
DECLARE
seq_name VARCHAR2(100);
current_increment PLS_INTEGER;
BEGIN
FOR seq IN (SELECT sequence_name FROM all_sequences WHERE sequence_owner = 'CGMS_DEV') LOOP
seq_name := seq.sequence_name;
IF seq_name NOT IN ('CONFIG_GROUPS_ID_SEQ', 'FIRMWARE_GROUPS_ID_SEQ', 'NET_C8000_METRICS_ID_SEQ',
'NET_C8000_PROPERTIES_ID_SEQ', 'NET_LGLFN_METRICS_ID_SEQ','NET_LGLFN_PROPERTIES_ID_SEQ') THEN
-- Get the current increment for the sequence
EXECUTE IMMEDIATE 'SELECT INCREMENT_BY FROM ALL_SEQUENCES WHERE SEQUENCE_NAME = :seq and sequence_owner = ''CGMS_DEV'''
INTO current_increment
USING seq_name;
IF current_increment <> 1 THEN
-- If the current increment is not 1, update it to 1
EXECUTE IMMEDIATE 'ALTER SEQUENCE ' || seq_name || ' INCREMENT BY 1';
END IF;
END IF;
END LOOP;
END;
/