Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-12315

Upgrading Bitbucket from 6.x to 7.x without any record on bb_comment fails

    XMLWordPrintable

Details

    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

      1. Create a Bitbucket 6.x instance from scratch;
      2. Create a project and a repository;
      3. Add some files, then commit and push that changes;
      4. 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.

      Attachments

        Activity

          People

            fdoherty@atlassian.com Frank Doherty
            09001b6e3d75 ogarcia (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: