Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting no transaction is in progress when running GlobalTransaction #4976

Closed
1 task done
rpajaziti opened this issue Oct 5, 2022 · 7 comments · Fixed by #5134
Closed
1 task done

Getting no transaction is in progress when running GlobalTransaction #4976

rpajaziti opened this issue Oct 5, 2022 · 7 comments · Fixed by #5134
Labels
type: bug Category issues or prs related to bug.

Comments

@rpajaziti
Copy link

rpajaziti commented Oct 5, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Ⅰ. Issue Description

We have a couple of microservices build with Spring Boot, postgresql and we use thrift for inner communication.
When i run a global transaction through microservices, i get: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException

Ⅱ. Describe what happened

The error happens when we use jpa's saveAndFlush(), but when we use save(), it works fine no error, but it doesn't save at all.
The globaltransaction is created fine in SEATA client (no local transactions though in the case of save() method).

If there is an exception, please attach the exception trace:

When we use save() this is the logs it generates, also it says commited but it is not commited.

With save():

2022-10-05 12:05:57.266  INFO [,,,] 13732 --- [nio-9093-exec-9] i.seata.tm.api.DefaultGlobalTransaction  : Begin new global transaction [192.168.1.101:8091:5530733769509556240]
2022-10-05 12:05:58.591  INFO [,,,] 13732 --- [nio-9093-exec-9] c.b.t.v.service.TVehiclePortService      : # createVehicleGroup... xid: TX_XID
2022-10-05 12:05:58.593  INFO [,,,] 13732 --- [nio-9093-exec-9] c.b.t.v.service.TVehiclePortService      : # createVehicleGroup... xid: TX_XID

2022-10-05 12:06:10.693  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : channel [id: 0x35a8bb0d, L:/127.0.0.1:54499 - R:/127.0.0.1:8091] read idle.
2022-10-05 12:06:10.701  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.core.rpc.netty.NettyPoolableFactory  : will destroy channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 - R:/127.0.0.1:8091]
2022-10-05 12:06:10.702  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 - R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.703  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.704  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.netty.NettyClientChannelManager  : return to pool, rm channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.704  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.core.rpc.netty.NettyPoolableFactory  : channel valid false,channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.704  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.core.rpc.netty.NettyPoolableFactory  : will destroy channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.704  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.705  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.705  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : channel inactive: [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.706  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.core.rpc.netty.NettyPoolableFactory  : channel valid false,channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.706  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.core.rpc.netty.NettyPoolableFactory  : will destroy channel:[id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]
2022-10-05 12:06:10.706  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.707  INFO [,,,] 13732 --- [ctor_RMROLE_1_1] i.s.c.r.n.AbstractNettyRemotingClient    : ChannelHandlerContext(AbstractNettyRemotingClient$ClientHandler#0, [id: 0x35a8bb0d, L:/127.0.0.1:54499 ! R:/127.0.0.1:8091]) will closed
2022-10-05 12:06:10.713  INFO [,,,] 13732 --- [nio-9093-exec-9] i.seata.tm.api.DefaultGlobalTransaction  : Suspending current transaction, xid = 192.168.1.101:8091:5530733769509556240
2022-10-05 12:06:10.715  INFO [,,,] 13732 --- [nio-9093-exec-9] i.seata.tm.api.DefaultGlobalTransaction  : [192.168.1.101:8091:5530733769509556240] commit status: Committed

With saveAndFlush():

common.exception.BaseRuntimeException: General server error
	at com.common.handler.DomainExceptionHandler.doOnError(DomainExceptionHandler.java:49)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
	at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:617)
	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:68)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
	at com.bravo.domain.service.DriverDomainService$$EnhancerBySpringCGLIB$$f70ec819.create(<generated>)
	at com.bravo.thrift.driver.service.TDriverPortService.create(TDriverPortService.java:55)
	at com.bravo.thrift.driver.controller.TDriverController.create(TDriverController.java:23)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.adapter.ThrowsAdviceInterceptor.invoke(ThrowsAdviceInterceptor.java:113)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at ru.trylogic.spring.boot.thrift.aop.MetricsThriftMethodInterceptor.invoke(MetricsThriftMethodInterceptor.java:22)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy148.create(Unknown Source)
	at com.bravo.thrift.driver.TDriverService$Processor$create.getResult(TDriverService.java:651)
	at com.bravo.thrift.driver.TDriverService$Processor$create.getResult(TDriverService.java:630)
	at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38)
	at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:38)
	at org.apache.thrift.server.TServlet.doPost(TServlet.java:83)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.common.filter.SeataFilter.doFilter(SeataFilter.java:44)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:403)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:235)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy146.saveAndFlush(Unknown Source)
	at com.bravo.domain.service.DriverDomainService.create(DriverDomainService.java:63)
	at com.bravo.domain.service.DriverDomainService$$FastClassBySpringCGLIB$$47a868b7.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
	at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64)
	... 78 common frames omitted
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
	at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:413)
	at org.hibernate.internal.SessionImpl.checkTransactionNeededForUpdateOperation(SessionImpl.java:3397)
	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1354)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1349)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:362)
	at com.sun.proxy.$Proxy142.flush(Unknown Source)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:311)
	at com.sun.proxy.$Proxy142.flush(Unknown Source)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.flush(SimpleJpaRepository.java:604)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.saveAndFlush(SimpleJpaRepository.java:573)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
	at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:524)
	at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:531)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:156)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:131)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	... 92 common frames omitted

Ⅲ. Describe what you expected to happen

