Import of cloud backup to server fails with SQL exception due to missing primary key

XMLWordPrintable

    • 39
    • Severity 2 - Major
    • 110

      NOTE: This bug report is for JIRA Server. Using JIRA Cloud? See the corresponding bug report.

      Summary

      When trying to import the XML backup generated from the Cloud instance (1000.456.2) the restore process failed with a SQL syntax error of the CREATE TABLE statement.

      Environment

      • XML backup generated from Cloud instance 1000.456.2
      • Target JIRA Server version : 7.2.2 (PostgreSQL)

      Steps to Reproduce

      1. Create an XML backup from Cloud instance.
      2. Import backup to JIRA Server instance.

      Expected Results

      Restore process finished without any error.

      Actual Results

      Following error in UI:

      There was a problem restoring ActiveObjects data for the <unknown plugin> plugin. Importing table AO_D9132D_SHARED_REPORT failed. Please Check the logs for details.
      

      The below exception is thrown in the log file:

      2016-10-28 19:49:30,251 JiraImportTaskExecutionThread-1 ERROR sysadmin 1186x326x1 1hy1inv 127.0.0.1 /secure/admin/XmlRestore.jspa [c.a.j.bc.dataimport.DefaultDataImportService] Error importing data: java.lang.IllegalArgumentException: Unsupported field encountered: binary
      java.lang.IllegalArgumentException: Unsupported field encountered: binary
      	at com.atlassian.dbexporter.importer.DataImporter$BaseInserter.setValue(DataImporter.java:372)
      	at com.atlassian.dbexporter.importer.DataImporter.importTable(DataImporter.java:112)
      	at com.atlassian.dbexporter.importer.DataImporter.access$000(DataImporter.java:41)
      	at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:71)
      	at com.atlassian.dbexporter.importer.DataImporter$1.call(DataImporter.java:64)
      	at com.atlassian.dbexporter.jdbc.JdbcUtils.withConnection(JdbcUtils.java:28)
      	at com.atlassian.dbexporter.importer.DataImporter.doImportNode(DataImporter.java:64)
      	at com.atlassian.dbexporter.importer.AbstractImporter.importNode(AbstractImporter.java:44)
      	at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:69)
      	at com.atlassian.activeobjects.backup.ActiveObjectsBackup.restore(ActiveObjectsBackup.java:151)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.restoreActiveObjects(DefaultDataImportService.java:554)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.performImport(DefaultDataImportService.java:728)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.doImport(DefaultDataImportService.java:324)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:60)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:28)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:157)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:133)
      	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:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      

      And

      2016-10-19 13:36:47,196 JiraImportTaskExecutionThread-1 ERROR administrator 816x98x1 6feeel 192.168.0.40 /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> (table AO_D9132D_SHARED_REPORT):Error executing update for SQL statement 'CREATE TABLE public."AO_D9132D_SHARED_REPORT" (
          "FILTER_CONFIGURATION" TEXT,
          "FILTER_CONFIG_HASH" INTEGER,
          "HASH" TEXT,
          "HIERARCHY_LEVEL" INTEGER,
          "ID" BIGSERIAL,
          "PLAN_ID" BIGINT,
          "REPORT_CONFIGURATION" TEXT,
          "REPORT_CONFIG_HASH" INTEGER,
          "REPORT_ID" TEXT,
      )'
      	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.ActiveObjectsTableCreator.create(ActiveObjectsTableCreator.java:73)
      	at com.atlassian.activeobjects.backup.ActiveObjectsTableCreator.create(ActiveObjectsTableCreator.java:57)
      	at com.atlassian.dbexporter.importer.TableDefinitionImporter.doImportNode(TableDefinitionImporter.java:50)
      	at com.atlassian.dbexporter.importer.AbstractImporter.importNode(AbstractImporter.java:44)
      	at com.atlassian.dbexporter.DbImporter.importData(DbImporter.java:69)
      	at com.atlassian.activeobjects.backup.ActiveObjectsBackup.restore(ActiveObjectsBackup.java:151)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.restoreActiveObjects(DefaultDataImportService.java:554)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.performImport(DefaultDataImportService.java:728)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.doImport(DefaultDataImportService.java:324)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:60)
      	at com.atlassian.jira.web.action.setup.DataImportAsyncCommand.call(DataImportAsyncCommand.java:28)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:157)
      	at com.atlassian.jira.task.ImportTaskManagerImpl$TaskCallableDecorator.call(ImportTaskManagerImpl.java:133)
      	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:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near ")"
        Position: 295
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2101)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1834)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:300)
      	at org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
      	at org.apache.commons.dbcp2.DelegatingStatement.executeUpdate(DelegatingStatement.java:234)
      	at com.atlassian.activeobjects.backup.SqlUtils.executeUpdate(SqlUtils.java:34)
      	... 19 more
      

      Notes

      The issue is caused by two tables which do not have a primary key defined:

      • AO_D9132D_SHARED_REPORT which is used by JIRA Portfolio Plugin (This is a bundled system plugin in Cloud instance)
        jira=> \d "AO_D9132D_SHARED_REPORT"
                                         Table "public.AO_D9132D_SHARED_REPORT"
                Column        |  Type   |                               Modifiers
        ----------------------+---------+------------------------------------------------------------------------
         ID                   | bigint  | not null default nextval('"AO_D9132D_SHARED_REPORT_ID_seq"'::regclass)
         HASH                 | text    | not null
         PLAN_ID              | bigint  | not null
         REPORT_ID            | text    | not null
         REPORT_CONFIGURATION | text    |
         FILTER_CONFIGURATION | text    | not null
         HIERARCHY_LEVEL      | integer | not null
         REPORT_CONFIG_HASH   | integer |
         FILTER_CONFIG_HASH   | integer |
        
      • CONNECT_PLUGIN_MODULES_F4ED3A which is used by a Cloud specific plugin.
        jira=> \d CONNECT_PLUGIN_MODULES_F4ED3A
        Table "public.connect_plugin_modules_f4ed3a"
         Column | Type  | Modifiers
        --------+-------+-----------
         data   | bytea | not null
        

      Once we modified the activeobjects.xml file by setting a primary key to the relevant table, the error disappeared.

      Workaround

      • If these tables do not contain any data, we can manually modify the activeobjects.xml file by removing both tables' definition and data:
        • Search for "<table name="AO_D9132D_SHARED_REPORT">" and "<table name="CONNECT_PLUGIN_MODULES_F4ED3A">", remove these two table entities.
        • Search for "<data tableName="AO_D9132D_SHARED_REPORT">" and "<data tableName="CONNECT_PLUGIN_MODULES_F4ED3A">", remove these two data entities.
      • If there are any data in the AO_D9132D_SHARED_REPORT table, we can set the primary key to the ID column by searching for
        <table name="AO_D9132D_SHARED_REPORT"><column name="ID" primaryKey="false"
        

        and changing the primaryKey value from "false" to "true".

        • Since the table CONNECT_PLUGIN_MODULES_F4ED3A is Cloud-specific we can remove it from the activeobjects.xml file as described in the above workaround.

            Assignee:
            alex (Inactive)
            Reporter:
            Chen Mao (Inactive)
            Votes:
            9 Vote for this issue
            Watchers:
            33 Start watching this issue

              Created:
              Updated:
              Resolved: