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

Getting 'duplicate key' database error when trying to look at a user's profile page.

XMLWordPrintable

      Symptom

      Getting the following error when trying to view a profile page:

      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)
      

      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).

      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.

              bbain bain
              bbain bain
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: