Fisheye upgrade to 4.8.x fails because cru_source_rev_path_hash column already exists in cru_revision table

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server と Data Center のみ - この記事は、サーバーおよびデータセンター プラットフォームのアトラシアン製品にのみ適用されます。


要約

Upon starting up Fisheye 4.8.x for the first time after upgrading the instance, the upgrade fails and the following error is reported in the atlassian-fisheye.log  file:

2021-05-06 15:13:05,293 INFO  - Upgrading DB from version 107 using E:\Atlassian\fecru-4.8.0\sql\SQLSERVER2008\upgrade\upgrade_107.sql
2021-05-06 15:13:05,605 ERROR - The Web context could not be started
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbControlFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.cenqua.crucible.hibernate.DBControlFactoryImpl]: Constructor threw exception; nested exception is com.cenqua.crucible.hibernate.CruDBException: Problem upgrading database
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1115) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	...
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.cenqua.crucible.hibernate.DBControlFactoryImpl]: Constructor threw exception; nested exception is com.cenqua.crucible.hibernate.CruDBException: Problem upgrading database
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:164) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:125) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:270) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	... 53 more
Caused by: com.cenqua.crucible.hibernate.CruDBException: Problem upgrading database
	at com.cenqua.crucible.hibernate.DefaultDBControl.upgrade(DefaultDBControl.java:451) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.start(DefaultDBControl.java:268) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.start(DefaultDBControl.java:250) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DBControlFactoryImpl.<init>(DBControlFactoryImpl.java:67) [fisheye.jar:?]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [?:1.8.0_265]
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [?:1.8.0_265]
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:1.8.0_265]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [?:1.8.0_265]
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) [spring-beans-4.0.9.RELEASE.jar:4.0.9.RELEASE]
	... 55 more
Caused by: com.cenqua.crucible.hibernate.CruDBException: SQL script error on line 1: "alter table cru_revision add cru_source_rev_path_hash nvarchar(128);" 
    (Column names in each table must be unique. Column name 'cru_source_rev_path_hash' in table 'cru_revision' is specified more than once.), please contact http://www.atlassian.com/support/
	at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:595) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:524) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.doUpgrade(DefaultDBControl.java:482) [fisheye.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.upgrade(DefaultDBControl.java:433) [fisheye.jar:?]
	... 63 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Column names in each table must be unique. Column name 'cru_source_rev_path_hash' in table 'cru_revision' is specified more than once.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1621) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:868) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:768) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:248) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:223) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:711) [mssql-jdbc-7.2.2.jre8.jar:?]
	at com.cenqua.crucible.hibernate.DefaultDBControl.executeScript(DefaultDBControl.java:566) [fisheye.jar:?]
	... 66 more

環境

Reported originally when upgrading from 4.7.3 to 4.8.0, running in a Windows environment and connecting to SQL Server database; however, the operating system and the database type are most likely agnostic—the problem may happen in any OS and database type.

診断

After having restored the most recent backup from the original version so as to have a working environment once again, use an SQL client to connect to the Fisheye database and verify that the cru_revision  table has a column named cru_source_rev_path_hash

原因

The upgrade script does not expect the column cru_source_rev_path_hash to already exist in the cru_revision table because the upgrade script is supposed to create this column. As the column is already there, the script will fail, and the whole upgrade will fail as a consequence.

The unexpected existence of this column suggests that an upgrade was tried in the past; however, the upgrade failed. No backups were used to restore after the failed upgrade attempt, which left the database in an inconsistent state, making any future upgrade attempts fail.

ソリューション

It is not possible to predict how damaged the database is, i.e., how many other inconsistencies exist, but to fix this specific upgrade error please follow these steps:

  1. Using an SQL client, connect to the database used by Fisheye
  2. Run the following SQL command in order to remove the column from the table:

    ALTER TABLE cru_revision DROP cru_source_rev_path_hash;
  3. Make sure that this change has been committed
  4. Try upgrading again

(info) As you are modifying the database prior to upgrade, ensure that you have a backup before dropping the table.






最終更新日 2021 年 7 月 14 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.