KC startups longer then default JBoss 5 min timeout and got rolled back,
~300 security realms created.
From jstack, I see application is busy with multiple queries initiated
all realms fetch
Sequence is following:
1. KeycloakApplication.setupScheduledTasks is called on bootstrap
2. All realms are fetched inside UserStorageSyncManager#bootstrapPeriodic
3. During each realm fetch, RealmEntity is wrapped to CachedRealm by
4. In CachedRealm constructor, it reads all RealmEntity collections
5. Sql selects fired for all RealmEntity collections
(RealmAttributeEntity, AuthenticationFlowEntity, RequiredCredentialEntity,
I see there was optimization to fetch only realms with user storages:
. This didn't help me because
I have user federation provider in each realm.
Also I see hibernate 1st level cache clear was advised here:
. This also did not help,
probably because too much data is being read.
I suggest to modify realm-extraction code at
UserStorageSyncManager#bootstrapPeriodic so it will select only required
info from DB. I am ready to develop this change, what do you think about it?