Upgrade Failed with "Table has no primary key" Error Message

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

The Confluence upgrade process failed due a missing primary key or constraint in one of its tables. In the below example the problematic table is the LINKS table. The following appears in atlassian-confluence.log

2015-01-12 14:22:56,204 ERROR [localhost-startStop-1] [atlassian.confluence.upgrade.UpgradeLauncherServletContextListener] contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.LowerCaseUsernameReferencesUpgradeTask@292e1ad3 failed during the SCHEMA_UPGRADE phase due to: Table 'LINKS' has no primary key
com.atlassian.confluence.upgrade.UpgradeException: Upgrade task com.atlassian.confluence.upgrade.upgradetask.LowerCaseUsernameReferencesUpgradeTask@292e1ad3 failed during the SCHEMA_UPGRADE phase due to: Table 'LINKS' has no primary key
	at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:273)
	at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:217)
	at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:167)
	at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:51)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

Cause

There are two possible causes for this behavior:

  1. The constraint was previously removed while making changes to the database.
  2. The constraint was not added during a previous upgrade attempt.

Resolution

  1. Restore your database from a working backup.
  2. Create a temporary Confluence instance that matches the version you restored to.
  3. Match the LINKS table from your Confluence with the LINKS table from the fresh installation.
  4. Shutdown your Confluence.
  5. Backup your database.
  6. Add the missing constraints so the LINKS table in both instances match
  7. Start Confluence.
  8. Try upgrading again.
  9. If it fails again with a different table repeat the process to find out the missing constraints and fix them (AO tables can be ignored)

Since these steps involve multiple changes to the database, we strongly recommend using a DBA to assist in this task.

Last modified on Mar 30, 2016

Was this helpful?

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