hazelcast / hazelcast

Hazelcast is a unified real-time data platform combining stream processing with a fast data store, allowing customers to act instantly on data-in-motion for real-time insights.
https://www.hazelcast.com
Other
6.18k stars 1.85k forks source link

Transaction Propagation feature #13540

Open sbespalov opened 6 years ago

sbespalov commented 6 years ago

As stated in HazelcastTransactionManager there is no "nested" transactions in Hazelcast and as a consequence there is no support of PROPAGATION_REQUIRES_NEW for PlatformTransactionManager in Spring.

This feature required in some cases, like for example in our project we use @TransactionalEventListener with TransactionPhase.AFTER_COMMIT, and in case of synchronous event there should be new "nested" transaction in same thread if we need to change some data.

There is internal request for this mentioned here, is there are any plans to have this implemented any time soon?

Or maybe you can give some direction for us so we can contribute this feature?

mmedenjak commented 6 years ago

Hi @sbespalov !

There are still no plans on when this will be implemented. We are still assessing the community interest.

sbespalov commented 6 years ago

hi @mmedenjak , thanks for your response.

Hope community will vote for this feature.

sbespalov commented 5 years ago

@mmedenjak would you approve if I will try to contribute this feature for you?

mmedenjak commented 5 years ago

It depends :) We'll definitely take a look and try and include it in the release. On the other hand, I can't foresee how production-ready your fix will be. It may also take us some time to review the PR as there are many other tasks we are involved in but I would say we are making some improvements in this area. I suggest you try. Working on distributed systems problems is quite interesting. At least for me :)

sbespalov commented 5 years ago

@mmedenjak I've created a PR with initial implementation of this feature.

Can you please have a look and provide some feedback?

sbespalov commented 5 years ago

hi @mmedenjak is there any update? thanks :)

mmedenjak commented 4 years ago

Reopening since the commit was reverted. Some of our users have experienced issues (suspend / resume logic with Weblogic, JCA adaptor) and we believe this feature needs more research for a complete implementation. I'll add more details about the issues here once I find time.

sbespalov commented 4 years ago

@mmedenjak thanks for feedback. I would also be interested to know if I can continue to work on this in case of having more details?

mmedenjak commented 4 years ago

Sure @sbespalov , here is some info we've received since:

We  works with Hazelcast JCA Resource Adapter (https://github.com/hazelcast/hazelcast-ra) which is deployed on Weblogic application server.
It  configures to supply XATransaction to container.

Problem we encounter is that wrong hazelcast transactional context is returned in following scenario:
1.  Call to EJB1 method M1  with creating new TX
2.  Call to other EJB2 method M2 (with TransactionAttributeType.REQUIRES_NEW) within M1 method
3.  After return from M2 method  hazelcast TX does not contains changes done before cal M2.

 How can this be fixed  ?
I send to you 3 classes with  reproduction problem I was described below. See attachment.

I use functionality of Weblogic transaction manager.  I suppose that it implements  of container manage Tx using  following  scenario (Suspend / resume behaviour). I have changed little code of JCA in product  application to adopt it to version 4.0. 
> method1 - begin tran1
  > method2 - suspend tran1, begin tran2
    workA
  < method2 - commit tran2, resume tran1
< method1 - rollback tran1 (tran2 remains committed)

Sample was took from unit test in hazelcast-jca-3.7.2.jar
Test Environment: Windows 10. 

Application server: Weblogic 12.2.1.1
Hazelcast version : 3.11 (but issue appears also on 4.0)
hazelcast-ra version : 3.7.2 (issue appears also with updated hazelcast-ra for HZ 4.0)
Resource configuration: see attachment

reproducer.zip