[keycloak-dev] jta, emf, db migration
Bill Burke
bburke at redhat.com
Wed Sep 7 10:52:13 EDT 2016
Currently there is some issues with master since I added JTA
transactions to the mix
* KeycloakDS datasource config now requires jta=false. This breaks
backward compatibility and has migration issues. This was done because
both RESOURCE_LOCAL EntityManagers and Liquibase (using raw JDBC) cannot
function within a JTA transaction.
* Our EntityManager implementation is not controlled by JTA. This is not
great as the db connection cannot be involved with XA, especially if
another external transaction resource is involved when doing events
and/or user federation.
To do this I had to do some things that may be a little weird.
* Entity Manager is now JTA managed if JTA exists in the environment
keycloak is running in. The side effect of this is that all
interactions with the EntityManager need to happen within a JTA
transaction (or you get an exception).
* jta=false is reverted in server distribution
* All DBLock and Liquibase operations now suspend any existing JTA
transaction before executing. You cannot call commit/rollback on a JDBC
connection if you are getting a connection from a JTA aware db
connection pool and there is a JTA connection active. DBLock calls a
rollback() for some reason...if running in JTA, this marks the
connection as rolled back and you can't use the connection after that.
So basically for DBLock and Liquibase there's a lot of issues with
running inside a JTA transaction.
Honestly, this code can and should be refactored into different
providers (i.e. a DBMigrationProvider), but I've got so many other
things I need to refactor right now I'm going to put this on the back
burner.
Bill
More information about the keycloak-dev
mailing list