Optimize deletion of composite roles#45490
Conversation
b68d242 to
30e3676
Compare
|
@mposolda / @vmuzikar / @mabartos - I think the performance of this eroded in multiple changes, and the final killing bit was then the I've now made Can you please have a comment on this approach? I also had a challenge to flush the role in the right moment as Hibernate now doesn't know about the relation between CompositeRoleEntity and RoleEntity ... AFAIK I can't use RoleEntity as a primary key in ComposeRoleEntity. Thanks! |
Closes keycloak#45065 Signed-off-by: Alexander Schwartz <[email protected]>
30e3676 to
b5538e3
Compare
Signed-off-by: Alexander Schwartz <[email protected]>
cb7d2aa to
8c583a8
Compare
Signed-off-by: Alexander Schwartz <[email protected]>
95d00c4 to
218089f
Compare
|
@pedroigor - it should now be ready for the final review. Thanks! |
| private final String parentId; | ||
| private final LazyLoader<GroupModel, MultivaluedHashMap<String, String>> attributes; | ||
| private final LazyLoader<GroupModel, Set<String>> roleMappings; | ||
| private Set<String> cachedRoleMappings = new HashSet<>(); |
There was a problem hiding this comment.
Isn't enough to rely on roleMappings? Caching is implicit when using a LazyLoader.
| } | ||
|
|
||
| public Set<String> getCachedRoleMappings() { | ||
| return cachedRoleMappings; |
There was a problem hiding this comment.
Is it expected to eventually return an empty set if getRoleMappings wasn't called before?
There was a problem hiding this comment.
For getCachedRoleMappings() yes - this is the contract. I'll add some more javadoc for this.
Signed-off-by: Alexander Schwartz <[email protected]>
|
Hi @ahus1, thanks for updating the initial related PR. It looks to me that switching from an id-oriented relation table (no entity here, so Hibernate has no clue) to an entity-oriented one (there Hibernate includes it in its entities relationship graph) like you did will allow proper low-scale join selects but will actually be detrimental to the other parts of Hibernate performance, which is the dirty checking bit when looking at large scale selects: you may have a very large number of entities in Hibernate's session cache to dirty check at flush time... My 0.02 €. |
|
@davoustp - thank you, noted. Yes, there will be more entities in the context when updating entities. When reading the composite roles for a roles with |
Closes #45065
With this change and ~1000 clients, a delete is fast again, and should complete within 100ms with a local database running PostgreSQL: