Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
ldap
Bug Description
When configuring an LDAP User Federation provider with a group-ldap-mapper, setting Batch Size for Sync to 0 causes group synchronization to enter an infinite loop.
The synchronization process does not make progress and eventually triggers transaction timeouts.
The issue was observed with Keycloak 26.8.2 using Samba Active Directory over LDAPS.
Version
26.8.2
Regression
- The issue is a regression
Expected behavior
Keycloak should handle a batch size of 0 safely.
If zero is not a supported value, the configuration should be rejected with a clear validation error instead of allowing synchronization to enter an infinite loop.
Actual behavior
When Batch Size for Sync is set to 0, LDAP group synchronization does not make progress and enters an infinite loop.
The transaction manager eventually detects long-running transactions and cancels them. This results in transaction rollback errors and Hibernate exceptions.
The issue prevents the group mapper synchronization from completing successfully.
How to Reproduce?
- Start Keycloak 26.8.2.
- Configure an LDAP User Federation provider connected to an Active Directory server.
- Configure a group-ldap-mapper for the LDAP provider.
- Set the LDAP provider's Batch Size for Sync to 0.
- Trigger synchronization of the LDAP group mapper.
- Observe that synchronization does not complete and transaction timeouts eventually occur.
Tested environment:
- Keycloak: 26.8.2
- LDAP vendor: Active Directory (Samba AD)
- Connection: LDAPS
- Mapper: group-ldap-mapper
- Mode: READ_ONLY
- User Groups Retrieve Strategy: GET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE
Anything else?
Workaround
Setting the LDAP provider's Batch Size for Sync to 100 resolves the issue in our environment.
Technical investigation
The issue appears to originate in GroupLDAPStorageMapper.java, specifically in syncFlatGroupStructure().
The outer iterator loop checks whether more groups are available, while iterator advancement occurs inside an inner loop controlled by groupsPerTransaction.
When groupsPerTransaction is 0, the inner loop never executes and the iterator is never advanced. Consequently, the outer loop cannot terminate.
Relevant source code (Keycloak 26.8.2):
Transaction manager and Hibernate logs
The following messages were observed during synchronization:
ARJUNA012117: TransactionReaper::check processing TX ... in state RUN
ARJUNA012404: Action id ... had stackTrace
...
GroupLDAPStorageMapper.syncFlatGroupStructure(GroupLDAPStorageMapper.java:266)
GroupLDAPStorageMapper.syncDataFromFederationProviderToKeycloak(GroupLDAPStorageMapper.java:191)
UserStorageProviderResource.syncMapperData(UserStorageProviderResource.java:259)
HHH90007020: Transaction afterCompletion called by a background thread;
delaying afterCompletion processing until the original thread can handle it.
ARJUNA012095: Abort of action invoked while multiple threads active within it.
ARJUNA012108: CheckedAction::check - atomic action aborting with 1 threads active!
ARJUNA012121: TransactionReaper::doCancellations worker successfully canceled TXAfter Keycloak shutdown, additional Hibernate errors appeared:
org.hibernate.HibernateException:
Transaction was rolled back in a different threadThe associated exception was raised while closing the JPA connection provider:
org.keycloak.connections.jpa.DefaultJpaConnectionProvider.close
org.keycloak.services.DefaultKeycloakSession.closeThese Hibernate exceptions appear to be consequences of the transaction being rolled back by the Transaction Reaper in another thread, rather than the original cause of the synchronization failure.
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsOpen
Activity
tkyjovsk commentedon Nov 23, 2026
The
26.8.2code supports the reported cause: with batch size zero, flat group synchronization never advances its iterator when LDAP groups are present. (Also affects26.4so it's not a recent regression; and the currentmain.)PR #55334 addresses the problem and includes a reported reproduction against ApacheDS. Zero already selects non-paginated loading elsewhere in the LDAP implementation, I'd say it makes sense to go with the same behavior for consistency.
keycloak-github-bot commentedon Nov 23, 2026
Due to the amount of issues reported by the community we are not able to prioritise resolving this issue at the moment.
If you are affected by this issue, upvote it by adding a 👍 to the description. We would also welcome a contribution to fix the issue.
Do not loop forever on LDAP group sync when the batch size for sync is 0
Add a timeout assertion to `LDAPGroupMapperSyncTest.test09_flatSynchW…