I really need a fix for this, as we still are considering going with Seata or with something else, but besides this, everything is looking great with Seata, so a help will be appreciated.

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. xxx
  2. xxx
  3. xxx

Ⅴ. Anything else we need to know?

Ⅵ. Environment:

  • JDK version : 11
  • Seata version: 1.5.2
  • OS : MACOS
  • Others:
@rpajaziti rpajaziti changed the title Getting no transaction is in progress when running GlobalTransaction Getting no transaction is in progress when running GlobalTransaction Oct 5, 2022
@funky-eyes
Copy link
Contributor

The current information doesn't seem to have anything to do with seata, so can you provide a demo

@rpajaziti
Copy link
Author

Yes, i used this sample: https://github.com/vir56k/java_demo/tree/master/seata_demo
Then implemented similar to what we have.
So first, we have a gateway which communicates with other microservices through thrift(RPC).
The issue is that, when i used RestTemplate to communicate with another microservice, it worked fine.
But when i communicate with Thrift, i get the above issues, mainly no transaction in progress.
One question i have, whether it is Rest or RPC or any communication, the only info Thrift needs it is the header tx right?
Because if yes, you can see in gateway module i have Service1ThriftClient, where i have a bean of THttpClient, which i use on the service to send tx_id in the header. And the transactionId is received successfully, as i am able to catch that in the filter, and the RootContext.bind(txId) is successfully executed.

Thanks for your help.

seata_demo2.zip

@finger-dy
Copy link

Hiberate事务冲突了,设置allow_update_outside_transaction=true,
建议将jpa事务托管给spring
spring.jpa.properties.hibernate.allow_update_outside_transaction=true
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext
spring.jpa.properties.hibernate.transaction_manager=org.springframework.orm.hibernate5.HibernateTransactionManager

@rpajaziti2
Copy link

@finger-dy Thank you for the reply.
I tried the above, but with no results.

So first, let me tell you how i solved this.
So when using 1.4.2, and with druid as a datasource, everything seems to work fine, but if i try to use some other datasource(hikari), it doesn't work at all, and when starting the app i can see different logs.
So with druid i get:
LOG RM will register :jdbc:postgresql://localhost:5432/sample1, but with hikari i do not get this.

Also, with druid i get this log:
LOG NettyPool create channel to transactionRole:RMROLE,address:127.0.0.1:8091,msg:< RegisterRMRequest{resourceIds='jdbc:postgresql://localhost:5432/sample1', applicationId='sample1-service', transactionServiceGroup='test-group'} >

But without druid i get this:
LOG NettyPool create channel to transactionRole:RMROLE,address:127.0.0.1:8091,msg:< RegisterRMRequest{resourceIds='null', applicationId='vehicle-service', transactionServiceGroup='bravo-group'} >

So for some reason, without druid i am not able to make the connection with a specific database, but with druid it works fine.
This was with version: 1.4.2 and with/without druid.

As for version 1.5.2 or 1.6.0-RC1 they both do not work.
With 1.5.2 i get the above error, also no undo_log data generated. With 1.6.0-RC1 also it doesn't work, as no undo_log data is generated.

I'll do a request, but if this is not possible no problem, as 1.4.2 is working but we want to make this as a future proof solution for us.
Is it possible the above sample i attached, to make it with 1.5.2 or newer, but without druid, as we tried everything but it seems it refuses to work without druid even with 1.4.2 version.
I saw many examples, and tested everything, but what i said above is the only thing that works for us, and as we know that is not future proof, as later if we want to make spring or something else changes to the versions, we will have issues with Seata. Thank you.

@xingfudeshi
Copy link
Member

I'll check.

@xingfudeshi xingfudeshi reopened this Dec 6, 2022
@wangliang181230 wangliang181230 added the type: bug Category issues or prs related to bug. label Dec 14, 2022
@rpajaziti2
Copy link

Hello.
So since i didn't get an answer here, i wrote to @a364176773 on email, and thank God i got an answer and it works fine.
So i solved my issue, but just leaving it here for someone in the future to find it and have a working solution.
So here's what you have to do, to have 1.5.2 version working for you with Hikari as a datasource:

You can declare a SeataAutoDataSourceProxyCreator bean and exclude SeataDataSourceAutoConfiguration.class
case:
@Bean(BEAN_NAME_SEATA_AUTO_DATA_SOURCE_PROXY_CREATOR)
    @ConditionalOnMissingBean(SeataAutoDataSourceProxyCreator.class)
    public SeataAutoDataSourceProxyCreator seataAutoDataSourceProxyCreator(SeataProperties seataProperties) {
        return new SeataAutoDataSourceProxyCreator(seataProperties.isUseJdkProxy(),
            seataProperties.getExcludesForAutoProxying(), seataProperties.getDataSourceProxyMode());
    }

PS: Please, Seata needs a lot a rewriten documentation for the ground up, and specific for each version, as it took me weeks to figure it out how to make it working. That can be my flaw, but still, the documentation is nowhere near a good one, and one that you do not need to ask any question after it. So please, invest on it, and also invest in English one, even though i used google translate, but still there are a lot of people around the world who need Distributed transactions solution, and to which Seata would be a great approach, just like it was for us.
So thank you for this, just do a propper documentation.

@rpajaziti2
Copy link

rpajaziti2 commented Dec 29, 2022

@a364176773 I somehow mixed the dependencies, and i think i was working with the 1.4.2, because 1.5.2 is the same issue, even with the above bean. Also excluding SeataDataSourceAutoConfiguration gives no impact.
It works fine with 1.4.2 though, but since that is a bit old, we wanted to make it work with 1.5.2.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants