Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-16243

Upgrading Jira to 7.6 causes DVCS to fail on MS SQL environments

      Summary

      Upgrading Jira from version prior to 7.4 to 7.6+ causes DVCS to fail on MS SQL environments

      Environment

      • Jira 7.6.0
      • Jira database is using a MS SQL server on the backend such as 2012 or 2014

      Steps to Reproduce

      This problem can be reproduced by

      1. Install previous version of Jira such as 7.1.9 or 7.2.x
      2. Use a MS SQL 2012 database
      3. connect Jira to a bitbucket or github repo using the DVCS connector
      4. upgrade Jira to 7.6.0

      Expected Results

      DVCS works

      Actual Results

      DVCS stops working, and the logs have errors such as:

      Caught SQLServerException for select "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", "AO_E8B6CC_MESSAGE"."PAYLOAD", "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY", max("AO_E8B6CC_MESSAGE_QUEUE_ITEM"."RETRIES_COUNT") as "RETRIES_COUNT" from "dbo"."AO_E8B6CC_MESSAGE" "AO_E8B6CC_MESSAGE" left join "dbo"."AO_E8B6CC_MESSAGE_QUEUE_ITEM" "AO_E8B6CC_MESSAGE_QUEUE_ITEM" on "AO_E8B6CC_MESSAGE"."ID" = "AO_E8B6CC_MESSAGE_QUEUE_ITEM"."MESSAGE_ID" where "AO_E8B6CC_MESSAGE"."ID" = ? group by "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", "AO_E8B6CC_MESSAGE"."PAYLOAD", "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY"
      com.querydsl.core.QueryException: Caught SQLServerException for select "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", "AO_E8B6CC_MESSAGE"."PAYLOAD", "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY", max("AO_E8B6CC_MESSAGE_QUEUE_ITEM"."RETRIES_COUNT") as "RETRIES_COUNT" from "dbo"."AO_E8B6CC_MESSAGE" "AO_E8B6CC_MESSAGE" left join "dbo"."AO_E8B6CC_MESSAGE_QUEUE_ITEM" "AO_E8B6CC_MESSAGE_QUEUE_ITEM" on "AO_E8B6CC_MESSAGE"."ID" = "AO_E8B6CC_MESSAGE_QUEUE_ITEM"."MESSAGE_ID" where "AO_E8B6CC_MESSAGE"."ID" = ? group by "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", "AO_E8B6CC_MESSAGE"."PAYLOAD", "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY" 
      

      The more telling error is:

      Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator. 
      

      Which appears to indicate that the DVCS is trying to make a SQL comparison/sort that is not possible in MS SQL

      Notes

       

      Workaround

      • Manually update all columns in table AO_E8B6CC_% from ntext to nvarchar(max)

            [JSWSERVER-16243] Upgrading Jira to 7.6 causes DVCS to fail on MS SQL environments

            I migrated after this initial ticket to Jira 7.7.1 and this is no longer a concern – we haven't fully updated to 7.92, so I can't say if this is reoccuring or not.

            Casey Daniell added a comment - I migrated after this initial ticket to Jira 7.7.1 and this is no longer a concern – we haven't fully updated to 7.92, so I can't say if this is reoccuring or not.

            Hello Team,

            At present we are using Jira v7.3.6 and we are planning to upgrade directly from Jira v7.3.6 to Jira 7.9.2. As you mentioned above this problem is fixed in Jira v 7.6.3 then please let us know "Manually update all columns in table AO_E8B6CC_% from ntext to nvarchar(max)" Is this activity need to do while upgrading Jira v7.9.2??

             

            Thanks! 

            Dnyaneshwar Ramesh Borase added a comment - - edited Hello Team, At present we are using Jira v7.3.6 and we are planning to upgrade directly from Jira v7.3.6 to Jira 7.9.2. As you mentioned above this problem is fixed in Jira v 7.6.3 then please let us know "Manually update all columns in table AO_E8B6CC_% from ntext to nvarchar(max)" Is this activity need to do while upgrading Jira v7.9.2??   Thanks! 

            Fixed in version 7.6.3.

            Peter Runge (Inactive) added a comment - Fixed in version 7.6.3.

            What is the resolution? How was this moved to resolved? We are still experiencing this issue and need guidance

            Chad Peters added a comment - What is the resolution? How was this moved to resolved? We are still experiencing this issue and need guidance

            This recommended workaround did not work for us. I'm now seeing the following in the logs. Has anyone else seen this follow-on issue? This is really impacting our production workflow.

            The DELETE statement conflicted with the REFERENCE constraint "fk_ao_e8b6cc_message_queue_item_message_id". The conflict occurred in database "jira", table "jiraschema.AO_E8B6CC_MESSAGE_QUEUE_ITEM", column 'MESSAGE_ID'.

            Chad Peters added a comment - This recommended workaround did not work for us. I'm now seeing the following in the logs. Has anyone else seen this follow-on issue? This is really impacting our production workflow. The DELETE statement conflicted with the REFERENCE constraint "fk_ao_e8b6cc_message_queue_item_message_id". The conflict occurred in database "jira", table "jiraschema.AO_E8B6CC_MESSAGE_QUEUE_ITEM", column 'MESSAGE_ID'.

            Will Atlassian support this change, if implemented.

            I identified the tables to change with
            select * from INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE in ('TEXT', 'NTEXT')
            and TABLE_NAME like 'AO_E8B6CC_%'

            Which gives me:  
            AO_E8B6CC_SYNC_EVENT
            AO_E8B6CC_SYNC_EVENT
            AO_E8B6CC_ISSUE_MAPPING_V2
            AO_E8B6CC_ISSUE_MAPPING_V2
            AO_E8B6CC_CHANGESET_MAPPING
            AO_E8B6CC_CHANGESET_MAPPING
            AO_E8B6CC_CHANGESET_MAPPING
            AO_E8B6CC_REPOSITORY_MAPPING
            AO_E8B6CC_SYNC_AUDIT_LOG
            AO_E8B6CC_COMMIT

            And this SQL will give me the correct alter statement preserving the nullability of a column.
            select
            'alter table [dbo].' + quotename(TABLE_NAME)
            + ' alter column ' + quotename(COLUMN_NAME)
            + ' nvarchar(max) '
            + case when IS_NULLABLE = 'NO' then 'not null' else 'null' end
            + ';'
            from
            INFORMATION_SCHEMA.COLUMNS
            where
            DATA_TYPE in ('NTEXT')
            and TABLE_NAME like 'AO_E8B6CC_%'
            Ideally, Atlassian will support these changes and let me get our critically needed GIT / JIRA integration functional again – our DEV process is currently severely impacted by this issue.

            Casey Daniell added a comment - Will Atlassian support this change, if implemented. I identified the tables to change with select * from INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE in ('TEXT', 'NTEXT') and TABLE_NAME like 'AO_E8B6CC_%' Which gives me:   AO_E8B6CC_SYNC_EVENT AO_E8B6CC_SYNC_EVENT AO_E8B6CC_ISSUE_MAPPING_V2 AO_E8B6CC_ISSUE_MAPPING_V2 AO_E8B6CC_CHANGESET_MAPPING AO_E8B6CC_CHANGESET_MAPPING AO_E8B6CC_CHANGESET_MAPPING AO_E8B6CC_REPOSITORY_MAPPING AO_E8B6CC_SYNC_AUDIT_LOG AO_E8B6CC_COMMIT And this SQL will give me the correct alter statement preserving the nullability of a column. select 'alter table [dbo] .' + quotename(TABLE_NAME) + ' alter column ' + quotename(COLUMN_NAME) + ' nvarchar(max) ' + case when IS_NULLABLE = 'NO' then 'not null' else 'null' end + ';' from INFORMATION_SCHEMA.COLUMNS where DATA_TYPE in ('NTEXT') and TABLE_NAME like 'AO_E8B6CC_%' Ideally, Atlassian will support these changes and let me get our critically needed GIT / JIRA integration functional again – our DEV process is currently severely impacted by this issue.

            Adam Jakubowski (Inactive) added a comment - - edited prunge I think that most probably this is caused by  https://ecosystem.atlassian.net/browse/AO-3429   https://bitbucket.org/activeobjects/ao/pull-requests/90/ao-3429-ao-3430-issue-jsds-307-nvarchar/diff

            I did change to nvarchar(max) for all AO_E8B6CC_% and made collation to be same for them as well for other columns i DVCS tables.  GITHUB is now connected and works. Something like this can be used:

             

            SELECT CONCAT( 'ALTER TABLE ' ,T.name, ' ALTER COLUMN ', C.name, ' nvarchar(max) COLLATE SQL_Latin1_General_CP437_CI_AI;') FROM   sys.tables AS T INNER JOIN sys.columns C ON T.object_id = C.object_id WHERE  collation_name IS NOT NULL AND collation_name = 'SQL_Latin1_General_CP437_CI_AI' AND T.name like 'AO_E8B6CC_%' and type_name(c.user_type_id) ='ntext'

            Carl Kullman added a comment - I did change to nvarchar(max) for all AO_E8B6CC_% and made collation to be same for them as well for other columns i DVCS tables.  GITHUB is now connected and works. Something like this can be used:   SELECT CONCAT( 'ALTER TABLE ' ,T.name, ' ALTER COLUMN ', C.name, ' nvarchar(max) COLLATE SQL_Latin1_General_CP437_CI_AI;') FROM   sys.tables AS T INNER JOIN sys.columns C ON T.object_id = C.object_id WHERE  collation_name IS NOT NULL AND collation_name = 'SQL_Latin1_General_CP437_CI_AI' AND T.name like 'AO_E8B6CC_%' and type_name(c.user_type_id) ='ntext'

            or
            ALTER TABLE AO_E8B6CC_MESSAGE ALTER COLUMN PAYLOAD NVARCHAR(MAX)

            Carl Kullman added a comment - or ALTER TABLE AO_E8B6CC_MESSAGE ALTER COLUMN PAYLOAD NVARCHAR(MAX)

            Using the SQL above on a MS SQL 2012 server if I cast the text column to a nvarchar(max) the SQL starts functioning again. (see below SQL). 

            MS is removing support for text, ntext, and image datatypes. The Payload json object is a ntext column, while the other columns in this DB are varchar(255), seems like a solution to explore is migrating this column from ntext to text.

            https://docs.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql

             

            select "AO_E8B6CC_MESSAGE"."ID",
            "AO_E8B6CC_MESSAGE"."ADDRESS",
            CAST ("AO_E8B6CC_MESSAGE"."PAYLOAD" AS NVARCHAR(MAX)),
            "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE",
            "AO_E8B6CC_MESSAGE"."PRIORITY",
            max("AO_E8B6CC_MESSAGE_QUEUE_ITEM"."RETRIES_COUNT") as "RETRIES_COUNT"
            from "dbo"."AO_E8B6CC_MESSAGE" "AO_E8B6CC_MESSAGE"
            left join "dbo"."AO_E8B6CC_MESSAGE_QUEUE_ITEM" "AO_E8B6CC_MESSAGE_QUEUE_ITEM"
            on "AO_E8B6CC_MESSAGE"."ID" = "AO_E8B6CC_MESSAGE_QUEUE_ITEM"."MESSAGE_ID"
            --where "AO_E8B6CC_MESSAGE"."ID" = ?
            group by "AO_E8B6CC_MESSAGE"."ID",
            "AO_E8B6CC_MESSAGE"."ADDRESS",
            CAST ("AO_E8B6CC_MESSAGE"."PAYLOAD" AS NVARCHAR(MAX)) ,
            "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE",
            "AO_E8B6CC_MESSAGE"."PRIORITY"

            Casey Daniell added a comment - Using the SQL above on a MS SQL 2012 server if I cast the text column to a nvarchar(max) the SQL starts functioning again. (see below SQL).  MS is removing support for text, ntext, and image datatypes. The Payload json object is a ntext column, while the other columns in this DB are varchar(255), seems like a solution to explore is migrating this column from ntext to text. https://docs.microsoft.com/en-us/sql/t-sql/data-types/ntext-text-and-image-transact-sql   select "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", CAST ("AO_E8B6CC_MESSAGE"."PAYLOAD" AS NVARCHAR(MAX)), "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY", max("AO_E8B6CC_MESSAGE_QUEUE_ITEM"."RETRIES_COUNT") as "RETRIES_COUNT" from "dbo"."AO_E8B6CC_MESSAGE" "AO_E8B6CC_MESSAGE" left join "dbo"."AO_E8B6CC_MESSAGE_QUEUE_ITEM" "AO_E8B6CC_MESSAGE_QUEUE_ITEM" on "AO_E8B6CC_MESSAGE"."ID" = "AO_E8B6CC_MESSAGE_QUEUE_ITEM"."MESSAGE_ID" --where "AO_E8B6CC_MESSAGE"."ID" = ? group by "AO_E8B6CC_MESSAGE"."ID", "AO_E8B6CC_MESSAGE"."ADDRESS", CAST ("AO_E8B6CC_MESSAGE"."PAYLOAD" AS NVARCHAR(MAX)) , "AO_E8B6CC_MESSAGE"."PAYLOAD_TYPE", "AO_E8B6CC_MESSAGE"."PRIORITY"

              Unassigned Unassigned
              aheinzer Andy Heinzer
              Affected customers:
              35 This affects my team
              Watchers:
              40 Start watching this issue

                Created:
                Updated:
                Resolved: