Batched email notifications can cause Jira XML restores to fail

XMLWordPrintable

    • 8.05
    • 11
    • Severity 3 - Minor
    • 4

      Issue Summary

      See https://confluence.atlassian.com/jirakb/backup-restore-fails-when-restoring-activeobjects-with-foreign-key-constraint-error-in-jira-1050543506.html

      Steps to Reproduce

      1. Perform XML export while Jira is sending email notifications
      2. Attempt to perform XML import on another Jira instance

      Expected Results

      The XML import completes successfully

      Actual Results

      The import fails with the following in atlassian-jira.log:

      2022-01-12 22:43:19,110+0000 JiraImportTaskExecutionThread-1 DEBUG anonymous 1321x82x1 9b31ks 172.29.249.105,172.50.0.2 /secure/SetupImport.jspa [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] startCleaning
      2022-01-12 22:43:19,122+0000 JiraImportTaskExecutionThread-1 DEBUG anonymous 1321x82x1 9b31ks 172.29.249.105,172.50.0.2 /secure/SetupImport.jspa [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] stopCleaning
      ...
      2022-01-12 22:49:38,154+0000 JiraImportTaskExecutionThread-1 ERROR anonymous 1321x82x1 9b31ks 172.29.249.105,172.50.0.2 /secure/SetupImport.jspa [c.a.j.bc.dataimport.DefaultDataImportService] Error during ActiveObjec
      ts restore
      com.atlassian.activeobjects.spi.ActiveObjectsImportExportException: There was an error during import/export with <unknown plugin>:Error executing update for SQL statement 'ALTER TABLE public."AO_733371_EVENT_PARAMETE
      R" ADD CONSTRAINT "fk_ao_733371_event_parameter_event_id" FOREIGN KEY ("EVENT_ID") REFERENCES public."AO_733371_EVENT"("ID")'
              at com.atlassian.activeobjects.backup.ImportExportErrorServiceImpl.newImportExportSqlException(ImportExportErrorServiceImpl.java:26)
              at com.atlassian.activeobjects.backup.SqlUtils.onSqlException(SqlUtils.java:46)
              at com.atlassian.activeobjects.backup.SqlUtils.executeUpdate(SqlUtils.java:37)
              at com.atlassian.activeobjects.backup.ActiveObjectsForeignKeyCreator.create(ActiveObjectsForeignKeyCreator.java:43)
              at com.atlassian.activeobjects.backup.ForeignKeyAroundImporter.after(ForeignKeyAroundImporter.java:26)
              at com.atlassian.dbexporter.importer.AbstractImporter.importNode(AbstractImporter.java:47)
              at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:70)
              at com.atlassian.activeobjects.backup.ActiveObjectsBackup.restore(ActiveObjectsBackup.java:151)
              at com.atlassian.jira.bc.dataimport.DefaultDataImportService.restoreActiveObjects(DefaultDataImportService.java:574)
              at com.atlassian.jira.bc.dataimport.DefaultDataImportService.performImport(DefaultDataImportService.java:749)
              at com.atlassian.jira.bc.dataimport.DefaultDataImportService.doImport(DefaultDataImportService.java:323)
              at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.unsafeCall(DataImportAsyncCommand.java:82)
              at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:64)
              at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:30)
              at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:177)
              at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:149)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
              at java.base/java.lang.Thread.run(Thread.java:829)
      Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on table "AO_733371_EVENT_PARAMETER" violates foreign key constraint "fk_ao_733371_event_parameter_event_id"
        Detail: Key (EVENT_ID)=(4888542) is not present in table "AO_733371_EVENT".
              at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2552)
              at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2284)
              at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:322)
              at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
              at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:322)
              at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:308)
              at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:284)
              at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:258)
              at org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
              at org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
              at com.atlassian.jira.ofbiz.sql.StatementWrapper.executeUpdate(StatementWrapper.java:29)
              at com.atlassian.jira.diagnostic.connection.DiagnosticStatement.lambda$executeUpdate$8(DiagnosticStatement.java:70)
              at com.atlassian.diagnostics.internal.platform.monitor.db.DefaultDatabaseDiagnosticsCollector.recordExecutionTime(DefaultDatabaseDiagnosticsCollector.java:70)
              at com.atlassian.jira.diagnostic.connection.DatabaseDiagnosticsCollectorDelegate.recordExecutionTime(DatabaseDiagnosticsCollectorDelegate.java:55)
              at com.atlassian.jira.diagnostic.connection.DiagnosticStatement.executeUpdate(DiagnosticStatement.java:70)
              at com.atlassian.activeobjects.backup.SqlUtils.executeUpdate(SqlUtils.java:34)
              ... 19 more
      

      Workaround

      • Schedule an XML export during non-peak usage or by taking 1 node out of the load balancer rotation first
      • Open activeobjects.xml in a text editor suitable for editing large files and remove all the data rows for <data tableName="AO_733371_EVENT_RECIPIENT">. This table stores email notifications and its contents are not needed for the restored Jira instance

            Assignee:
            Unassigned
            Reporter:
            Jeff Curry
            Votes:
            15 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: