sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Atlassian JIRA | Brendan Humphreys [Atlassian] | 5 years ago
  1. 0

    addItemToHistory has a race condition that can cause attempted inserts of duplicate keys. {code} 011-09-02 15:03:40,806 WARN [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - SQL Error: 0, SQLState: null 2011-09-02 15:03:40,907 ERROR [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - Batch entry 0 insert into cru_recently_visited (cru_last_viewed, cru_user_name, cru_item_type, cru_entity_id) values (1314 939820407, tstcruser4, atlassian-review, CR-ATL-542) was aborted. Call getNextException to see the cause. 2011-09-02 15:03:40,908 WARN [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - SQL Error: 0, SQLState: 23505 2011-09-02 15:03:40,908 ERROR [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - ERROR: duplicate key value violates unique constraint "cru_recently_visited_pkey" Detail: Key (cru_user_name, cru_item_type, cru_entity_id)=(tstcruser4, atlassian-review, CR-ATL-542) already exists. 2011-09-02 15:03:40,910 ERROR [btpool0-54 ] org.hibernate.event.def.AbstractFlushingEventListener org.hibernate.event.def.AbstractFlushingEventListener-performExecutions - Could not synchronize database state with sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137) at com.cenqua.crucible.hibernate.SessionState.commit(SessionState.java:101) at com.cenqua.crucible.hibernate.SessionState.commitTx(SessionState.java:67) at com.cenqua.crucible.hibernate.HibernateUtil.commitTransaction(HibernateUtil.java:228) at com.atlassian.fisheye.user.DefaultRecentlyVisitedManager.addItemToHistory(DefaultRecentlyVisitedManager.java:84) at com.atlassian.crucible.actions.ReviewAction.execute(ReviewAction.java:110) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:358) at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:218) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:192) at com.cenqua.crucible.interceptors.ReviewInterceptor.intercept(ReviewInterceptor.java:51) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.cenqua.crucible.interceptors.CruciblePermissionInterceptor.intercept(CruciblePermissionInterceptor.java:52) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) {code}

    Atlassian JIRA | 5 years ago | Brendan Humphreys [Atlassian]
    sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
  2. 0

    addItemToHistory has a race condition that can cause attempted inserts of duplicate keys. {code} 011-09-02 15:03:40,806 WARN [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - SQL Error: 0, SQLState: null 2011-09-02 15:03:40,907 ERROR [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - Batch entry 0 insert into cru_recently_visited (cru_last_viewed, cru_user_name, cru_item_type, cru_entity_id) values (1314 939820407, tstcruser4, atlassian-review, CR-ATL-542) was aborted. Call getNextException to see the cause. 2011-09-02 15:03:40,908 WARN [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - SQL Error: 0, SQLState: 23505 2011-09-02 15:03:40,908 ERROR [btpool0-54 ] org.hibernate.util.JDBCExceptionReporter org.hibernate.util.JDBCExceptionReporter-logExceptions - ERROR: duplicate key value violates unique constraint "cru_recently_visited_pkey" Detail: Key (cru_user_name, cru_item_type, cru_entity_id)=(tstcruser4, atlassian-review, CR-ATL-542) already exists. 2011-09-02 15:03:40,910 ERROR [btpool0-54 ] org.hibernate.event.def.AbstractFlushingEventListener org.hibernate.event.def.AbstractFlushingEventListener-performExecutions - Could not synchronize database state with sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206) at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137) at com.cenqua.crucible.hibernate.SessionState.commit(SessionState.java:101) at com.cenqua.crucible.hibernate.SessionState.commitTx(SessionState.java:67) at com.cenqua.crucible.hibernate.HibernateUtil.commitTransaction(HibernateUtil.java:228) at com.atlassian.fisheye.user.DefaultRecentlyVisitedManager.addItemToHistory(DefaultRecentlyVisitedManager.java:84) at com.atlassian.crucible.actions.ReviewAction.execute(ReviewAction.java:110) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:358) at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:218) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:192) at com.cenqua.crucible.interceptors.ReviewInterceptor.intercept(ReviewInterceptor.java:51) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) at com.cenqua.crucible.interceptors.CruciblePermissionInterceptor.intercept(CruciblePermissionInterceptor.java:52) at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190) {code}

    Atlassian JIRA | 5 years ago | Brendan Humphreys [Atlassian]
    sessionorg.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

    Root Cause Analysis

    1. sessionorg.hibernate.exception.ConstraintViolationException

      Could not execute JDBC batch update

      at org.hibernate.exception.SQLStateConverter.convert()
    2. Hibernate
      ActionQueue.executeActions
      1. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
      2. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      3. org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
      4. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
      5. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
      5 frames
    3. Hibernate
      SessionImpl.managedFlush
      1. org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
      2. org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
      3. org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
      4. org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
      4 frames
    4. Hibernate
      JDBCTransaction.commit
      1. org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
      1 frame
    5. com.cenqua.crucible
      HibernateUtil.commitTransaction
      1. com.cenqua.crucible.hibernate.SessionState.commit(SessionState.java:101)
      2. com.cenqua.crucible.hibernate.SessionState.commitTx(SessionState.java:67)
      3. com.cenqua.crucible.hibernate.HibernateUtil.commitTransaction(HibernateUtil.java:228)
      3 frames
    6. com.atlassian.fisheye
      DefaultRecentlyVisitedManager.addItemToHistory
      1. com.atlassian.fisheye.user.DefaultRecentlyVisitedManager.addItemToHistory(DefaultRecentlyVisitedManager.java:84)
      1 frame
    7. com.atlassian.crucible
      ReviewAction.execute
      1. com.atlassian.crucible.actions.ReviewAction.execute(ReviewAction.java:110)
      1 frame
    8. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    9. XWork Tiger Extensions
      DefaultActionInvocation.invoke
      1. com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:358)
      2. com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:218)
      3. com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:192)
      3 frames
    10. com.cenqua.crucible
      ReviewInterceptor.intercept
      1. com.cenqua.crucible.interceptors.ReviewInterceptor.intercept(ReviewInterceptor.java:51)
      1 frame
    11. XWork Tiger Extensions
      DefaultActionInvocation.invoke
      1. com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
      1 frame
    12. com.cenqua.crucible
      CruciblePermissionInterceptor.intercept
      1. com.cenqua.crucible.interceptors.CruciblePermissionInterceptor.intercept(CruciblePermissionInterceptor.java:52)
      1 frame
    13. XWork Tiger Extensions
      DefaultActionInvocation.invoke
      1. com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
      1 frame