How to fix the issue when a snapshot deployment fails with an error java.io.IOException: Failed to parse snapshot archive

Problem

During the deployment of a Jira snapshot, an error occurs java.io.IOException: Failed to parse snapshot archive and Caused by: java.util.zip.ZipException: zip END header not found, indicating a failure to parse the snapshot archive. Additionally, issues such as duplicate entries, SQL exceptions, and data migration problems are also encountered.

Symptoms

  1. Error message: Failed to parse snapshot archive '/opt/atlassian/jira/temp/snapshot****/*****.zip'

  2. Duplicate object errors, specifically with the 'Parent-Child Link'.

  3. Integrity check failures indicate multiple errors and warnings.

  4. SQL exceptions such as Duplicate entry '******' for key 'PRIMARY'

  5. NullPointerExceptions in logs.

  6. Issues are not visible post-deployment despite the application of configuration changes.

  7. Attachment-related errors were reported during deployment.

Root Cause Analysis

The root cause can be any of the following:

  1. Corrupted Snapshot Archive: The snapshot archive is corrupted, leading to parsing failures.

  2. Duplicate Entries: Duplicate issue link types in the Jira database, causing integrity check failures.

  3. SQL Exceptions: Configuration issues in the database are leading to integrity constraint violations.

  4. NullPointerExceptions: The browser or a proxy/firewall is terminating the request. Potential issues with request handling or database integrity.

  5. Attachment Errors: Missing or corrupted attachments causing deployment errors.

Resolution

Below are the resolutions depending on the root causes. You can follow any of the resolutions depending on the root cause you encounter.

Step 1: Addressing Snapshot Archive Parsing Error

  1. Recreate the Export: If an error like the one below is reported, recreate the export, as the files are likely corrupted.

    java.io.IOException: Failed to parse snapshot archive '/opt/atlassian/jira/temp/snapshot****/******.zip'. at com.botronsoft.jira.rollout.impl.SnapshotUnzippingServiceImpl.parseArchive(SnapshotUnzippingServiceImpl.java:133) at com.botronsoft.jira.rollout.impl.SnapshotUnzippingServiceImpl.initiateOperation(SnapshotUnzippingServiceImpl.java:73)
  2. Zip END header not found: If the Caused by: java.util.zip.ZipException: zip END header not found error is found during a Configuration Manager for Jira (CMJ) snapshot deployment like the one below, try the suggestions mentioned in the article here:

    Caused by: java.util.zip.ZipException: zip END header not found at java.base/java.util.zip.ZipFile$Source.zerror(Unknown Source) at java.base/java.util.zip.ZipFile$Source.findEND(Unknown Source) at java.base/java.util.zip.ZipFile$Source.initCEN(Unknown Source)
  3. Exclude Attachments: The attachment metadata (filename, creator, create date, etc.) is small enough to always be included in the snapshot. However, including the attachment files can make the snapshot grow very large. If attachments are included in the export, exclude them and manually migrate them. Refer to Moving Attachments.

Step 2: Resolving Duplicate Entries

If there is a Duplicate Object with an error related to ‘Parent-Child Link’ as the one below, then perform the two SQL queries shown in the following subsection:

Duplicate object,Error,Parent-Child Link,"Issue Link Type <a href=""http://abc.com/secure/admin/EditLinkType!default.jspa?id=12345"" target=""_blank"">'Parent-Child Link'</a> has duplicates. This may cause errors during deploy.",Parent-Child Link (Issue Link Type)
  1. Identify Duplicates:

  2. Delete Duplicates: Based on the integrity check results, delete the duplicate entry. Here is an example.

  3. Rename Duplicate Link Type: Alternatively, rename the duplicate issue link type via the Jira UI to resolve the conflict.

Step 3: Addressing SQL Exceptions

If the errors are related to SQL Exceptions, as the one below:

  1. Review MySQL Configuration: Ensure that the MySQL configuration is correct. Refer to Duplicate Entry for Key PRIMARY for detailed steps.

Step 4: Resolving NullPointerExceptions and Request Termination Issues

If the errors are related to java.lang.NullPointerException as the one below

  1. Check for Termination Issues: Review the request handling to ensure that a proxy or firewall is not terminating it. Refer to Timeout or Proxy Error.

  2. Ensure Proper Request Handling: Verify that the NullPointerException does not occur, which could be due to interrupted or malformed requests for the browser or a proxy/firewall terminating the request.

Step 5: Handling Attachment Errors

  1. Delete and Reimport: Delete issues associated with missing attachments and reimport them.

  2. Redeploy Attachments: Ensure that attachment errors are resolved before redeploying.

Post-Deployment Steps

  1. Reindex Jira: Run a reindexing operation to ensure all issues and configurations are correctly indexed and visible.

  2. Verify issues visibility: Confirm that all issues are visible and configurations are correctly applied post-redeployment.

By following the resolution steps, you can effectively resolve the common errors encountered during Jira snapshot deployments. To prevent data loss, ensure that you perform database backups before making any changes.