Upgrade Fails: Problem upgrading with script, Violation of unique constraint on upgrade_33.sql
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Symptoms
Upgrading from Fisheye/Crucible version 1.6.X to 2.X fails with an error similar to the following:
1
2
3
4
5
6
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 with script /data/apps/fecru-2.0.0/sql/HSQL/upgrade/upgrade_33.sql: SQL script error on line 54:
"insert into cru_inline_comment (select distinct(cru_comment), cru_frx_id from cru_revision_comment where cru_line_range is not null);"
(Violation of unique constraint SYS_PK_649: duplicate value(s) for column(s) CRU_COMMENT_ID),
please contact http://www.atlassian.com/support/
Cause
Corruptions in the database, duplicate entries, prevent the upgrade script from completing successfully.
Resolution
Connect to the HSQL DB using this connection procedure.
Run the following SQL queries:
select comment from revision_comment where linerange is null group by comment having count(comment) > 1;
The result will be an ID number, for example:
22
select * from revision_comment where comment=22;
The result will will be the offending data, for example:
12 | 2008-12-02 | 17:35:21 | (null) | 126 | 582 | 22 |
19 | 2008-12-08 | 12:06:23 | (null) | 126 | 1040 | 22 |
3. Either run the following SQL command (don't forget to commit the change):
delete from revision_comment where rc_id = 19;
commit;
OR
Create the SQL script and apply it directly from the command line:
patch.sql
1
2
delete from revision_comment where rc_id = 19;
commit;
Go to
Administration > Backup
and create a backup of the db in your crucible 1.6.6.Shutdown the Fisheye/Crucible server.
Go to the
FISHEYE_HOME/lib
directory and run the following command, replacingFISHEYE_HOME
andFISHEYE_INST
with the fully qualified path:
1
java -Xms512m -Xmx512m -jar FISHEYE_HOME/lib/hsqldb-1.8.0.10.jar --inlineRC "URL=jdbc:hsqldb:file:FISHEYE_INST/var/data/crudb/crucible;shutdown=true,USER=sa,PASSWORD=" patch.sql
4. The above command should result in output similar to the following:
x rows updated (where x is some number > 0)
Was this helpful?