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 2022/01/18 07:22:57 UTC

[GitHub] [shardingsphere] tuyendev opened a new issue #14858: read-write-splitting with spring boot and jpa never read on save

tuyendev opened a new issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858


   
   ### Which version of ShardingSphere did you use? 
   
   - **5.0.0**
   
   ### Which project did you use? 
   
   - **ShardingSphere-JDBC**
   
   ### Expected behavior
   - Read behavior never swith to slave datasources even ROUND_ROBIN or RANDOM
   ### Actual behavior
   - Read behavior CAN reach to slave datasources
   ### Reason analyze (If you can)
   - Not yet
   ### Steps to reproduce the behavior
   - I was following the official example of shardingshere. I was confused a bit when I turn off write datasource (master), the read process is dead and can never recover back
   
   ### Example codes for reproduce this issue (such as a github link).
   [SRC](https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-jdbc-example/single-feature-example/readwrite-splitting-example/readwrite-splitting-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/readwrite/splitting/spring/namespace)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #14858: read-write-splitting with spring boot and jpa never read on read-datasource

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015168242


   @tuyendev Thanks for your feedback. I will adjust readwrite-splitting configuration and check your question.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015307724


   I will tell you if this issue are fixed,If you interest of this,you can resolve it too.
   
   
   
   发自我的iPhone
   
   
   ------------------ Original ------------------
   From: Tea ***@***.***&gt;
   Date: Tue,Jan 18,2022 7:06 PM
   To: apache/shardingsphere ***@***.***&gt;
   Cc: zhaojinchao ***@***.***&gt;, Mention ***@***.***&gt;
   Subject: Re: [apache/shardingsphere] read-write-splitting with spring boot andjpa never reach to read-datasource (Issue #14858)


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev removed a comment on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev removed a comment on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015180971


   @zjcnb I don't think your configuration is wrong.
   
   Please check my update


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015330481


   > @zjcnb thank you. I will try to fix the issue
   
   I will create a new issue and then you claim it.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015309952


   @zjcnb thank you. I will try to fix the issue


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev commented on issue #14858: read-write-splitting with spring boot and jpa never read on read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015180971


   @zjcnb I don't think your configuration is wrong.
   I found a weird behaviour ( not sure about that  ) in **ReadwriteSplittingDataSourceRouter.java**
   
   `    private boolean isPrimaryRoute(final SQLStatement sqlStatement) {
           return containsLockSegment(sqlStatement) || !(sqlStatement instanceof SelectStatement) || HintManager.isWriteRouteOnly() || TransactionHolder.isTransaction();
       }`
   
   The **TransactionHolder.isTransaction()** was **true**, i even don't set any transaction configuration.  
   It worked in previous version (4.1.1). I only cause problem with this version
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015267141


   @tuyendev Hi, this reason is `processSuccess()` method add @Transactional annotation. the autoCommit set as false.  Maybe this readwrite-splitting example are some problem, the insert and query should be separated and not in a 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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] zjcnb commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
zjcnb commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015189777


   > @zjcnb I don't think your configuration is wrong.
   > 
   > Please check my update
   
   OK, I will check.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev edited a comment on issue #14858: read-write-splitting with spring boot and jpa never read on read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev edited a comment on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015180971


   @zjcnb I don't think your configuration is wrong.
   
   Please check my update


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev edited a comment on issue #14858: read-write-splitting with spring boot and jpa never read on read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev edited a comment on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015180971


   @zjcnb I don't think your configuration is wrong.
   I found a weird behaviour ( not sure about that  ) in **ReadwriteSplittingDataSourceRouter.java**
   
   `    private boolean isPrimaryRoute(final SQLStatement sqlStatement) {
           return containsLockSegment(sqlStatement) || !(sqlStatement instanceof SelectStatement) || HintManager.isWriteRouteOnly() || TransactionHolder.isTransaction();
       }`
   
   The **TransactionHolder.isTransaction()** was **true**, i even don't set any transaction configuration.  
   It worked in previous version (4.1.1). I only cause problem with this version (5.0.0)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015187619


   @zjcnb I don't think your configuration is wrong.
   
   Please check my update


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tuyendev commented on issue #14858: read-write-splitting with spring boot and jpa never reach to read-datasource

Posted by GitBox <gi...@apache.org>.
tuyendev commented on issue #14858:
URL: https://github.com/apache/shardingsphere/issues/14858#issuecomment-1015304525


   Agreed @zjcnb . Should I report this issue as bug or waiting for the your example.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org