com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.))

Atlassian JIRA | Brenden Bain [Atlassian] | 4 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    h1. Symptom Getting the following error when trying to view a profile page: {noformat} jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.)) com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.)) at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:379) at com.atlassian.jira.user.OfBizUserHistoryStore.addHistoryItemNoChecks(OfBizUserHistoryStore.java:104) at com.atlassian.jira.user.CachingUserHistoryStore$2.run(CachingUserHistoryStore.java:94) at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333) at com.atlassian.jira.user.CachingUserHistoryStore.addHistoryItem(CachingUserHistoryStore.java:84) at com.atlassian.jira.user.SessionBasedAnonymousUserHistoryStore$2.run(SessionBasedAnonymousUserHistoryStore.java:120) at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333) {noformat} h2. Cause If a user's name changes case and you are connected to a database that does case insensitive comparison (e.g. MSSQL 2008 as setup following the steps on https://confluence.atlassian.com/x/CpX2Cw). The most common way for a user's name to change is for it to change in an external user directory where case is important (e.g. some LDAP servers). h2. Steps * Setup JIRA to an LDAP directory. * Create a user with username "testuser" in the internal JIRA directory. * Login with username "testuser" * Go to the user's profile page. * Inside the LDAP directory, create a user "TestUser". * Move the LDAP directory to the top. * (BUG) Go to the current user's profile page. You will get the above exception.

    Atlassian JIRA | 4 years ago | Brenden Bain [Atlassian]
    com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.))
  2. 0

    h1. Symptom Getting the following error when trying to view a profile page: {noformat} jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.)) com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.)) at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:379) at com.atlassian.jira.user.OfBizUserHistoryStore.addHistoryItemNoChecks(OfBizUserHistoryStore.java:104) at com.atlassian.jira.user.CachingUserHistoryStore$2.run(CachingUserHistoryStore.java:94) at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333) at com.atlassian.jira.user.CachingUserHistoryStore.addHistoryItem(CachingUserHistoryStore.java:84) at com.atlassian.jira.user.SessionBasedAnonymousUserHistoryStore$2.run(SessionBasedAnonymousUserHistoryStore.java:120) at com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333) {noformat} h2. Cause If a user's name changes case and you are connected to a database that does case insensitive comparison (e.g. MSSQL 2008 as setup following the steps on https://confluence.atlassian.com/x/CpX2Cw). The most common way for a user's name to change is for it to change in an external user directory where case is important (e.g. some LDAP servers). h2. Steps * Setup JIRA to an LDAP directory. * Create a user with username "testuser" in the internal JIRA directory. * Login with username "testuser" * Go to the user's profile page. * Inside the LDAP directory, create a user "TestUser". * Move the LDAP directory to the top. * (BUG) Go to the current user's profile page. You will get the above exception.

    Atlassian JIRA | 4 years ago | Brenden Bain [Atlassian]
    com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.))

    Root Cause Analysis

    1. com.atlassian.jira.exception.DataAccessException

      org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:UserHistoryItem][id,10374][username,admin][data,null][entityId,admin][lastViewed,1350569188345][type,Assignee] (SQL Exception while executing the following:INSERT INTO jiraschema.userhistoryitem (ID, entitytype, entityid, USERNAME, lastviewed, data) VALUES (?, ?, ?, ?, ?, ?) (Cannot insert duplicate key row in object 'jiraschema.userhistoryitem' with unique index 'uh_type_user_entity'.))

      at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue()
    2. com.atlassian.jira
      CachingUserHistoryStore$2.run
      1. com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:379)
      2. com.atlassian.jira.user.OfBizUserHistoryStore.addHistoryItemNoChecks(OfBizUserHistoryStore.java:104)
      3. com.atlassian.jira.user.CachingUserHistoryStore$2.run(CachingUserHistoryStore.java:94)
      3 frames
    3. com.atlassian.util
      ManagedLocks$ManagedLockImpl.withLock
      1. com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333)
      1 frame
    4. com.atlassian.jira
      SessionBasedAnonymousUserHistoryStore$2.run
      1. com.atlassian.jira.user.CachingUserHistoryStore.addHistoryItem(CachingUserHistoryStore.java:84)
      2. com.atlassian.jira.user.SessionBasedAnonymousUserHistoryStore$2.run(SessionBasedAnonymousUserHistoryStore.java:120)
      2 frames
    5. com.atlassian.util
      ManagedLocks$ManagedLockImpl.withLock
      1. com.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:333)
      1 frame