Uploaded image for project: 'Jira Cloud'
  1. Jira Cloud
  2. JRACLOUD-65554

SQL errors thrown during Cloud export when more than one Remote Crowd Directory exists

    XMLWordPrintable

Details

    Description

      Steps to reproduce

      1. Trigger a backup from the Backup Manager on a Cloud instance that has more than one "Remote Crowd Directory" in cwd_directory (i.e. it's been previously imported from a Cloud instance)

      Expected results

      The backup completes with no errors.

      Actual results

      The backup does successfully complete but with a number of these errors in the logs:

      2016-06-27 12:13:10,813 Long running task: OnDemandBackup ERROR jashmore 733x20059x7 g6x0cn 59.167.133.100 /rest/obm/1.0/runbackup [c.a.o.backupmanager.service.BackupEntityChangesProvider] Unable to find Entity [Membership] by WhereClausule: directory_id = (select id from cwd_directory where directory_name='Remote Crowd Directory')
      org.ofbiz.core.entity.GenericDataSourceException: SQL Exception while executing the following:SELECT ID FROM public.cwd_membership WHERE directory_id = (select id from cwd_directory where directory_name='Remote Crowd Directory') (ERROR: more than one row returned by a subquery used as an expression)
      	at org.ofbiz.core.entity.jdbc.SQLProcessor.executeQuery(SQLProcessor.java:641)
      	at org.ofbiz.core.entity.GenericDAO.createEntityListIterator(GenericDAO.java:967)
      	at org.ofbiz.core.entity.GenericDAO.selectListIteratorByCondition(GenericDAO.java:883)
      	at org.ofbiz.core.entity.GenericDAO.selectByCondition(GenericDAO.java:798)
      	at org.ofbiz.core.entity.GenericDAO.selectByCondition(GenericDAO.java:777)
      	at org.ofbiz.core.entity.GenericHelperDAO.findByCondition(GenericHelperDAO.java:178)
      	at org.ofbiz.core.entity.GenericDelegator.findByCondition(GenericDelegator.java:1085)
      	at com.atlassian.ondemand.backupmanager.service.BackupEntityChangesProvider.findEntityIds(BackupEntityChangesProvider.java:215)
      	at com.atlassian.ondemand.backupmanager.service.BackupEntityChangesProvider.parseBackupEntityChange(BackupEntityChangesProvider.java:194)
      	at com.atlassian.ondemand.backupmanager.service.BackupEntityChangesProvider.loadFromXml(BackupEntityChangesProvider.java:153)
      	at com.atlassian.ondemand.backupmanager.service.BackupEntityChangesProvider.<init>(BackupEntityChangesProvider.java:56)
      	at com.atlassian.ondemand.backupmanager.service.JiraBackupService.backup(JiraBackupService.java:125)
      	at com.atlassian.ondemand.backupmanager.rest.OnDemandBackupTask.run(OnDemandBackupTask.java:84)
      	at com.atlassian.ondemand.backupmanager.longrunning.ManagedTask.run(ManagedTask.java:35)
      	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: more than one row returned by a subquery used as an expression
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
      	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
      	at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
      	at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
      	at org.ofbiz.core.entity.jdbc.SQLProcessor.executeQuery(SQLProcessor.java:633)
      	... 18 more
      

      And using this backup created for a restore on JIRA Server will not have the any users in the internal directory.

      Notes

      From mlassau:

      It is running an invalid SQL query:

      SELECT ID 
      FROM public.cwd_membership 
      WHERE directory_id = (select id from cwd_directory where directory_name='Remote Crowd Directory')
      

      The problem is the inner query: it is finding more than one row in cwd_directory that is a Remote Crowd directory.
      This would make sense if you eg import data from server that already had a Remote Crowd Directory because JIRA OD will add another one during import and deactivate all previous user directories.

      The query should be looking for the one and only directory that is active.
      It should maybe even do some "integrity checking" up front.

      Workaround

      To remove the additional user directory and generate the backup again. Please contact support if you need help to apply the workaround.

      Attachments

        Issue Links

          Activity

            People

              ohookins@atlassian.com Oliver Hookins (Inactive)
              nmason Nick Mason
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: