There is bug with clear() and batching together. I opened a JIRA for the issue: [ISPN-8494] Clear is leaking transaction with Batching - JBoss Issue Tracker .
It should be fixed in the next release. For now, I advice you to move the clear outside the batching or, if you need it inside the batching, execute in another thread like:
Thanks for your help.
Thanks for the suggestion and the link to the bug!
What happen to the startBatch transaction in case the cache.clear executed by CompletableFuture fails?
Or what if some other actions executed in the startBatch are failing? The cache.clear will be committed anyway?
The clear() is isolated from the batch. So, if it fails, it doesn't fails the batch. If another operation in batch fails, the clear() is still committed.
Note that the clear() is committed when it executes and not when the batch ends!
I imagined, thanks for the confirmation, but at this point is not very different from having the cache.clear outside the batch..
Thanks for your help anyway!