Details
-
Bug
-
Resolution: Fixed
-
High
-
7.0.0
-
None
-
4
-
Severity 3 - Minor
-
17
-
Description
Issue Summary
When we upgrade Bitbucket from 6.x to 7.x version without any comments on files or pull requests the upgrade will fail.
The Liquibase migration is:
update id_sequence set next_val = (
select max(id) + 100 from bb_comment
) where sequence_name = 'bb_comment'
If there are no records on bb_comment table, the select max will return no results, so the update will fail with the following error:
liquibase/r7_0/upgrade.xml::BBSDEV-19009-1::fdoherty: Reason: liquibase.exception.DatabaseException: ORA-01407: cannot update ("THE_OWNER"."ID_SEQUENCE"."NEXT_VAL") to NULL [Failed SQL: update id_sequence set next_val = ( select max(id) + 100 from bb_comment ) where sequence_name = 'bb_comment']
Steps to Reproduce
- Create a Bitbucket 6.x instance from scratch;
- Create a project and a repository;
- Add some files, then commit and push that changes;
- Try to upgrade to any 7.x version;
Expected Results
Upgrade completed with success
Actual Results
The upgrade process fails while trying to execute the changeset liquibase/r7_0/upgrade.xml::BBSDEV-19009-1:
ERROR [spring-startup] c.a.j.s.w.s.JohnsonDispatcherServlet SpringMVC dispatcher [springMvc] could not be started org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'crowdAliasDao': Unsatisfied dependency expressed through method 'setSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [stash-context.xml]: Invocation of init method failed; nested exception is liquibase.exception.MigrationFailedException: Migration failed for change set liquibase/r7_0/upgrade.xml::BBSDEV-19009-1::fdoherty: Reason: liquibase.exception.DatabaseException: ORA-01407: cannot update ("THE_OWNER"."ID_SEQUENCE"."NEXT_VAL") to NULL [Failed SQL: update id_sequence set next_val = ( select max(id) + 100 from bb_comment ) where sequence_name = 'bb_comment'] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:723) at
Workaround
Before the upgrade process, we can add a dummy comment on any commit. So the upgrade will be done with no errors.