Confluence Upgrade from 3.5.5 to 4.0.4 failes due to database error (bandana)
Asked by Robert Schlephorst:

After performing an Upgrade from 3.5.5 to 4.0.4 Confluence complained about a failed upgrade. It is obviously related to an SQL/Database-Error with userdata or similar.

Confluence is integrated with Jira 4.4.3 (recently updated from 4.3) and Crowd 2.3.4 (recently updated from 2.2).

Everything is stored in the same PostgreSQL 8.4 instance.

Changing the JDBC-Driver didn't fix it (tried jdbc3, jdbc4 and newer build 803), must be related to database.

See the Logs:

```
2011-11-15 10:58:31,315 INFO main com.atlassian.confluence.lifecycle contextInitialized Starting Confluence 4.0.4 (build #3057)2011-11-15 10:58:32,842 INFO main springframework.web.context.ContextLoader initWebApplicationContext Root WebApplicationContext: initialization started2011-11-15 10:58:35,390 INFO main com.atlassian.confluence.lifecycle &lt;init&gt; Loading EhCache cache manager2011-11-15 10:58:47,223 INFO main springframework.web.context.ContextLoader initWebApplicationContext Root WebApplicationContext: initialization completed in 14381 ms2011-11-15 10:58:51,221 WARN main confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask doUpgrade Could not create unique constraint: alter table cwd_user add constraint cwd_user_name_dir_id unique (lower_user_name, directory_id), StatementCallback; bad SQL grammar alter table cwd_user add constraint cwd_user_name_dir_id unique (lower_user_name, directory_id) ; nested exception is org.postgresql.util.PSQLException: FEHLER: Relation ?cwd_user_name_dir_id? existiert bereits2011-11-15 10:58:51,226 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 A PooledConnection that has already signalled a Connection error is still in use!2011-11-15 10:58:51,227 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 Another error has occurred org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert which will not be reported to listeners!org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriertat org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2096)at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1829)at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:364)at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:78)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:99)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy33.doUpgrade(Unknown Source)at com.atlassian.confluence.upgrade.AbstractUpgradeManager$UpgradeStep$3.execute(AbstractUpgradeManager.java:479)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:188)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:137)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:94)at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)2011-11-15 10:58:51,229 WARN main confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask doUpgrade Could not create unique constraint: alter table cwd_group add constraint cwd_group_name_dir_id unique (lower_group_name, directory_id), StatementCallback; uncategorized SQLException for SQL alter table cwd_group add constraint cwd_group_name_dir_id unique (lower_group_name, directory_id) ; SQL state 25P02 ; error code 0 ; FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert; nested exception is org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert2011-11-15 10:58:51,230 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 A PooledConnection that has already signalled a Connection error is still in use!2011-11-15 10:58:51,230 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 Another error has occurred org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert which will not be reported to listeners!org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriertat org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2096)at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1829)at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:364)at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:78)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:99)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy33.doUpgrade(Unknown Source)at com.atlassian.confluence.upgrade.AbstractUpgradeManager$UpgradeStep$3.execute(AbstractUpgradeManager.java:479)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:188)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:137)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:94)at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)2011-11-15 10:58:51,231 WARN main confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask doUpgrade Could not create unique constraint: alter table cwd_user_attribute add constraint cwd_unique_usr_attr unique (directory_id, user_id, attribute_name, attribute_lower_value), StatementCallback; uncategorized SQLException for SQL alter table cwd_user_attribute add constraint cwd_unique_usr_attr unique (directory_id, user_id, attribute_name, attribute_lower_value) ; SQL state 25P02 ; error code 0 ; FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert; nested exception is org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert2011-11-15 10:58:51,232 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 A PooledConnection that has already signalled a Connection error is still in use!2011-11-15 10:58:51,232 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 Another error has occurred org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert which will not be reported to listeners!org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriertat org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2096)at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1829)at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:364)at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:78)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:99)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy33.doUpgrade(Unknown Source)at com.atlassian.confluence.upgrade.AbstractUpgradeManager$UpgradeStep$3.execute(AbstractUpgradeManager.java:479)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:188)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:137)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:94)at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)2011-11-15 10:58:51,233 WARN main confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask doUpgrade Could not create unique constraint: alter table cwd_group_attribute add constraint cwd_unique_grp_attr unique (directory_id, group_id, attribute_name, attribute_lower_value), StatementCallback; uncategorized SQLException for SQL alter table cwd_group_attribute add constraint cwd_unique_grp_attr unique (directory_id, group_id, attribute_name, attribute_lower_value) ; SQL state 25P02 ; error code 0 ; FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert; nested exception is org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert2011-11-15 10:58:51,234 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 A PooledConnection that has already signalled a Connection error is still in use!2011-11-15 10:58:51,234 WARN main v2.c3p0.impl.NewPooledConnection handleThrowable c3p0 Another error has occurred org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert which will not be reported to listeners!org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriertat org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2096)at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1829)at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:364)at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:78)at com.atlassian.confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask.doUpgrade(AbstractConstraintCreationUpgradeTask.java:99)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy33.doUpgrade(Unknown Source)at com.atlassian.confluence.upgrade.AbstractUpgradeManager$UpgradeStep$3.execute(AbstractUpgradeManager.java:479)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:188)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:137)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:94)at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)2011-11-15 10:58:51,235 WARN main confluence.upgrade.upgradetask.AbstractConstraintCreationUpgradeTask doUpgrade Could not create unique constraint: alter table cwd_membership add constraint cwd_unique_group_membership unique (parent_id, child_group_id), StatementCallback; uncategorized SQLException for SQL alter table cwd_membership add constraint cwd_unique_group_membership unique (parent_id, child_group_id) ; SQL state 25P02 ; error code 0 ; FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert; nested exception is org.postgresql.util.PSQLException: FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert2011-11-15 10:58:51,283 INFO main confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintCleaner cleanUp Checking for invalid entries in the Bandana table2011-11-15 10:58:51,290 INFO main confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask doUpgrade Beginning task to add not null and unique constraints on Bandana context and key columns2011-11-15 10:58:51,300 INFO main confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask doUpgrade Ignoring non-existence of band_key_idx constraint2011-11-15 10:58:51,301 INFO main confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask doUpgrade Adding not null and unique constraints on Bandana context and key columns2011-11-15 10:58:51,337 ERROR main confluence.upgrade.ddl.HibernateAlterTableExecutor alterTable Failed to run alter table commands2011-11-15 10:58:51,353 ERROR main atlassian.confluence.upgrade.UpgradeLauncherServletContextListener contextInitialized Upgrade failed, application will not start: Upgrade task com.atlassian.confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask@a5ab328 failed during the SCHEMA_UPGRADE phase due to: StatementCallback; bad SQL grammar alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY) ; nested exception is org.postgresql.util.PSQLException: FEHLER: Relation ?bandana_unique_key? existiert bereitscom.atlassian.confluence.upgrade.UpgradeException: Upgrade task com.atlassian.confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask@a5ab328 failed during the SCHEMA_UPGRADE phase due to: StatementCallback; bad SQL grammar alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY) ; nested exception is org.postgresql.util.PSQLException: FEHLER: Relation ?bandana_unique_key? existiert bereitsat com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:212)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.runSchemaUpgradeTasks(AbstractUpgradeManager.java:137)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.upgrade(AbstractUpgradeManager.java:94)at com.atlassian.confluence.upgrade.UpgradeLauncherServletContextListener.contextInitialized(UpgradeLauncherServletContextListener.java:45)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)at org.apache.catalina.core.StandardService.start(StandardService.java:525)at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)at org.apache.catalina.startup.Catalina.start(Catalina.java:595)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)Caused by: org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY) ; nested exception is org.postgresql.util.PSQLException: FEHLER: Relation ?bandana_unique_key? existiert bereitsat org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:97)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:429)at com.atlassian.confluence.upgrade.ddl.HibernateDdlExecutor.executeDdlStatements(HibernateDdlExecutor.java:55)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy34.executeDdlStatements(Unknown Source)at com.atlassian.confluence.upgrade.ddl.HibernateAlterTableExecutor.alterTableGrouped(HibernateAlterTableExecutor.java:84)at com.atlassian.confluence.upgrade.ddl.HibernateAlterTableExecutor.alterTable(HibernateAlterTableExecutor.java:64)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy35.alterTable(Unknown Source)at com.atlassian.confluence.upgrade.upgradetask.BandanaKeyUniqueConstraintUpgradeTask.doUpgrade(BandanaKeyUniqueConstraintUpgradeTask.java:117)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)at $Proxy33.doUpgrade(Unknown Source)at com.atlassian.confluence.upgrade.AbstractUpgradeManager$UpgradeStep$3.execute(AbstractUpgradeManager.java:479)at com.atlassian.confluence.upgrade.AbstractUpgradeManager.executeUpgradeStep(AbstractUpgradeManager.java:188)... 18 moreCaused by: org.postgresql.util.PSQLException: FEHLER: Relation ?bandana_unique_key? existiert bereitsat org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2096)at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1829)at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:372)at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:364)at com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422)at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)... 58 more2011-11-15 10:58:51,357 ERROR main atlassian.confluence.upgrade.UpgradeLauncherServletContextListener contextInitialized 1 errors were encountered during upgrade:2011-11-15 10:58:51,358 ERROR main atlassian.confluence.upgrade.UpgradeLauncherServletContextListener contextInitialized 1: StatementCallback; bad SQL grammar alter table BANDANA alter column BANDANACONTEXT set not null, alter column BANDANAKEY set not null, add constraint bandana_unique_key unique (BANDANACONTEXT, BANDANAKEY) ; nested exception is org.postgresql.util.PSQLException: FEHLER: Relation ?bandana_unique_key? existiert bereits2011-11-15 10:58:51,358 WARN main atlassian.confluence.plugin.PluginFrameworkContextListener contextInitialized Not starting full plugin system due to upgrade or licensing errors
```


Answers:
author: Volker Volker
body: We had the same error here. After checking back with Atlassion support, we coude resolve the issue by executing the following SQL queries before starting the upgrade:

```
alter table bandana drop constraint bandana_unique_key;alter table CONTENT_PERM drop constraint cp_unique_user;alter table CONTENT_PERM drop constraint cp_unique_group;alter table CONTENT_PERM_SET drop constraint cps_unique_type;delete from CONTENT_PERM where CPS_ID is null;delete from CONTENT_PERM_SET where CONTENT_ID is null;
```


author: Gregory Sudderth
body: The "Bandana" check is basically the 1st operation applied against the DB. If it fails, then everything else will fail as well.