Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-64915

Site restore fails on Oracle with due to duplicate sequences being created by active objects

      Summary

      Site restore fails due to active objects import for some add-ons on oracle.

      The import fails due to the restore attempting to create duplicate sequences in the database. This is caused by the naming of tables and columns in active objects entities used by the add-on.

      Environment

      • Database: Oracle 11g 11.2.0.1.0 / 11.2.0.4.0
      • Database Driver Version: 11.2.0.2.0 / 11.2.0.4.0 / 12.1.0.1.0
      • Add-on: Smart Attachments - others likely affected.

      Steps to Reproduce

      1. Install JIRA with Oracle database configured in setup.
      2. Install add-on (Smart Attachments)
      3. Create XML backup
      4. Restore XML backup

      Expected Results

      All data is restored without issue as it would be on other supported databases (Postgres, MySQL, etc).

      Actual Results

      Data restore fails when restoring active objects tables.

      The below exception is thrown in the xxxxxxx.log file:

      2017-03-22 13:07:09,192 JiraImportTaskExecutionThread-1 ERROR dmcmorris 786x603x1 4xuhp1 192.168.56.1 /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 plugin Smart Attachments(com.stiltsoft.jira.smart-attachments) #1.15.1 (table AO_D4B4E5_FV_COMMENT_THREAD):Error executing update for SQL statement 'CREATE SEQUENCE "AO_D4B4E5_FV_COMMEN1480854115" INCREMENT BY 1 START WITH 1 NOMAXVALUE MINVALUE 1'
      	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:583)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.performImport(DefaultDataImportService.java:757)
      	at com.atlassian.jira.bc.dataimport.DefaultDataImportService.doImport(DefaultDataImportService.java:331)
      	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: java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by an existing object
      

      Notes

      This appears to be caused by how active objects creates sequence names in Oracle as mention in this issue:

      A restore of a backup fails in Oracle 11.2g due to a bug in the way sequence names are generated which causes duplicate sequences to be generated. Attached is a patch file that contains a unit test that demonstrate the problem.

      This happens when:

      • there are two entities name A and A_B
      • entity A has a field named B_ID,
      • entity A_B has a field named ID

      The above makes a sequence for both tables named A_B_ID_SEQ_ID (which may or may not be shortened - the log snippet below is using the shortened name). 

      The sequence generation net.java.ao.schema.DefaultSequenceNameConverter simply concatenates the table name and field name, which means both of the above entities generates the same sequence, and thus causing the restore to fail.

      Workaround

      Have the add-on developer change column names and add an upgrade task so that duplicated sequences are not generated at restoration.

       As a workaround to the failing XML restoration, restore using Oracle dump instead.

            [JRASERVER-64915] Site restore fails on Oracle with due to duplicate sequences being created by active objects

            Dee Howard added a comment -

            Hey, 

            We've got a few customers struggling with this one and some complaints raised. From our side, this would be very difficult and risky to fix. Can you please let us know if this can be fixed?

            Even so we can get back to the customers and set some expectations. 

            Much appreciated, 

            Dee

            Dee Howard added a comment - Hey,  We've got a few customers struggling with this one and some complaints raised. From our side, this would be very difficult and risky to fix. Can you please let us know if this can be fixed? Even so we can get back to the customers and set some expectations.  Much appreciated,  Dee

            Hi there,

            Would be great if this could be resolved. It seems to require a very simple fix actually, but the impact is monstrous. We (TM4J) had a number of customers of our add-on not being able to backup/restore Jira instances over the last years because of this exact problem.

            Please, provide any feedback so we can understand what are the next steps.

            Thank you.

            Vitor Pelizza added a comment - Hi there, Would be great if this could be resolved. It seems to require a very simple fix actually, but the impact is monstrous. We (TM4J) had a number of customers of our add-on not being able to backup/restore Jira instances over the last years because of this exact problem. Please, provide any feedback so we can understand what are the next steps. Thank you.

            Just had this same error when importing to an Oracle 12c database.

            Espen Sandall added a comment - Just had this same error when importing to an Oracle 12c database.

            Issue also reported in Test Management for Jira

            Keri Duthie (Inactive) added a comment - Issue also reported in Test Management for Jira

            We've noticed that in the created backup file for our field "THREAD_ID" (table AO_D4B4E5_FV_COMMENT) there is a parameter autoIncrement="true", but it should be - autoIncrement="false". If we manually change the value to "false" then it will restore from backup without any errors. On other database types this parameter is always set autoIncrement="false".

            Alexander Ovsyannikov added a comment - We've noticed that in the created backup file for our field "THREAD_ID" (table AO_D4B4E5_FV_COMMENT) there is a parameter autoIncrement="true", but it should be - autoIncrement="false". If we manually change the value to "false" then it will restore from backup without any errors. On other database types this parameter is always set autoIncrement="false".

              Unassigned Unassigned
              dmcmorris@atlassian.com Douglas McMorris (Inactive)
              Affected customers:
              17 This affects my team
              Watchers:
              20 Start watching this issue

                Created:
                Updated: