Closed geetrawat closed 3 years ago
FYI, the Issue Reporting & Template applies here.
Having stated the above...
BUG DESCRITION
We understand the problem is related to 2 (or more) transactions initiated from a client (i.e. GemFire/Geode ClientCache
instance) in separate requests (Threads) to a (cluster of) server(s) with a REPLICATE
Region, where the first transaction is successful (i.e. commits, ??), however, the 2nd transaction fails and successfully rolls back, but unfortunately results in a o.s.transaction.NoTransactionException
, which seems to somehow be caused by GemFire/Geode:
Caused by: java.lang.IllegalStateException: Thread does not have an active transaction
at org.apache.geode.internal.cache.TXManagerImpl.rollback(TXManagerImpl.java:532)
STEPS TO REPRODUCE
?
EXPECTED OUTCOME
Rollback; no Exception is thrown.
ACTUAL OUTCOME:
2nd transaction failed and successfully rolled back, however, the Spring Transaction Management Infrastructure apparently threw a NoTransactionException
during the rollback operation.
This seems to have been caused by GemFire/Geode itself in the call to ...
org.apache.geode.internal.cache.TXManagerImpl.rollback(TXManagerImpl.java:532)
... from the Spring PlatformTransactionManager
for Apache Geode (i.e. the SDG GemfireTransactionManager
)
org.springframework.data.gemfire.transaction.GemfireTransactionManager.doRollback(GemfireTransactionManager.java:232)
.
Care to share:
Include what is relevant.
??
Re-opening to request more feedback.
The following, recent addition of this test class to the SDG test suite proves that Spring's Transaction Management infrastructure, initiated by the Spring Framework @EnableTransactionManagement
(Javadoc) and @Transactional
(Javadoc) annotations in conjunction with SDG's GemfireTransactionManager
(Javadoc), works correctly in the context of concurrent client transactions (initiated from different requests/Threads) against server(s) with a REPLICATE
Region.
In fact, this problem should be largely Region DataPolicy independent. Meaning, this should work regardless of the (server) Region DataPolicy type (e.g. REPLICATE
, PARTITION
, LOCAL
, etc).
There are several reasons why a NoTransactionException
might be thrown, including but not limited to:
@EnableTransactionManagement
annotation, or alternatively and conveniently by using SDG's EnableGemfireCacheTransactions
annotation).PlatformTransactionManager
implementation (specific to the data management technology) as a bean definition in the Spring ApplicationContext
(e.g. SDG's @GemfireTransactionManager
for GemFire/Geode cache transactions). This is especially true when not using SDG's @EnableGemfireCacheTransactions
annotation, which conveniently enables Spring's Transaction Management as well as declares & registers the SDG GemfireTransactionManager
for you.@Transasctional
annotation (e.g. not propagating the transaction, forgetting to resume a suspended transaction, etc).@Transactional
service method from another non-transactional service method inside the AOP proxy for the transactional service bean, thereby not tripping the Spring @Transactional
AOP Advice.@Transactional
annotation, which does not get properly recognized by the Spring Transaction Management infrastructure.@Transactional
annotation via the TransactionInterceptor
) that invokes Apache Geode's CacheTransactionManager
directly, not involving by circumventing the Spring Transaction Management infrastructure in the (cache) transaction.But, it is not because Spring Framework's Transaction Management combined with SDG's custom PlatformTransactionManager
implementation (i.e. GemfireTransactionManager
) is not properly managing (GemFire/Geode cache) transactions when Spring's Transaction Management infrastructure is enabled and used properly.
Ignoring the NoTransactionException
is dangerous, particularly if you think your code has initiated, and is running in a transaction when in fact it hasn't and isn't! These type of problems turn out to be (application) configuration problems more so than infrastructure/framework problems.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.
Client App is using multiple threads to modify the same object concurrently in the same region (replicated region in this case) with transaction. When the second transaction fails, the transaction rollsback (which is correct). However, in doing so, it is throwing the following exception