Create Infinispan caches/schemas again when Infinispan server killed #38877
-
ContextI have a Quarkus app (multiple pods) deployed on Kubernetes and a shared cache in a single Infinispan server (with the Infinispan operator) in the same namespace. The cache schemas are handled by code using Kubernetes pods:
ProblemSometimes, the Infinispan server pod might be killed for whatever reasons. When this happens, another Infinispan server pod is started, but Quarkus can't use it because it has no schemas/caches. My app handle this so it's not broken but my response times are slower as caching doesn't work anymore. After the new instance is created, my caches/schemas are not recreated because Quarkus didn't start, it was already running. SolutionsI would like to fix it automatically. What is the recommended way to do this? Do you know how people handle this? Here's some solutions I thought of:
Reproducerhttps://github.com/jdussouillez/quarkus-infinispan-cache-reset TLDR: What is the best way to recreate Infinispan caches/schemas after the server was killed, if possible from the Quarkus app itself without restarting it, and without persisting all cached data in a database/filesystem? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
You can register the schema again in case you've lost it on a server reboot. The schema needs to be uploaded to the server, this is done with the remote cache manager. However, the API is not great now but we are providing good changes for 15. I'm going to create a new issue to try to cover this case, so you don't need to handle it yourself. Another option is, if you are using the Infinispan Operator, pass the schema to the server so it's created on startup. The downside of this is that you need to sync the schemas for each release, disabling the "upload" from the app. This is a good option if your schema tends to be stable enough. |
Beta Was this translation helpful? Give feedback.
-
@wburns or any other core team member might have additional ideas on this. I've just ping them in our chat |
Beta Was this translation helpful? Give feedback.
-
@jdussouillez Schemas should survive server restarts. Can you share your Infinispan CR definition? |
Beta Was this translation helpful? Give feedback.
Hi @jdussouillez
You can register the schema again in case you've lost it on a server reboot. The schema needs to be uploaded to the server, this is done with the remote cache manager. However, the API is not great now but we are providing good changes for 15.
https://github.com/infinispan/infinispan-simple-tutorials/blob/main/infinispan-remote/query/src/main/java/org/infinispan/tutorial/simple/remote/query/InfinispanRemoteQuery.java#L46
I'm going to create a new issue to try to cover this case, so you don't need to handle it yourself.
Another option is, if you are using the Infinispan Operator, pass the schema to the server so it's created on startup. The downside of this is that you nee…