You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/17 03:31:27 UTC

[GitHub] [incubator-shardingsphere] Zze0 opened a new issue #4002: Transactions cannot be rolled back properly when using local transaction.

Zze0 opened a new issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002
 
 
   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub issues](https://github.com/apache/incubator-shardingsphere/issues).
   - Read documentation: [ShardingSphere Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more details. 
   If no response **more than 7 days** and we cannot reproduce it on current information, we will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   4.0.0-RC2
   
   ### Which project did you use? Sharding-JDBC or Sharding-Proxy?
   Sharding-JDBC
   
   ### Expected behavior
   https://shardingsphere.apache.org/document/current/en/features/transaction/function/local-transaction/
   ![image](https://user-images.githubusercontent.com/59901940/72581051-f6c00880-3918-11ea-8fe2-2b727603dc10.png)
   
   
   ### Actual behavior
   1, The insert is committed directly.
   2, Local transaction cannot be rolled back after a null pointer exception is thrown.
   
   Example code:
   ![image](https://user-images.githubusercontent.com/59901940/72581279-c4fb7180-3919-11ea-82cb-f5e967c5ee0a.png)
   
   ### Reason analyze (If you can)
   Distributed transactions are enabled after the sharding-transaction-xa-core package is imported into the project.
   The reason for the insert is directly committed is probably because the autoCommit property of the ShardingConnection class defaults to true and then returns false in the isHoldTransaction function of the ShardingConnection class.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   Please see the sample code below.
   
   ### Example codes for reproduce this issue (such as a github link).
   https://github.com/Zze0/demo-sharding-jdbc

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 edited a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 edited a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575496502
 
 
   > hi, you should exclude the `JtaAutoConfiguration ` in your project like this
   > 
   > ```
   > @SpringBootApplication(exclude = JtaAutoConfiguration.class)
   > ```
   > 
   > aslo @ShardingTransactionType doesn't work without [sharding-transaction-jdbc-spring](https://github.com/OpenSharding/shardingsphere-spi-impl/tree/4.0.0-RC2/sharding-spring/sharding-transaction-spring-boot-starter/sharding-transaction-jdbc-spring-boot-starter) dependency. we haven't merge it to ShardingSphere now, you should deploy it by yourself
   
   Thank you for your patient reply.
   It finally worked when I excluded JtaAutoConfiguration from my project.
   
   The solution is to use DataSourceTransactionManager by default after excluded JtaAutoConfiguration ?
   
   The second question is, can I use 2PC XA transactions after excluding JtaAutoConfiguration? (Even if that means no JtaTransactionManager)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 closed issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 closed issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 edited a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 edited a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575496502
 
 
   > hi, you should exclude the `JtaAutoConfiguration ` in your project like this
   > 
   > ```
   > @SpringBootApplication(exclude = JtaAutoConfiguration.class)
   > ```
   > 
   > aslo @ShardingTransactionType doesn't work without [sharding-transaction-jdbc-spring](https://github.com/OpenSharding/shardingsphere-spi-impl/tree/4.0.0-RC2/sharding-spring/sharding-transaction-spring-boot-starter/sharding-transaction-jdbc-spring-boot-starter) dependency. we haven't merge it to ShardingSphere now, you should deploy it by yourself
   
   Thank you for your patient reply.
   It finally worked When I excluded JtaAutoConfiguration from my project.
   
   The solution is to Use DataSourceTransactionManager by default After excluded JtaAutoConfiguration ?
   
   The second question is, can I use 2PC XA transactions after excluding JtaAutoConfiguration? (Even if that means no JtaTransactionManager)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575961548
 
 
   Wish you a happy Spring Festival in advance !
   
   Can someone solve my doubts?
   It’s very important for me. 
   I still have a production problem to solve.
   ![IMG20200119-110527](https://user-images.githubusercontent.com/59901940/72673923-a0cf9a00-3aab-11ea-9878-38d3ed8c0911.jpeg)
   
   
   @KomachiSion @terrymanu @cherrylzhao 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575966318
 
 
   @KomachiSion @cherrylzhao 
   Thank you very much for your answer.
   My problem is solved.
   
   --------------------------------------------------------------------------
   > If you want to use ShardingSphere XA, you need to exclude JtaTransactionManager. Because JtaTransactionManager will shutdown the Transaction control of ShardingSphere.
   
   In addition, I think you need to update your official documents on this point.
   Right here: https://shardingsphere.apache.org/document/current/en/manual/sharding-jdbc/usage/transaction/

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] KomachiSion commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
KomachiSion commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575962836
 
 
   > After debugging, I found that excluding or not excluding JtaAutoConfiguration made a big difference.
   > 
   > **Don’t exclude JtaAutoConfiguration, use JtaTransactionManager.**
   > 
   > When commit:
   > 1、org.springframework.transaction.support.AbstractPlatformTransactionManager#commit
   > 2、org.springframework.transaction.jta.JtaTransactionManager#doCommit
   > 3、com.atomikos.icatch.jta.UserTransactionManager#commit
   > 
   > **Exclude JtaAutoConfiguration, use DataSourceTransactionManager.**
   > 
   > When commit:
   > 1、org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection#commit
   > 2、org.apache.shardingsphere.transaction.xa.XAShardingTransactionManager#commit
   > 3、com.atomikos.icatch.jta.UserTransactionManager#commit
   > 
   > Does this mean that JtaAutoConfiguration must be excluded to ensure that sharding-jdbc controls the commit or rollback ? @cherrylzhao
   
   If you want to use ShardingSphere XA, you need to exclude `JtaTransactionManager`. Because `JtaTransactionManager` will shutdown the Transaction control of ShardingSphere.
   
   If use local or base of ShardingSphere, `JtaTransactionManager` can be excluded or not.
   
   > Currently, do we have to develop the @ShardingTransactionType aspect by ourselves?
   
   There is no need to develop @ShardingTransactionType by yourself. But only you should clone the `shardingsphere-spi-impl` repo and install by yourself.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575966690
 
 
   this is a constraint in spring side, you can try to PR for it to become our new contributor

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 removed a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 removed a comment on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575486520
 
 
   Thank you for your patient reply.
   It finally worked When I excluded JtaAutoConfiguration from my project.
   
   The solution is to Use DataSourceTransactionManager by default After excluded JtaAutoConfiguration ?
   
   The second question is, whether XA transactions can be used after JtaAutoConfiguration is excluded?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575486520
 
 
   Thank you for your patient reply.
   It finally worked When I excluded JtaAutoConfiguration from my project.
   
   The solution is to Use DataSourceTransactionManager by default After excluded JtaAutoConfiguration ?
   
   The second question is, whether XA transactions can be used after JtaAutoConfiguration is excluded?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575463054
 
 
   hi, you should exclude the `JtaAutoConfiguration ` in your project like this
   ```
   @SpringBootApplication(exclude = JtaAutoConfiguration.class)
   ```
   aslo @ShardingTransactionType doesn't work without [sharding-transaction-jdbc-spring](https://github.com/OpenSharding/shardingsphere-spi-impl/tree/4.0.0-RC2/sharding-spring/sharding-transaction-spring-boot-starter/sharding-transaction-jdbc-spring-boot-starter) dependency. we haven't merge it to ShardingSphere now, you should deploy it by yourself

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575546746
 
 
   After debugging, I found that excluding or not excluding JtaAutoConfiguration made a big difference.
   
   
   ------------------------------------------------------------------------------------
   
   **Don’t exclude JtaAutoConfiguration, use JtaTransactionManager.**
   
   When commit:
   1、org.springframework.transaction.support.AbstractPlatformTransactionManager#commit
   2、org.springframework.transaction.jta.JtaTransactionManager#doCommit
   3、com.atomikos.icatch.jta.UserTransactionManager#commit
   
   ------------------------------------------------------------------------------------
   
   **Exclude JtaAutoConfiguration, use DataSourceTransactionManager.**
   
   When commit:
   1、org.apache.shardingsphere.shardingjdbc.jdbc.core.connection.ShardingConnection#commit
   2、org.apache.shardingsphere.transaction.xa.XAShardingTransactionManager#commit
   3、com.atomikos.icatch.jta.UserTransactionManager#commit
   
   ------------------------------------------------------------------------------------
   
   Does this mean that JtaAutoConfiguration must be excluded to ensure that sharding-jdbc controls the commit or rollback ? @cherrylzhao 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575496502
 
 
   > hi, you should exclude the `JtaAutoConfiguration ` in your project like this
   > 
   > ```
   > @SpringBootApplication(exclude = JtaAutoConfiguration.class)
   > ```
   > 
   > aslo @ShardingTransactionType doesn't work without [sharding-transaction-jdbc-spring](https://github.com/OpenSharding/shardingsphere-spi-impl/tree/4.0.0-RC2/sharding-spring/sharding-transaction-spring-boot-starter/sharding-transaction-jdbc-spring-boot-starter) dependency. we haven't merge it to ShardingSphere now, you should deploy it by yourself
   
   Thank you for your patient reply.
   It finally worked When I excluded JtaAutoConfiguration from my project.
   
   The solution is to Use DataSourceTransactionManager by default After excluded JtaAutoConfiguration ?
   
   The second question is, whether XA transactions can be used after JtaAutoConfiguration is excluded?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575505389
 
 
   > hi, you should exclude the `JtaAutoConfiguration ` in your project like this
   > 
   > ```
   > @SpringBootApplication(exclude = JtaAutoConfiguration.class)
   > ```
   > 
   > aslo @ShardingTransactionType doesn't work without [sharding-transaction-jdbc-spring](https://github.com/OpenSharding/shardingsphere-spi-impl/tree/4.0.0-RC2/sharding-spring/sharding-transaction-spring-boot-starter/sharding-transaction-jdbc-spring-boot-starter) dependency. we haven't merge it to ShardingSphere now, you should deploy it by yourself
   
   As for your statement that "@ShardingTransactionType doesn't work without sharding-transaction-jdbc-spring dependency",  which version will be merged?
   
   Currently, do we have to develop the @ShardingTransactionType aspect by ourselves?
   
   Like this? https://github.com/OpenSharding/shardingsphere-spi-impl/blob/4.0.0-RC2/sharding-spring/sharding-transaction-spring/sharding-transaction-jdbc-spring/src/main/java/io/shardingsphere/transaction/aspect/ShardingTransactionJDBCAspect.java

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
cherrylzhao commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575966099
 
 
   ShardingSphere use local transaction interface to integrate distributed transaction(XA and BASE). 
   from the spring perspective we only compatible with `DataSourceTransactionManager`,so JTA
   TransactionMananger will conflict with us. @ShardingTransactionType is a customer annotation, it should be handled by aspect class, you can use our code of  SPI project or develop by yourself.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.

Posted by GitBox <gi...@apache.org>.
Zze0 commented on issue #4002: Transactions cannot be rolled back properly when using local transaction.
URL: https://github.com/apache/incubator-shardingsphere/issues/4002#issuecomment-575966887
 
 
   > this is a constraint in spring side, you can try to PR for it to become our new contributor
   
   Ok, I will

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services