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

Database deadlocks when deleting Jira issues using parallel threads.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 7.1.4, 7.9.2, 8.13.1, 8.15.1
    • Issue - Actions

    Description

      Summary -
      When using an add-on executes functions using parallel threads such as deleting issues, Postgres goes into a deadlock situation.

      How to replicate -
      Using Automation for Jira

      1. Set up a rule trigger to use JQL to find issues 20+
      2. Action set as Delete Issue
      3. Make sure the Process all issues produced by this trigger in bulk is unticked (to force parallel threads)
      4. Run rule to delete.

      Expected result -
      All issues found by the JQL will be deleted.

      Actual result -
      Some issues get deleted but then Postgres throws an error -

      2018-06-15 13:57:16,440 automation-rule-executor:thread-4 ERROR admin 908x3610x2 t833he 0:0:0:0:0:0:0:1 /rest/plugins/1.0/available/featured [c.c.a.api.service.ComponentChainImpl] Unexpected runtime error executing component for config 'ComponentConfigBean{id='6', component=ACTION, parentId='null', conditionParentId='null', schemaVersion=1, type='jira.issue.delete', value=DeleteActionConfig{sendNotifications=false}, conditions=[], children=[], optimisedIds=[]}': 
      com.querydsl.core.QueryException: Caught PSQLException for update public.issuelink
      set sequence = ?
      where issuelink.id = ?
      	at com.querydsl.sql.DefaultSQLExceptionTranslator.translate(DefaultSQLExceptionTranslator.java:50)
      	at com.querydsl.sql.Configuration.translate(Configuration.java:459)
      	at com.querydsl.sql.dml.SQLUpdateClause.execute(SQLUpdateClause.java:217)
      	at com.atlassian.jira.issue.link.DefaultIssueLinkManager.lambda$resetSequences$2(DefaultIssueLinkManager.java:370)
      	at com.atlassian.jira.database.DefaultQueryDslAccessor.lambda$execute$1(DefaultQueryDslAccessor.java:74)
      	at com.atlassian.jira.database.DatabaseAccessorImpl.runInTransaction(DatabaseAccessorImpl.java:110)
      	at com.atlassian.jira.database.DefaultQueryDslAccessor.execute(DefaultQueryDslAccessor.java:73)
      	at com.atlassian.jira.issue.link.DefaultIssueLinkManager.resetSequences(DefaultIssueLinkManager.java:364)
      	at com.atlassian.jira.config.DefaultSubTaskManager.resetSequences(DefaultSubTaskManager.java:337)
      	at com.atlassian.jira.config.DefaultSubTaskManager.resetSequences(DefaultSubTaskManager.java:332)
      	at com.atlassian.jira.issue.managers.DefaultIssueDeleteHelper.removeIssueLinks(DefaultIssueDeleteHelper.java:182)
      	at com.atlassian.jira.issue.managers.DefaultIssueDeleteHelper.deleteIssue(DefaultIssueDeleteHelper.java:133)
      	at com.atlassian.jira.issue.managers.DefaultIssueManager.deleteIssue(DefaultIssueManager.java:723)
      	at com.atlassian.jira.issue.managers.RequestCachingIssueManager.deleteIssue(RequestCachingIssueManager.java:232)
      	at com.atlassian.jira.bc.issue.DefaultIssueService.delete(DefaultIssueService.java:402)
      	... 2 filtered
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at com.sun.proxy.$Proxy79.delete(Unknown Source)
      	... 2 filtered
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
      	at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
      	at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
      	at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
      	at com.sun.proxy.$Proxy4210.delete(Unknown Source)
      	at com.codebarrel.jira.issues.NativeIssueClient.deleteIssue(NativeIssueClient.java:393)
      	at com.codebarrel.automation.rulecomponent.jira.action.delete.DeleteActionExecutor.lambda$executeWithIssues$0(DeleteActionExecutor.java:50)
      	at java.util.ArrayList.forEach(ArrayList.java:1249)
      	at com.codebarrel.automation.rulecomponent.jira.action.delete.DeleteActionExecutor.executeWithIssues(DeleteActionExecutor.java:49)
      	at com.codebarrel.automation.api.component.executor.IssueRequiredExecutor.execute(IssueRequiredExecutor.java:28)
      	at com.codebarrel.automation.api.component.executor.IssueRequiredExecutor.execute(IssueRequiredExecutor.java:16)
      	at com.codebarrel.automation.api.service.ComponentChainImpl.doExecute(ComponentChainImpl.java:101)
      	at com.codebarrel.automation.api.service.SingleRuleExecutorServiceImpl.execute(SingleRuleExecutorServiceImpl.java:181)
      	at com.codebarrel.jira.plugin.automation.queue.JiraAutomationQueueExecutor.lambda$null$3(JiraAutomationQueueExecutor.java:246)
      	at com.codebarrel.jira.plugin.automation.service.execution.JiraThreadLocalExecutor.lambda$executeAs$0(JiraThreadLocalExecutor.java:36)
      	at com.codebarrel.jira.plugin.automation.service.execution.JiraThreadLocalExecutor.executeAsWithResult(JiraThreadLocalExecutor.java:53)
      	at com.codebarrel.jira.plugin.automation.service.execution.JiraThreadLocalExecutor.executeAs(JiraThreadLocalExecutor.java:35)
      	at com.codebarrel.jira.plugin.automation.queue.JiraAutomationQueueExecutor.lambda$processClaimedItem$4(JiraAutomationQueueExecutor.java:246)
      	at com.atlassian.jira.util.concurrent.BoundedExecutor$1.run(BoundedExecutor.java:50)
      	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: deadlock detected
        Detail: Process 88473 waits for ShareLock on transaction 49155693; blocked by process 83523.
      Process 83523 waits for ShareLock on transaction 49155677; blocked by process 88473.
        Hint: See server log for query details.
        Where: while updating tuple (0,12) in relation "issuelink"
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
      	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
      	at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98)
      	at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98)
      	at com.querydsl.sql.dml.SQLUpdateClause.execute(SQLUpdateClause.java:203)
      	... 54 more
      

      and the automation fails halfway due to the deadlock.

      Workaround
      If using Automation for Jira, make sure Process all issues produced by this trigger in bulk is
      Other add-on you need to see if they can be set to do the action in a single thread.

      This does not crash Jira, the transaction on delete just stops, and you can use Jira as normal anytime during the transaction and after.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dung@atlassian.com Dave (Inactive)
              Votes:
              27 Vote for this issue
              Watchers:
              34 Start watching this issue

              Dates

                Created:
                Updated: