User directory in Bitbucket Data Center does not synchronize
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Summary
The User Directory in Bitbucket Data Center is not synchronized. Even after you click Synchronize from the user directories page and the page refreshes, the last synchronized timestamp remains unchanged, and the changes from the external directory are also not fetched.
Environment
Bitbucket Data Center 8.19.0, but may apply to other versions.
Diagnosis
Check for stalled synchronizations in the database
The output of the SQL query below suggests that the update queries are stalled in the database.
The following query is compatible with PostgreSQL. If you are using a different database engine, please modify the query to match that database's syntax.
user1=# SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM
pg_stat_activity
WHERE
state = 'active'
AND now() - pg_stat_activity.query_start > interval '5 minutes'
ORDER BY
duration DESC;
EXAMPLE OUTPUT
pid | duration | query | state
-----+-----------------+-----------------------------------------------------------------------------------+--------
33 | 00:34:19.222002 | update bb_clusteredjob set next_run=$1, version=$2 where job_id=$3 and version=$4 | active
35 | 00:33:48.242739 | update bb_clusteredjob set next_run=$1, version=$2 where job_id=$3 and version=$4 | active
36 | 00:32:48.22937 | update bb_clusteredjob set next_run=$1, version=$2 where job_id=$3 and version=$4 | active
37 | 00:31:48.222724 | update bb_clusteredjob set next_run=$1, version=$2 where job_id=$3 and version=$4 | active
(4 rows)In our example, there are multiple update bb_clusteredjob processes that are active. These are stalled, preventing updates to the directory.
Cause
The atlassian-bitbucket.log will record events indicating that the sync request has been received when the user clicks the synchronize button. However, it will not contain any events indicating whether the synchronization is in progress, has failed, or has succeeded.
2025-08-25 13:26:31,452 INFO [http-nio-7990-exec-2 url: /plugins/servlet/embedded-crowd/directories/sync; user: user1] user1 @11CNUZGx814x1761x0 1c05kvv 10.255.11.2 "POST /plugins/servlet/embedded-crowd/directories/sync HTTP/1.1" c.a.c.e.a.list.DirectoriesController User directory synchronisation requested: [ LDAP server ], type: [ CONNECTOR ]
2025-08-25 13:26:31,485 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.i18n.PluginI18nService No values found in any valid locale for key dashboard.name and locales [en_US, en]
2025-08-25 13:26:31,486 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.i18n.PluginI18nService No values found in any valid locale for key administration.name and locales [en_US, en]
2025-08-25 13:26:31,487 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.i18n.PluginI18nService No values found in any valid locale for key embedded.crowd.directory.configure.alt and locales [en_US, en]
2025-08-25 13:26:31,519 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.c.HazelcastClusterService Querying all nodes for status
2025-08-25 13:26:31,520 DEBUG [hz.hazelcast.cached.thread-4] c.a.s.i.c.HazelcastClusterService Received query for state; returning RUNNING
2025-08-25 13:26:31,520 DEBUG [hz.hazelcast.async.thread-1] c.a.s.i.c.HazelcastClusterService$NodeStatusCallback Success executing on Member [10.255.0.1]:5701 - 07c3d92f-3b63-47b3-9e73-db51d17ac970 this. Result: RUNNING
2025-08-25 13:26:31,520 DEBUG [hz.hazelcast.async.thread-1] c.a.s.i.c.HazelcastClusterService Received status of RUNNING for 07c3d92f-3b63-47b3-9e73-db51d17ac970 listening on /10.255.0.1:5701
2025-08-25 13:26:31,521 DEBUG [hz.hazelcast.async.thread-1] c.a.s.i.c.HazelcastClusterService$NodeStatusCallback Execution complete. Successful - true
2025-08-25 13:26:31,521 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.c.HazelcastClusterService Node status query complete
2025-08-25 13:26:31,528 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.c.HazelcastClusterService Querying all nodes for status
2025-08-25 13:26:31,528 DEBUG [hz.hazelcast.cached.thread-4] c.a.s.i.c.HazelcastClusterService Received query for state; returning RUNNING
2025-08-25 13:26:31,528 DEBUG [hz.hazelcast.async.thread-2] c.a.s.i.c.HazelcastClusterService$NodeStatusCallback Success executing on Member [10.255.0.1]:5701 - 07c3d92f-3b63-47b3-9e73-db51d17ac970 this. Result: RUNNING
2025-08-25 13:26:31,528 DEBUG [hz.hazelcast.async.thread-2] c.a.s.i.c.HazelcastClusterService Received status of RUNNING for 07c3d92f-3b63-47b3-9e73-db51d17ac970 listening on /10.255.0.1:5701
2025-08-25 13:26:31,528 DEBUG [hz.hazelcast.async.thread-2] c.a.s.i.c.HazelcastClusterService$NodeStatusCallback Execution complete. Successful - true
2025-08-25 13:26:31,528 DEBUG [http-nio-7990-exec-10 url: /plugins/servlet/embedded-crowd/directories/list; user: user1] user1 @11CNUZGx814x1762x0 1c05kvv 10.255.11.2 "GET /plugins/servlet/embedded-crowd/directories/list HTTP/1.1" c.a.s.i.c.HazelcastClusterService Node status query complete
2025-08-25 13:26:31,618 DEBUG [http-nio-7990-exec-7 url: /rest/api/latest/inbox/pull-requests/count; user: user1] user1 @11CNUZGx814x1764x0 1c05kvv 10.255.11.2 "GET /rest/api/latest/inbox/pull-requests/count HTTP/1.1" c.a.s.i.rest.inbox.InboxResource Retrieving pull request count for user user1Generate thread dump
Please refer to the Generate a Thread Dump Externally article for the relevant procedure to capture thread dumps.
When reviewing the thread dumps, all four Caesium threads(by default, 4 threads) seem to be stuck with the following stack trace. This trace suggests that Bitbucket is waiting for a response from the database. After receiving the sync request, Bitbucket attempts to update details in the bb_clusteredjob table, among others. If the database doesn’t let these update queries execute for any reason, the directory synchronization will not initiate.
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:171)
java.net.SocketInputStream.read(SocketInputStream.java:141)
org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:161)
org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:128)
org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:113)
org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
org.postgresql.core.PGStream.receiveChar(PGStream.java:465)
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155)
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368)
org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498)
org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415)
org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:190)
org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:152)
com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
org.hibernate.hql.internal.ast.exec.BasicExecutor.doExecute(BasicExecutor.java:80)
org.hibernate.hql.internal.ast.exec.BasicExecutor.execute(BasicExecutor.java:50)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:458)
org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:377)
org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1483)
org.hibernate.query.internal.AbstractProducedQuery.doExecuteUpdate(AbstractProducedQuery.java:1714)
org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1696)
com.atlassian.stash.internal.scheduling.HibernateClusteredJobDao.lambda$updateNextRunTime$8(HibernateClusteredJobDao.java:145)
com.atlassian.stash.internal.scheduling.HibernateClusteredJobDao$$Lambda$1249/1418296717.doInTransaction(Unknown Source)
org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:140)
com.atlassian.stash.internal.scheduling.HibernateClusteredJobDao.updateNextRunTime(HibernateClusteredJobDao.java:138)
sun.reflect.GeneratedMethodAccessor415.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:89)
com.atlassian.stash.internal.aop.ProfilingAspect.profileMethod(ProfilingAspect.java:36)
sun.reflect.GeneratedMethodAccessor173.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:241)
com.sun.proxy.$Proxy274.updateNextRunTime(Unknown Source)
com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJob(CaesiumSchedulerService.java:423)
com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJobWithRecoveryGuard(CaesiumSchedulerService.java:454)
com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(CaesiumSchedulerService.java:382)
com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$$Lambda$1235/1894328236.accept(Unknown Source)
com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(SchedulerQueueWorker.java:66)
com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(SchedulerQueueWorker.java:60)
com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.run(SchedulerQueueWorker.java:35)
java.lang.Thread.run(Thread.java:750)Solution
Clear stuck processes and/or restart
Shut down the Bitbucket application, terminate the stalled 'update bb_clusteredjob' queries or restart the database, and then restart Bitbucket. After the stalled queries are cleared, Bitbucket will begin synchronizing the user directories incrementally or upon receiving manual requests.
Was this helpful?