Closed rpajaziti closed 1 year ago
The current information doesn't seem to have anything to do with seata, so can you provide a demo
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.
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
@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.
I'll check.
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.
@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
Ⅰ. 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():
With saveAndFlush():
Ⅲ. 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)
Ⅴ. Anything else we need to know?
Ⅵ. Environment: