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

Upgrading to 5.x fails if there are commit general comments in the DB

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Highest Highest
    • 5.2.2, 5.0.7, 5.1.5
    • 5.0.0, 5.1.0, 5.2.0
    • None
    • None

      When upgrading to Bitbucket Server 5.x the system will fail to migrate the schema if there are commit general comments in the DB.

      NOTE: Commit general comments are not a full feature of the system. There's no way (and there's never been a way) to create them or display them through the Bitbucket Server UI. However the REST and Java API allow for these comments to be created. Only customers who have used these APIs to create these comments will be affected by this bug.

      The new Comment API migration tasks introduced a new CommentThread entity to be at the root of a conversation and to tie all of its comments together. As part of the 5.0 DB migration tasks for each root comment a thread row is created in the bb_comment_thread table. All comments in the sta_comment table are then copied across to the new bb_comment table. However the tasks are missing a step to create threads for commit general comments so when the system tries to copy those comments across the foreign key from bb_comment to bb_comment_thread is violated and the upgrade fails.

      2017-07-03 15:28:58,425 ERROR [spring-startup]  liquibase classpath:liquibase/master.xml: liquibase/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios: Change Set liquibase/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios failed.  Error: ERROR: insert or update on table "bb_comment" violates foreign key constraint "fk_bb_comment_thread"
         Detail: Key (thread_id)=(12345) is not present in table "bb_comment_thread". [Failed SQL: insert into bb_comment (
                           id,
                           author_id,
                           comment_text,
                           created_timestamp,
                           entity_version,
                           thread_id,
                           updated_timestamp
                   )
                   select
                           id,
                           author_id,
                           comment_text,
                           created_timestamp,
                           entity_version,
                           id,
                           updated_timestamp
                   from sta_comment
                   where root_id is null]
      

            [BSERV-9918] Upgrading to 5.x fails if there are commit general comments in the DB

            Aaron made changes -
            Comment [ A comment with security level 'atlassian-staff' was removed. ]
            Owen made changes -
            Workflow Original: Stash Workflow - Restricted [ 2408025 ] New: JAC Bug Workflow v3 [ 3133948 ]
            Kanwar made changes -
            Remote Link New: This issue links to "Page (Confluence)" [ 406028 ]
            Owen made changes -
            Symptom Severity Original: Major [ 14431 ] New: Severity 2 - Major [ 15831 ]
            Caterina Curti made changes -
            Comment [ Hi [~mathieu1306378015],
            We have created a support ticket to investigate this issue for you (https://support.atlassian.com/browse/SSP-30674).

            Let us know here if there are any issue accessing it. ]

            Mathieu Mailhos added a comment - - edited

            Edit: after further investigation with Jira support team, this is unrelated.

             

            Mathieu Mailhos added a comment - - edited Edit: after further investigation with Jira support team, this is unrelated.  
            Andrei Khudavets made changes -
            Fix Version/s New: 5.1.5 [ 73055 ]
            Andrei Khudavets made changes -
            Fix Version/s New: 5.0.7 [ 73054 ]

            lonewulfster,

            The only other report we've had of this issue when attempting to upgrade to 5.2.2 had invalid data in their database tables. I'd recommend creating a support request so you can work with a support engineer to identify the data that's causing your upgrade to fail and remove it. When you create your request, please reference this issue. It'll help us get a jump on next steps.

            Best regards,
            Bryan Turner
            Atlassian Bitbucket

            Bryan Turner (Inactive) added a comment - lonewulfster , The only other report we've had of this issue when attempting to upgrade to 5.2.2 had invalid data in their database tables. I'd recommend creating a support request so you can work with a support engineer to identify the data that's causing your upgrade to fail and remove it. When you create your request, please reference this issue. It'll help us get a jump on next steps. Best regards, Bryan Turner Atlassian Bitbucket

            Artur Kurkov added a comment - - edited

            I think i have this problem on Bitbucket 5.2.2 and postgresql 9.5( after upgraded from v4.14.7)

            2017-8-01 13:37:59,241 WARN [spring-startup] o.s.w.c.s.XmlWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: 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/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios:
             Reason: liquibase.exception.DatabaseException: ERROR: insert or update on table "bb_comment" violates foreign key constraint "fk_bb_comment_thread"
             Detail: Key (thread_id)=(7986) is not present in table "bb_comment_thread". [Failed SQL: insert into bb_comment (
             id,
             author_id,
             comment_text,
             created_timestamp,
             entity_version,
             thread_id,
             updated_timestamp
             )
             select
             id,
             author_id,
             comment_text,
             created_timestamp,
             entity_version,
             id,
             updated_timestamp
             from sta_comment
             where root_id is null]
            
            

            Artur Kurkov added a comment - - edited I think i have this problem on Bitbucket 5.2.2 and postgresql 9.5( after upgraded from v4.14.7) 2017-8-01 13:37:59,241 WARN [spring-startup] o.s.w.c.s.XmlWebApplicationContext Exception encountered during context initialization - cancelling refresh attempt: 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/r5_0/upgrade.xml::BSERVDEV-8489-12::jpalacios: Reason: liquibase.exception.DatabaseException: ERROR: insert or update on table "bb_comment" violates foreign key constraint "fk_bb_comment_thread" Detail: Key (thread_id)=(7986) is not present in table "bb_comment_thread" . [Failed SQL: insert into bb_comment ( id, author_id, comment_text, created_timestamp, entity_version, thread_id, updated_timestamp ) select id, author_id, comment_text, created_timestamp, entity_version, id, updated_timestamp from sta_comment where root_id is null ]

              jpalacios Juan Palacios (Inactive)
              jpalacios Juan Palacios (Inactive)
              Affected customers:
              1 This affects my team
              Watchers:
              17 Start watching this issue

                Created:
                Updated:
                Resolved: