Because of Arjuna timeout / closing the connection after 5 mins, setting following additional JAVA_OPTS
might help:
-Dquarkus.transaction-manager.default-transaction-timeout=3600
-Dkeycloak.migration.batch-enabled=true
-Dkeycloak.migration.batch-size=1000
I also added the below instructions to ensure only one thread running migration and avoid problems with race condition and infinispan (see the issue keycloak/keycloak#34267 for more details)