Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-18145

Update schema error on existing foreign keys when upgrading XWiki

    XMLWordPrintable

    Details

    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Documentation in Release Notes:
      N/A
    • Similar issues:

      Description

      The error started to appear thanks to XWIKI-18128 but it most likely related to XWIKI-8286.
      The following error appears when performing an upgrade from an instance of XWiki < 11.5RC1:

      2020-12-07 11:07:47,545 [Exec Stream Pumper] - org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table PUBLIC.activitystream_events_status add constraint FKmwu6uxkc2jl3yvej4wi1p0pv0 foreign key (ases_eventid) references PUBLIC.activitystream_events" via JDBC Statement 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:93) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:62) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:1077) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:944) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.updateDatabase(HibernateStore.java:1111) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.XWikiHibernateBaseStore.updateSchema(XWikiHibernateBaseStore.java:274) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.hibernateShemaUpdate(HibernateDataMigrationManager.java:207) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.updateSchema(HibernateDataMigrationManager.java:188) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.migrateDatabase(AbstractDataMigrationManager.java:735) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.startMigrations(AbstractDataMigrationManager.java:657) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.hibernate.HibernateDataMigrationManager.startMigrations(HibernateDataMigrationManager.java:361) 
      2020-12-07 11:07:47,545 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.startMigrationsOnlyOnce(AbstractDataMigrationManager.java:637) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.tryToProcceedToMigration(AbstractDataMigrationManager.java:614) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.migration.AbstractDataMigrationManager.checkDatabase(AbstractDataMigrationManager.java:539) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:672) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.setWiki(HibernateStore.java:633) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.store.hibernate.HibernateStore.beginTransaction(HibernateStore.java:811) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.XWikiHibernateBaseStore.beginTransaction(XWikiHibernateBaseStore.java:577) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.XWikiHibernateStore.loadXWikiDoc(XWikiHibernateStore.java:976) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.store.XWikiCacheStore.loadXWikiDoc(XWikiCacheStore.java:394) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2144) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.getDocument(XWiki.java:2206) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.initializeMandatoryDocument(XWiki.java:1418) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.initializeMandatoryDocuments(XWiki.java:1385) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1290) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.initXWiki(XWiki.java:1227) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.XWiki.<init>(XWiki.java:1200) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at com.xpn.xwiki.internal.XWikiInitializerJob.runInternal(XWikiInitializerJob.java:117) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.xwiki.job.AbstractJob.runInContext(AbstractJob.java:243) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.xwiki.job.AbstractJob.run(AbstractJob.java:220) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at java.lang.Thread.run(Thread.java:748) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - Caused by: java.sql.SQLSyntaxErrorException: a FOREIGN KEY constraint already exists on the set of columns: FKMWU6UXKC2JL3YVEJ4WI1P0PV0 in statement [alter table PUBLIC.activitystream_events_status add constraint FKmwu6uxkc2jl3yvej4wi1p0pv0 foreign key (ases_eventid) references PUBLIC.activitystream_events] 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.apache.commons.dbcp2.DelegatingStatement.execute(DelegatingStatement.java:194) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	... 36 common frames omitted 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - Caused by: org.hsqldb.HsqlException: a FOREIGN KEY constraint already exists on the set of columns: FKMWU6UXKC2JL3YVEJ4WI1P0PV0 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.error.Error.error(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.error.Error.error(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.TableWorks.checkCreateForeignKey(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.TableWorks.addForeignKey(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.StatementSchema.getResult(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.StatementSchema.execute(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.Session.executeCompiledStatement(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.Session.executeDirectStatement(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	at org.hsqldb.Session.execute(Unknown Source) 
      2020-12-07 11:07:47,546 [Exec Stream Pumper] - 	... 41 common frames omitted
      

      Note that the same log error appears for several foreign keys. A first investigation show that the foreign keys names changed between XWiki 11.4 and XWiki 11.5.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              surli Simon Urli
              Reporter:
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Date of First Response: