Uploaded image for project: 'SR for Bitbucket - Development'
  1. SR for Bitbucket - Development
  2. SRBITB-299

CreateDefaultPullRequestTasks listener conflicts with WorkZone listeners

    Details

    • Type: Bug
    • Status: Done (View Workflow)
    • Priority: Medium
    • Resolution: Done
    • Affects Version/s: 5.1.8
    • Fix Version/s: 5.7.0
    • Labels:
      None
    • Sprint:
      Sprint 37 - Ends Jan 29, Sprint 38 - Next, DevTools 71
    • Critical Points:
      0.7

      Description

      To reproduce:

      Use "Script Event Handler", "Add tasks to new pull request" and WorkZone add reviewers to pull request you sometimes get the following stacktrace depending on the order the event handlers are run in:

      2018-02-27 14:31:44,961 ERROR [AtlassianEvent::thread-16] jhecht *5C7UIGx871x2745764x2 1k2d9gm 172.17.60.11,0:0:0:0:0:0:0:1 "POST /projects/SAR/
      repos/ansible/pull-requests HTTP/1.1" o.h.e.j.batch.internal.BatchingBatch HHH000315: Exception executing batch [org.hibernate.StaleStateExcepti
      on: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1], SQL: update sta_pull_request set closed_times
      tamp=?, description=?, from_hash=?, locked_timestamp=?, rescoped_timestamp=?, pr_state=?, title=?, to_branch_name=?, to_hash=?, to_branch_fqn=?,
       updated_timestamp=?, entity_version=? where id=? and entity_version=?
      2018-02-27 14:31:44,962 ERROR [AtlassianEvent::thread-16] jhecht *5C7UIGx871x2745764x2 1k2d9gm 172.17.60.11,0:0:0:0:0:0:0:1 "POST /projects/SAR/
      repos/ansible/pull-requests HTTP/1.1" o.h.i.ExceptionMapperStandardImpl HHH000346: Error during managed flush [Batch update returned unexpected
      row count from update [0]; actual row count: 0; expected: 1]
      2018-02-27 14:31:45,120 ERROR [AtlassianEvent::thread-16] jhecht *5C7UIGx871x2745764x2 1k2d9gm 172.17.60.11,0:0:0:0:0:0:0:1 "POST /projects/SAR/
      repos/ansible/pull-requests HTTP/1.1" c.o.s.b.DynamicEventListenerInvoker **********************************************************************
      ***************
      2018-02-27 14:31:45,122 ERROR [AtlassianEvent::thread-16] jhecht *5C7UIGx871x2745764x2 1k2d9gm 172.17.60.11,0:0:0:0:0:0:0:1 "POST /projects/SAR/
      repos/ansible/pull-requests HTTP/1.1" c.o.s.b.DynamicEventListenerInvoker Event handler failed: event: com.atlassian.bitbucket.event.pull.PullRe
      questOpenedEvent file: null
      com.atlassian.bitbucket.EntityOutOfDateException: You are attempting to modify an entity based on out-of-date information.
              at com.atlassian.stash.internal.aop.ExceptionRewriteAdvice.afterThrowing(ExceptionRewriteAdvice.java:56)
              at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
              at com.atlassian.bitbucket.comment.CommentService$addComment.call(Unknown Source)
              at com.onresolve.scriptrunner.canned.bitbucket.events.CreateDefaultPullRequestTasks$1.perform(CreateDefaultPullRequestTasks.groovy:159)
              at com.atlassian.stash.internal.user.DefaultEscalatedSecurityContext.call(DefaultEscalatedSecurityContext.java:54)
              at com.atlassian.bitbucket.user.EscalatedSecurityContext$call.call(Unknown Source)
              at com.onresolve.scriptrunner.canned.bitbucket.events.CreateDefaultPullRequestTasks.doScript(CreateDefaultPullRequestTasks.groovy:154)
              ... 8 frames trimmed
      Caused by: org.springframework.orm.hibernate5.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update
       [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from u
      pdate [0]; actual row count: 0; expected: 1
              at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:283)
              at org.springframework.orm.hibernate5.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:755)
              at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:594)
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
              at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
              ... 7 common frames omitted
      Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
              at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:67)
              at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:54)
              at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.checkRowCounts(BatchingBatch.java:141)
              at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.performExecution(BatchingBatch.java:116)
              at org.hibernate.engine.jdbc.batch.internal.BatchingBatch.doExecuteBatch(BatchingBatch.java:97)
              at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.execute(AbstractBatchImpl.java:147)
              at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.executeBatch(JdbcCoordinatorImpl.java:206)
              at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:611)
              at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:456)
              at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:337)
              at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
              at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1435)
              at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:491)
              at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3201)
              at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2411)
              at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467)
              at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146)
              at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38)
              at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220)
              at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68)
              at org.springframework.orm.hibernate5.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:582)
              ... 9 common frames omitted
      

        Attachments

          Issue Links

            Structure

              Activity

                People

                Assignee:
                rlander Reece Lander
                Reporter:
                amarkham Adam Markham
                Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:

                    Structure Helper Panel