Incremental synchronisation failed due to cache returned different number of guids and users

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

LDAP incremental synchronization fails and thrown an exception in the JIRA log.

The following appears in the atlassian-jira.log

2015-06-24 05:11:48,382 atlassian-scheduler-quartz1.clustered_Worker-4 ERROR ServiceRunner     [atlassian.crowd.directory.DbCachingRemoteDirectory] Incremental synchronisation for directory [ 10200 ] was unexpectedly interrupted, falling back to a full synchronisation
com.atlassian.crowd.directory.ldap.cache.UsnChangedCacheRefresherIncSyncException: Cache returned different number of guids and users (possible reason is overlapping guids in cache, most likely null/empty values).
        at com.atlassian.crowd.directory.ldap.cache.UsnChangedCacheRefresher.validateAndReturnGuidsToAddAndDelete(UsnChangedCacheRefresher.java:287)
        at com.atlassian.crowd.directory.ldap.cache.UsnChangedCacheRefresher.synchroniseUserChangesGuid(UsnChangedCacheRefresher.java:320)
        at com.atlassian.crowd.directory.ldap.cache.UsnChangedCacheRefresher.synchroniseUserChanges(UsnChangedCacheRefresher.java:381)
        at com.atlassian.crowd.directory.ldap.cache.UsnChangedCacheRefresher.synchroniseChanges(UsnChangedCacheRefresher.java:124)
        at com.atlassian.crowd.directory.DbCachingRemoteDirectory.synchroniseCache(DbCachingRemoteDirectory.java:1097)
        at com.atlassian.crowd.manager.directory.DirectorySynchroniserImpl.synchronise(DirectorySynchroniserImpl.java:76)
        at com.atlassian.jira.crowd.embedded.JiraDirectorySynchroniser.synchronizeDirectory(JiraDirectorySynchroniser.java:96)
        at com.atlassian.jira.crowd.embedded.JiraDirectorySynchroniser.runJob(JiraDirectorySynchroniser.java:60)
        at com.atlassian.scheduler.core.JobLauncher.runJob(JobLauncher.java:136)
        at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(JobLauncher.java:101)
        at com.atlassian.scheduler.core.JobLauncher.launch(JobLauncher.java:80)
        at com.atlassian.scheduler.quartz1.Quartz1Job.execute(Quartz1Job.java:32)
        at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
        at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)

Diagnosis

Environment

  • Active Directory 2008
  • JIRA 6.4.x

Diagnostic Steps

  • Run the SQL query below in database to identify the inconsistent records:

    SELECT id, user_name, directory_id, external_id FROM cwd_user
    WHERE (external_id IN (SELECT external_id FROM cwd_user WHERE directory_id = '<user_directory_id>' GROUP BY external_id HAVING count(external_id) > 1) OR external_id IS NULL)
    AND directory_id = '<user_directory_id>';

    (info)<user_directory_id> can be found in the cwd_directory table. 

  • Please check the following before proceeding on the workaround:

    • There is result gotten from above query
    • Crosscheck from the result and verify the user does not exist on your external directory, then only proceed to workaround
  • IF after performing crosscheck, you notice that the result gotten leads to users that exist in external directory, contact Support for further investigation

Cause

  • The number of users in JIRA does not match with the number of GUIDs (External IDs) of the users in AD.
  • Some users has a NULL value in the External ID columns from the cwd_user table.

Workaround

The workaround will be inserting some dummy entries to the external id in cwd_user table to bypass the exception.

  1. Stop JIRA.

    Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  2. Run the SQL command below:

    UPDATE cwd_user SET external_id = '<user_name>' WHERE id = <id>;
    

    (info) Replace <user_name> and <id> from the SQL output in Diagnostic Steps.

  3. Restart JIRA.

Last modified on Jun 21, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.