-
Bug
-
Resolution: Fixed
-
High
-
None
-
7
-
Severity 2 - Major
-
15
-
Summary
Importing from Cloud to Server fails while restoring Active Object. The error occurs while adding a foreign key constraint for table "AO_56464C_APPROVAL_SOURCE", "AO_56464C_APPROVER_LIST". Below is the error shown in the UI. The issue is similar to JRASERVER-67706 but different tables are involved.
There was a problem restoring ActiveObjects data for the <unknown plugin> plugin. Caught exception with following message: ERROR: relation "public.JIRAISSUE" does not exist. Please check the log for details.
or
There was a problem restoring ActiveObjects data for the <unknown plugin> plugin. Caught exception with following message: Referencing column 'ISSUE_ID' and referenced column 'ID' in foreign key constraint fk_ao_56464c_approval_source_issue_id are incompatible. Please check the log for details.
Steps to Reproduce
- Export data from a cloud instance by creating a backup for server
- Access a test Jira DC or Server instance.
- Attempt to import the data
Expected Results
The import works without problems
Actual Results
The import fails and the below error can be observed in both catalina.out and atlassian-jira.log
2022-06-23 06:55:59,432+0000 JiraImportTaskExecutionThread-1 ERROR admin 415x291x1 1yrjz2 172.29.215.120 /secure/admin/XmlRestore.jspa [c.a.j.bc.dataimport.DefaultDataImportService] Error during ActiveObjects 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_56464C_APPROVAL_SOURCE" ADD CONSTRAINT "fk_ao_56464c_approval_source_issue_id" FOREIGN KEY ("ISSUE_ID") REFERENCES public."JIRAISSUE"("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:51) at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:72) 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.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 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: org.postgresql.util.PSQLException: ERROR: relation "public.JIRAISSUE" does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2565) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2297) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:322) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:401) 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
OR
com.atlassian.activeobjects.spi.ActiveObjectsImportExportException: There was an error during import/export with <unknown plugin>:Error executing update for SQL statement 'ALTER TABLE AO_56464C_APPROVAL_SOURCE ADD CONSTRAINT fk_ao_56464c_approval_source_issue_id FOREIGN KEY (ISSUE_ID) REFERENCES JIRAISSUE(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(Unknown Source) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: java.sql.SQLException: Referencing column 'ISSUE_ID' and referenced column 'ID' in foreign key constraint 'fk_ao_56464c_approval_source_issue_id' are incompatible. at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.StatementImpl.executeUpdateInternal(StatementImpl.java:1335) at com.mysql.cj.jdbc.StatementImpl.executeLargeUpdate(StatementImpl.java:2084) at com.mysql.cj.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1246) 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)
Workaround
- Unzip cloud backup
unzip cloudbackup.zip Archive: cloudbackup.zip inflating: entities.xml inflating: activeobjects.xml
- Expand xml to multiple lines:
xmllint activeobjects.xml --format > activeobjects_fixed.xml
- Remove the foreign key entries from activeobjects from activeobjects_fixed.xml using the editor of your choice.
<foreignKey fromTable="AO_56464C_APPROVAL_SOURCE" fromColumn="ISSUE_ID" toTable="JIRAISSUE" toColumn="ID" /> <foreignKey fromTable="AO_56464C_APPROVER_LIST" fromColumn="ISSUE_ID" toTable="JIRAISSUE" toColumn="ID" />
- Let's check our work so far. To start we'll make another copy of activeobjects in the multiline format:
xmllint activeobjects.xml --format > testing.xml
- Now we will Diff the fixed file to the original to ensure only 2 lines were removed (output should look like below):
diff testing.xml activeobjects_fixed.xml <foreignKey fromTable="AO_56464C_APPROVAL_SOURCE" fromColumn="ISSUE_ID" toTable="JIRAISSUE" toColumn="ID" /> <foreignKey fromTable="AO_56464C_APPROVER_LIST" fromColumn="ISSUE_ID" toTable="JIRAISSUE" toColumn="ID" />
- Delete the old active objects file and rename the fixed one to activeobjects.xml
mv activeobjects_fixed.xml activeobjects.xml
- Zip backup back together
zip -r fixed.zip activeobjects.xml entities.xml
- Move the backup to the import directory on the destination instance and perform the import