Upgrade failed, application will not start: com.atlassian.config.ConfigurationException: Cannot update schema

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

When attempting to upgrade from Confluence 5.10.x to 6.1.x or above, the upgrade fails and The following appears in the atlassian-confluence.log:

ERROR [localhost-startStop-1] [atlassian.confluence.plugin.PluginFrameworkContextListener] launchUpgrades Upgrade failed, application will not start: com.atlassian.config.ConfigurationException: Cannot update schema
com.atlassian.confluence.upgrade.UpgradeException: com.atlassian.config.ConfigurationException: Cannot update schema
	at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:135)
	at com.atlassian.confluence.plugin.PluginFrameworkContextListener.launchUpgrades(PluginFrameworkContextListener.java:119)
	at com.atlassian.confluence.plugin.PluginFrameworkContextListener.contextInitialized(PluginFrameworkContextListener.java:78)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: com.atlassian.config.ConfigurationException: Cannot update schema
	at bucket.core.persistence.hibernate.schema.SchemaHelper.validateSchemaUpdateIfNeeded(SchemaHelper.java:174)
	at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:120)
	... 11 more
Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key named [FK9DC3E34D34A4917E]
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:885)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl$ForeignKeyBuilderImpl.build(InformationExtractorJdbcDatabaseMetaDataImpl.java:866)
	at org.hibernate.tool.schema.extract.internal.InformationExtractorJdbcDatabaseMetaDataImpl.getForeignKeys(InformationExtractorJdbcDatabaseMetaDataImpl.java:849)
	at org.hibernate.tool.schema.extract.internal.TableInformationImpl.foreignKeys(TableInformationImpl.java:97)
	at org.hibernate.tool.schema.extract.internal.TableInformationImpl.getForeignKey(TableInformationImpl.java:108)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.findMatchingForeignKey(AbstractSchemaMigrator.java:446)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:419)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:245)
	at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:110)
	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:87)
	at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:58)
	at bucket.core.persistence.hibernate.schema.SchemaHelper.validateSchemaUpdateIfNeeded(SchemaHelper.java:171)

Diagnosis

Environment

  • Starting on Confluecne 5.10.x or prior
  • Upgrading to Confluence 6.1.x or newer

Diagnostic Steps

  • Confirm the attachment storage location is the file system and not the database.
  • You can confirm this by running these commands, if they return any results, you have encountered this issue:

    SELECT Count(*) FROM attachments;
    SELECT max(lastmoddate) FROM ATTACHMENTS;
    
    tip/resting Created with Sketch.

    However, even with zero results, the foreign key should not exist, post-attachment migration.

Cause

This is a failure updating the DB schema during a Confluence upgrade. The error thrown is caused by:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key named [FK9DC3E34D34A4917E]

This error relates to a hibernate issue: (HHH-10802) Attempt to resolve foreign key metadata from JDBC metadata failed to find column mappings for foreign key - Hibernate JIRA

The upgrade fails due to the foreign key, "fkf0e7436e34a4917e" from content_label table referenced by the attachment_backup table:

    "fkf0e7436e34a4917e" FOREIGN KEY (attachmentid) REFERENCES attachments_backup(attachmentid)

This appears to be caused by a residual foreign key constraint left over from a prior attachment migration from the DB to the file system. This constraint should have been dropped when the migration of attachments from the database to the filesystem was complete.

Resolution

tip/resting Created with Sketch.

You must backup up your database before performing the following task.


Steps to resolve:

  1. Roll back the database to 5.10.8 (or restore the version you were previously running)
  2. Run the following commands to remove the constraint and drop the attachments table (if it exists):

    ALTER TABLE attachments
    DROP CONSTRAINT FKF0E7436E34A4917E;
    DROP TABLE ATTACHMENTS;
    
  3. Take another database backup as a precaution
  4. Perform the upgrade to Confluence 6.1.x or newer
tip/resting Created with Sketch.

As the attachments are now stored in the file system since 5.4+ (by default), dropping the attachments table should not have any negative effects. Post-attachment migration, the info connecting attachment details in the database to files on the filesystem is now stored in the attachmentdata table.

Last modified on Nov 14, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.