KEYCLOAK-18518 Add expiration lifespan configuration to every distributed and replicated cache

This commit is contained in:
vramik 2021-06-28 13:57:46 +02:00 committed by Hynek Mlnařík
parent f3a96b9da9
commit 333f77a039
5 changed files with 154 additions and 16 deletions

View file

@ -757,4 +757,48 @@ if (outcome == failed) of /profile=$clusteredProfile/subsystem=infinispan/cache-
echo echo
end-if end-if
# Migrate from 14.0.0 to 15.0.0
# Add expiration lifespan configuration to every distributed and replicated cache.
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/replicated-cache=work/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'work' replicated-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/replicated-cache=work/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'sessions' replicated-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'clientSessions' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'offlineSessions' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'offlineClientSessions' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'authenticationSessions' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'loginFailures' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'actionTokens' distributed-cache
/profile=$clusteredProfile/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
echo *** End Migration of /profile=$clusteredProfile *** echo *** End Migration of /profile=$clusteredProfile ***

View file

@ -888,4 +888,48 @@ if (outcome == success) && (result == "") of /subsystem=jpa:read-attribute(name=
echo echo
end-if end-if
# Migrate from 14.0.0 to 15.0.0
# Add expiration lifespan configuration to every distributed and replicated cache.
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/replicated-cache=work/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'work' replicated-cache
/subsystem=infinispan/cache-container=keycloak/replicated-cache=work/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'sessions' replicated-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=sessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'clientSessions' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=clientSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'offlineSessions' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'offlineClientSessions' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=offlineClientSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'authenticationSessions' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=authenticationSessions/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'loginFailures' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=loginFailures/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
if (result == undefined) of /subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens/component=expiration/:read-attribute(name=lifespan)
echo Setting expiration lifespan for 'actionTokens' distributed-cache
/subsystem=infinispan/cache-container=keycloak/distributed-cache=actionTokens/component=expiration/:write-attribute(name=lifespan,value=900000000000000000)
echo
end-if
echo *** End Migration *** echo *** End Migration ***

View file

@ -22,26 +22,44 @@
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="sessions"/> <param name="distributed-cache" value="sessions"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="authenticationSessions"/> <param name="distributed-cache" value="authenticationSessions"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="offlineSessions"/> <param name="distributed-cache" value="offlineSessions"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="clientSessions"/> <param name="distributed-cache" value="clientSessions"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="offlineClientSessions"/> <param name="distributed-cache" value="offlineClientSessions"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.distributed-cache"> <feature spec="subsystem.infinispan.cache-container.distributed-cache">
<param name="distributed-cache" value="loginFailures"/> <param name="distributed-cache" value="loginFailures"/>
<param name="owners" value="1"/> <param name="owners" value="1"/>
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.local-cache"> <feature spec="subsystem.infinispan.cache-container.local-cache">
<param name="local-cache" value="authorization"/> <param name="local-cache" value="authorization"/>
@ -51,6 +69,9 @@
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.replicated-cache"> <feature spec="subsystem.infinispan.cache-container.replicated-cache">
<param name="replicated-cache" value="work"/> <param name="replicated-cache" value="work"/>
<feature spec="subsystem.infinispan.cache-container.replicated-cache.component.expiration">
<param name="lifespan" value="900000000000000000"/>
</feature>
</feature> </feature>
<feature spec="subsystem.infinispan.cache-container.local-cache"> <feature spec="subsystem.infinispan.cache-container.local-cache">
<param name="local-cache" value="keys"/> <param name="local-cache" value="keys"/>
@ -70,6 +91,7 @@
<feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration"> <feature spec="subsystem.infinispan.cache-container.distributed-cache.component.expiration">
<param name="max-idle" value="-1"/> <param name="max-idle" value="-1"/>
<param name="interval" value="300000"/> <param name="interval" value="300000"/>
<param name="lifespan" value="900000000000000000"/>
</feature> </feature>
</feature> </feature>
</feature> </feature>

View file

@ -37,12 +37,24 @@
</encoding> </encoding>
<memory storage="HEAP" max-count="10000"/> <memory storage="HEAP" max-count="10000"/>
</local-cache> </local-cache>
<distributed-cache name="sessions" owners="1"/> <distributed-cache name="sessions" owners="1">
<distributed-cache name="authenticationSessions" owners="1"/> <expiration lifespan="900000000000000000"/>
<distributed-cache name="offlineSessions" owners="1"/> </distributed-cache>
<distributed-cache name="clientSessions" owners="1"/> <distributed-cache name="authenticationSessions" owners="1">
<distributed-cache name="offlineClientSessions" owners="1"/> <expiration lifespan="900000000000000000"/>
<distributed-cache name="loginFailures" owners="1"/> </distributed-cache>
<distributed-cache name="offlineSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="clientSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="offlineClientSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="loginFailures" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<local-cache name="authorization"> <local-cache name="authorization">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
@ -50,7 +62,9 @@
</encoding> </encoding>
<memory storage="HEAP" max-count="10000"/> <memory storage="HEAP" max-count="10000"/>
</local-cache> </local-cache>
<replicated-cache name="work"/> <replicated-cache name="work">
<expiration lifespan="900000000000000000"/>
</replicated-cache>
<local-cache name="keys"> <local-cache name="keys">
<encoding> <encoding>
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
@ -64,7 +78,7 @@
<key media-type="application/x-java-object"/> <key media-type="application/x-java-object"/>
<value media-type="application/x-java-object"/> <value media-type="application/x-java-object"/>
</encoding> </encoding>
<expiration max-idle="-1" interval="300000"/> <expiration max-idle="-1" lifespan="900000000000000000" interval="300000"/>
<memory storage="HEAP" max-count="-1"/> <memory storage="HEAP" max-count="-1"/>
</distributed-cache> </distributed-cache>
</cache-container> </cache-container>

View file

@ -96,23 +96,37 @@
<local-cache name="users"> <local-cache name="users">
<heap-memory size="10000"/> <heap-memory size="10000"/>
</local-cache> </local-cache>
<distributed-cache name="sessions" owners="1"/> <distributed-cache name="sessions" owners="1">
<distributed-cache name="authenticationSessions" owners="1"/> <expiration lifespan="900000000000000000"/>
<distributed-cache name="offlineSessions" owners="1"/> </distributed-cache>
<distributed-cache name="clientSessions" owners="1"/> <distributed-cache name="authenticationSessions" owners="1">
<distributed-cache name="offlineClientSessions" owners="1"/> <expiration lifespan="900000000000000000"/>
<distributed-cache name="loginFailures" owners="1"/> </distributed-cache>
<distributed-cache name="offlineSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="clientSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="offlineClientSessions" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<distributed-cache name="loginFailures" owners="1">
<expiration lifespan="900000000000000000"/>
</distributed-cache>
<local-cache name="authorization"> <local-cache name="authorization">
<heap-memory size="10000"/> <heap-memory size="10000"/>
</local-cache> </local-cache>
<replicated-cache name="work"/> <replicated-cache name="work">
<expiration lifespan="900000000000000000"/>
</replicated-cache>
<local-cache name="keys"> <local-cache name="keys">
<heap-memory size="1000"/> <heap-memory size="1000"/>
<expiration max-idle="3600000"/> <expiration max-idle="3600000"/>
</local-cache> </local-cache>
<distributed-cache name="actionTokens" owners="2"> <distributed-cache name="actionTokens" owners="2">
<heap-memory size="-1"/> <heap-memory size="-1"/>
<expiration max-idle="-1" interval="300000"/> <expiration max-idle="-1" lifespan="900000000000000000" interval="300000"/>
</distributed-cache> </distributed-cache>
</cache-container> </cache-container>
<cache-container name="server" aliases="singleton cluster" default-cache="default" modules="org.wildfly.clustering.server"> <cache-container name="server" aliases="singleton cluster" default-cache="default" modules="org.wildfly.clustering.server">