-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
None
Using infinispan in Keycloak 24.0.5 (infinispan version
14.0.28.Final) leads to exceptions during purging:
* After the batchUpdate in the current transaction notifications are sent which lead to deleteFromAllStores -> this seams to lead to deletes on a separate connection and therefore a locking situation.
* the purgeExpired is ended using rollback of the transaction which is commented by postgres as connection already closed (this seams to be a consequence of the locktimeout handling)
* purgeExpired never gets called anymore after this error.
* our db admins tell us that there are idle connections with open transactions left
* agroal leak detection tells after some time, that connection leaks are occurring
* I tried to reproduce that using H2, it was not possible for me
I will provide the Stacktraces below: I assume, that you would like some code which might allow you to reproduce the problem.
I gladly will try to provide that, but I fear, that it will only work using Postgres, please tell me how you would like this to be handled.
Generally I am not happy how purgeExpired is currently implemented
* it opens a cursor to an indefinite number of entries
* it tries to delete these entries during walking along the cursor, This looks to me like walking a bridge and removing the pillars holding the bridge. I am quite convinced that not all SQL databases do support that
* The transaction size is not limited. imO. this is unnecessary here
* is it really necessary to send notifications during the transaction where it is not completely clear if a distributed transaction situation might occur?
Assuming, that a solution will not be done as soon as we need it, I created a workaround which subclasses JdbcStringBasedStore. I would gladly provide the code if anybody might be interested in it.
Nevertheless the loss of the scheduled task in case of errors I am currently not fixing.
I will add stacktrace, infinispan-config and quarkus-db-config as attachments.stacktraces.txt