Issue Overview:
We are encountering a sporadic issue where the DHIS2 API returns incomplete usergroup lists for users (in the api/users/x endpoint), while the api/usergroups endpoint shows the correct list of users.
This is critical as it affects user access to resources.
Detailed explanation:
Most usergroups disappear from users, but the api/usergroups endpoint still shows the correct users within the groups.
For example, a user (e.g., exampleuserid) may lose the exampleusergroupid in the user.userGroup list, but when checking /api/userGroups/exampleusergroupid, we still find the user in the group.
We’ve been monitoring the issue, and while logs don’t reveal much, we’ve noticed a common pattern: a ‘Hibernate caches cleared’ message appears before the issue, typically after users import metadata (e.g., creating a dashboard). This may be coincidental and unrelated to the usergroup loss.
In one case, a user with 135 usergroups only had 3 groups displayed in the api/users/x endpoint, and it seems the same groups are consistently missing.
A browser cache issue is discarded.
Suspected Cause:
We suspect the issue is related to Hibernate cache not updating correctly, causing incomplete usergroup lists. Since restarting the instance or clearing the cache resolves the issue without data loss, we believe it’s tied to how the cache handles user-usergroup associations.
Temporary solution:
Currently, we resolve this by restarting DHIS2 or clearing the cache via Data Administration → Maintenance.
We plan to implement a script to reset the cache automatically when the error happears, but this isn’t ideal. We’d like to understand the root cause and whether adding more logs related to Hibernate could help (ideally logging these separately to reduce noise).
Additional Details:
We have over 3,000 users and around 350 usergroups, with some users belonging to as many as 135 groups.
Some of the usergroups that are failing has around 2200 users inside.
System Information:
org.apache.catalina.startup.VersionLoggerListener.log Server version name: Apache Tomcat/9.0.70
org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
org.apache.catalina.startup.VersionLoggerListener.log Java Home: /usr/lib/jvm/java-11-openjdk-11.0.21.0.9-2.el9.x86_64
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xmx23000m
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Xms4000m
Postgresql version 14
dhis2 version: 2.38.7 (we will migrate in the next months to 2.41, but we need a workaround to fix this problem and know if this could still happens in 2.41).
We have created a jira issue [DHIS2-18071] - Jira
, but since maintenance for version 2.38.7 is no longer available, perhaps this is the right place to discuss it.