Hi,
We are trying to use JTA transaction in our project.
But it seems when using JTA transaction, tracking processors can’t fetch the token from tokenstore.
The problem is JdbcTokenStore trying to commit the connection while fetching token(I know it has to be commited otherwise token won’t be locked):
TrackingToken result = loadOrInsertToken(resultSet, processorName, segment);
if (!connection.getAutoCommit()) {
connection.commit();
}
Then it’ll trigger “com.atomikos.jdbc.AtomikosSQLException: Cannot call method ‘commit’ while a global transaction is running”
Is there any solution for this problem?
it does look like the combination of an aggressive commit() by the JdbcTokenStore and the lack of “blocking” of this call in the NoOpCloseHandler will cause a transaction to be committed, even when a UnitOfWorkAwareConnectionProviderWrapper is used. We will investigate whether it is desirable to block calls to commit until the Unit of Work completes.
However, there is a solution that will definitely work in your case. Since you’re using an explicit transaction manager, you could return a connection that blocks “external” calls to commit, while configuring the transaction manager to commit the underlying transaction directly when the transaction manager wants to commit.
When tracking processor tries to acquire a token, it has to write tokenentry table and commit, and this was done in another started transaction, so it got the “AtomikosSQLException: Cannot call method ‘commit’ while a global transaction is running”.
To fix this, I think either tracking processor tries to acquire token before the transaction started, or it commits in its own transaction ( a nested one)