cancel
Showing results for 
Search instead for 
Did you mean: 

conflicts in database connections in JTA

tbee
Champ in-the-making
Champ in-the-making
I've got a setup where business model and Activiti are mixed into one engine. In order to facilitate transactional consistency, Bitronix JTA-XA is used to enabled distributed transactions. Configuration wise this works, however during the execution of a Activiti listener the connections have a conflict: the execution freezes and after a while a time out occurs. This looks very similar to a locking conflict.

In order to examine this, I've logged all changes that Activiti makes to the database:

169: [EL Finer]: 2012-09-20 14:08:17.962–ClientSession(5578877)–Thread(Thread[main,5,main])–TX beginTransaction, status=STATUS_ACTIVE
306: 2012-09-20 14:08:20,448 DEBUG #5958562[C22645161] activiti: execute: update ACT_GE_PROPERTY     …
334: 2012-09-20 14:08:20,495 DEBUG #10522721[C5094311] activiti: execute: insert into ACT_RU_EXECUTION …
360: 2012-09-20 14:08:20,495 DEBUG #25022548[C5094311] activiti: execute: insert into ACT_HI_PROCINST …
384: 2012-09-20 14:08:20,511 DEBUG #13502571[C5094311] activiti: execute: insert into ACT_HI_ACTINST …
408: 2012-09-20 14:08:20,526 DEBUG #25489800[C5094311] activiti: execute: insert into ACT_RU_VARIABLE …
432: 2012-09-20 14:08:20,542 DEBUG #28968689[C5094311] activiti: execute: insert into ACT_RU_VARIABLE …
456: 2012-09-20 14:08:20,542 DEBUG #9486511[C5094311] activiti: execute: insert into ACT_HI_ACTINST …
486: 2012-09-20 14:08:20,557 DEBUG #4047039[C5094311] activiti: execute: insert into ACT_RU_TASK …
520: 2012-09-20 14:08:20,573 DEBUG #2157445[C5094311] activiti: execute: insert into ACT_HI_TASKINST …
534: 2012-09-20 14:08:20,589 DEBUG #22864626[C5094311] activiti: execute: insert into ACT_RU_IDENTITYLINK …
674: [EL Finer]: 2012-09-20 14:08:20.714–UnitOfWork(30281720)–Thread(Thread[main,5,main])–TX afterCompletion callback, status=COMMITTED
676: —————————
677: [EL Finer]: 2012-09-20 14:08:20.729–ClientSession(5578877)–Thread(Thread[main,5,main])–TX beginTransaction, status=STATUS_ACTIVE
741: 2012-09-20 14:08:20,808 DEBUG #17985579[C5094311] activiti: execute: update ACT_RU_TASK …
769: 2012-09-20 14:08:20,823 DEBUG #32139235[C5094311] activiti: execute: update ACT_HI_TASKINST …
781: 2012-09-20 14:08:20,823 DEBUG #28336320[C5094311] activiti: execute: update ACT_HI_ACTINST …
877: 2012-09-20 14:08:20,901 DEBUG #28860947[C22645161] activiti: execute: insert into ACT_RU_VARIABLE …
913: 2012-09-20 14:08:20,917 DEBUG #9528986[C5094311] activiti: execute: insert into ACT_RU_EXECUTION …
937: 2012-09-20 14:08:20,933 DEBUG #33054865[C5094311] activiti: execute: insert into ACT_HI_ACTINST …
961: 2012-09-20 14:08:20,948 DEBUG #21289936[C5094311] activiti: execute: insert into ACT_HI_ACTINST …
991: 2012-09-20 14:08:20,980 DEBUG #23935686[C5094311] activiti: execute: insert into ACT_RU_TASK …
1025: 2012-09-20 14:08:20,995 DEBUG #31851612[C5094311] activiti: execute: insert into ACT_HI_TASKINST …

Important is the number in square brackets which denotes the JDBC connection used. What I notice is that almost all interaction is done through [C5094311], except three which use [C22645161]. Now, prefix 408 and 432 and 877 use the same table through different connections. 877 is the result of this line:


      ProcessEngines.getDefaultProcessEngine().getRuntimeService().setVariable( getWorkflowProcessInstance().getProcessInstanceId(), "validateOfferStage", Long.valueOf(System.currentTimeMillis()));

And indeed, if i comment this out, the executions continues. Why are there different database connections being used to write to the database?
19 REPLIES 19

meyerd
Champ on-the-rise
Champ on-the-rise
I wrote earlier:
Make sure to set
shareTransactionConnections=true

In https://jira.codehaus.org/secure/attachment/61422/BitronixTrial.java
you are missing the shareTransactionConnections=true have you added this in the meantime?

tbee
Champ in-the-making
Champ in-the-making
BTW, the essence of this code is attached to the Jira issue, so it should be fairly easy to reproduce.

@meyerd: sorry, I had not seen your reply yet. I will test that tomorrow!

tbee
Champ in-the-making
Champ in-the-making
That option does not exist.

Invalid property 'shareTransactionConnections' of bean class [org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration]: Bean property 'shareTransactionConnections' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

meyerd
Champ on-the-rise
Champ on-the-rise
Hi tbee,

it is not a property in activiti but a property on the Bitronix PoolingDataSource

tbee
Champ in-the-making
Champ in-the-making
Sorry. No difference. It's still using a different connection.

tbee
Champ in-the-making
Champ in-the-making
Let me take that back. Too many file and configurations running around. It seems to work. More testing…

jbarrez
Star Contributor
Star Contributor
That's great news. Please report back if it works, so future generations can learn from it.

@Daniel: thanks, didn't knew about that property!

tbee
Champ in-the-making
Champ in-the-making
I didn't either 🙂

But so far so good. I'm planning a blog post about this next week.

jbarrez
Star Contributor
Star Contributor
Awesome. Keep us posted!