Version Picker (multiple versions) incorrectly persists data in JIRA change history

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

問題

The Version Picker (multiple versions) custom field incorrectly persists data in the change history table when making changes to issues. This can cause project imports to subsequently fail as the data's not in an expected state, causing errors similar to the following to appear in the logs:

2016-01-22 16:20:57,097 JiraTaskExectionThread-10 ERROR sysadmin 978x3742x1 z25doj 0:0:0:0:0:0:0:1 /secure/admin/ProjectImportSummary.jspa [c.a.jira.task.TaskManagerImpl] Task 'Importing project 'Project Name'.' failed.
java.lang.NumberFormatException: For input string: "[10150]"
	at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
	at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
	at java.lang.Double.parseDouble(Double.java:538)
	at java.lang.Double.<init>(Double.java:608)
	at com.atlassian.jira.imports.project.customfield.VersionCustomFieldImporter.getNonDecimalValue(VersionCustomFieldImporter.java:36)
	at com.atlassian.jira.imports.project.customfield.VersionCustomFieldImporter.getMappedImportValue(VersionCustomFieldImporter.java:26)
	at com.atlassian.jira.imports.project.transformer.ChangeItemTransformerImpl.mapCustomFieldIdList(ChangeItemTransformerImpl.java:73)
	at com.atlassian.jira.imports.project.transformer.ChangeItemTransformerImpl.transform(ChangeItemTransformerImpl.java:55)
	at com.atlassian.jira.imports.project.handler.ChangeItemPersisterHandler.handleEntity(ChangeItemPersisterHandler.java:54)
	at com.atlassian.jira.imports.project.handler.ChainedOfBizSaxHandler.endTopLevelElement(ChainedOfBizSaxHandler.java:219)
	at com.atlassian.jira.imports.project.handler.ChainedOfBizSaxHandler.endElement(ChainedOfBizSaxHandler.java:167)
	at com.atlassian.jira.imports.project.handler.ChainedOfBizSaxHandler.endElement(ChainedOfBizSaxHandler.java:134)
	at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
	at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at com.atlassian.security.xml.RestrictedXMLReader.parse(RestrictedXMLReader.java:103)
	at com.atlassian.jira.imports.xml.DefaultBackupXmlParser$XmlParser.parseXml(DefaultBackupXmlParser.java:115)
	at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parse(DefaultBackupXmlParser.java:64)
	at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parseXml(DefaultBackupXmlParser.java:52)
	at com.atlassian.jira.imports.xml.DefaultBackupXmlParser.parseOfBizBackupXml(DefaultBackupXmlParser.java:41)
	at com.atlassian.jira.imports.project.DefaultProjectImportManager.importChangeItemEntities(DefaultProjectImportManager.java:1113)
	at com.atlassian.jira.imports.project.DefaultProjectImportManager.doImport(DefaultProjectImportManager.java:659)
	at com.atlassian.jira.bc.imports.project.DefaultProjectImportService.doImport(DefaultProjectImportService.java:416)
	at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSummary$ProjectImportCallable.call(ProjectImportSummary.java:285)
	at com.atlassian.jira.web.action.admin.importer.project.ProjectImportSummary$ProjectImportCallable.call(ProjectImportSummary.java:236)
	at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:458)
	at com.atlassian.jira.task.TaskManagerImpl$TaskCallableDecorator.call(TaskManagerImpl.java:426)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at com.atlassian.jira.task.ForkedThreadExecutor$ForkedRunnableDecorator.run(ForkedThreadExecutor.java:216)
	at java.lang.Thread.run(Thread.java:745)

原因

The data is persisted incorrectly in the backup with square brackets, which can cause project imports to fail. Note that the full XML backup and restore functionality will still continue to work as expected.

回避策

It is important to not perform this changes directly on a production instance (Except if the source instance will no longer be used after the Project Import). Instead, we recommend setting up a staging server using an XML backup from the source instance, perform the changes on the staging server and then generate a new backup from that staging server to perform Project Import.

If needing to project import, the database can be edited with the below steps. These were verified on PostgreSQL and the syntax may vary for different DBMS.

  1. Backup JIRA.
  2. Jira を停止します。
  3. Execute the below SQL to identify the affected fields:

    SELECT * FROM changeitem WHERE oldvalue LIKE '[%]' OR newvalue LIKE '[%]';

    (warning) The above query was tested on PostgreSQL and the syntax may vary for different DBMS.

  4. Execute the below SQL to remove the brackets:

    PostgreSQL

    update changeitem set oldvalue = trim(both '[]' from oldvalue), newvalue = trim(both '[]' from newvalue) where field = '<affected field name>';

    MySQL

    UPDATE changeitem SET NEWVALUE = replace(replace(NEWVALUE,']',''),'[','') where field='<affected field name>' AND NEWVALUE like '[%]';
    UPDATE changeitem SET OLDVALUE = replace(replace(OLDVALUE,']',''),'[','') where field='<affected field name>' AND OLDVALUE like '[%]';

    SQL Server

    UPDATE changeitem SET NEWVALUE = replace(CONVERT(VARCHAR(MAX), replace(CONVERT(VARCHAR(MAX), NEWVALUE),']','')),'[','')
    where field='<affected field name>' AND NEWVALUE like '[[]%]';
    UPDATE changeitem SET OLDVALUE = replace(CONVERT(VARCHAR(MAX), replace(CONVERT(VARCHAR(MAX), OLDVALUE),']','')),'[','')
    where field='<affected field name>' AND OLDVALUE like '[[]%]';

    Oracle

    update changeitem set oldvalue = trim('[' from oldvalue), newvalue = trim ('[' from newvalue) where field = '<affected field name>';
    update changeitem set oldvalue = trim(']' from oldvalue), newvalue = trim (']' from newvalue) where field = '<affected field name>';
  5. In some cases, this may cause empty values to be present. We can fix this with the below:

    PostgreSQL

    UPDATE changeitem SET oldvalue = NULL WHERE oldvalue = '' AND field = <affected field name>;
    UPDATE changeitem SET newvalue = NULL WHERE newvalue = '' AND field = <affected field name>;
  6. Jira を起動します。

  7. Generate an XML backup and use that for importing into the target instance.


ソリューション

Bug reported in  JRASERVER-59681 - Getting issue details... STATUS


最終更新日 2022 年 9 月 9 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.