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/12 02:22:56 UTC

[GitHub] [shardingsphere] lwclover opened a new issue #14699: About readwrite splitting hint

lwclover opened a new issue #14699:
URL: https://github.com/apache/shardingsphere/issues/14699


   ## Using SQL Hint function is too complex. 
   code like:
   ```
   try(Connection conn = ds.getConnection(); Statement stat = conn.createStatement()) {
   	stat.execute("set readwrite_splitting hint source=write");
   	String sql = "select * from test";
   	try(ResultSet rs = stat.executeQuery(sql)) {
   		if(rs.next()){
   			System.out.println("有数据");
   		}else{
   			System.out.println("没有数据");
   		}
   	} finally {
   		stat.execute("clear readwrite_splitting hint");
   	}
   } catch (SQLException e) {
   	e.printStackTrace();
   }
   ```
   How about merging into one SQL?
   For example: /* set readwrite_splitting hint source=write */ select * from test /* clear readwrite_splitting hint */.
   And 'clear readwrite_splitting hint' is unnecessary.


-- 
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] strongduanmu commented on issue #14699: About using readwrite splitting hint function

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


   Hi @lwclover, thank you for your suggestion. We have already provide sql hint feature in master branch. You can refer this [doc](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/sharding/hint/#%E4%BD%BF%E7%94%A8-hint-%E5%BC%BA%E5%88%B6%E4%B8%BB%E5%BA%93%E8%B7%AF%E7%94%B1) for more detailed information. 
   
   ```sql
   /* ShardingSphere hint: writeRouteOnly=true */
   SELECT * FROM t_order;
   ```


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   The whole process is not atomic, there is a risk the hint tag never remove from ThreadLocal in proxy. 


-- 
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] tuichenchuxin commented on issue #14699: About using readwrite splitting hint

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


   @lwclover You can refer to [this](https://github.com/apache/shardingsphere/issues/13771)
   5.1 will be released soon.


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint

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


   > @lwclover You can refer to [this](https://github.com/apache/shardingsphere/issues/13771) 5.1 will be released soon.
   
   thanks


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   > @lwclover Please try the latest master branch, because this is a new feature.
   
   And how


-- 
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] lwclover closed issue #14699: About using readwrite splitting hint function

Posted by GitBox <gi...@apache.org>.
lwclover closed issue #14699:
URL: https://github.com/apache/shardingsphere/issues/14699


   


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   > > 
   > 
   > @lwclover Which version are you using? Is it possible to provide the log information printed by sql-show?
   
   proxy 5.0.0.
   TextProtocolBackendHandlerFactory.newInstance() method first line:
   `
   String trimSQL = SQLUtil.trimComment(sql);
   `
   


-- 
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] lwclover edited a comment on issue #14699: About using readwrite splitting hint function

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


   > > 
   > 
   > @lwclover Which version are you using? Is it possible to provide the log information printed by sql-show?
   
   proxy 5.0.0.
   TextProtocolBackendHandlerFactory.newInstance() method first line:
   `
   String trimSQL = SQLUtil.trimComment(sql);
   `
   `
   [INFO ] 2022-01-12 11:33:59.053 [Connection-34-ThreadExecutor] ShardingSphere-SQL - Logic SQL: /* ShardingSphere hint: writeRouteOnly=true */ select * from test
   [INFO ] 2022-01-12 11:33:59.053 [Connection-34-ThreadExecutor] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
   [INFO ] 2022-01-12 11:33:59.053 [Connection-34-ThreadExecutor] ShardingSphere-SQL - Actual SQL: read_ds ::: /* ShardingSphere hint: writeRouteOnly=true */ select * from test
   `


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint

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


   > @lwclover If you use SQL hint like `/* ShardingSphere hint: writeRouteOnly=true */ select * from test`, This way we didn't use HintManager at all. So, there is no risk about threadLocal.
   
   You are right.
   
   By the way, I am using proxy 5.0.0, If I want to use comment hint feature, Which commits do I need to merge?
   
   


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   > Hi @lwclover, thank you for your suggestion. We have already provide sql hint feature in master branch. You can refer this [doc](https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/special-api/sharding/hint/#%E4%BD%BF%E7%94%A8-hint-%E5%BC%BA%E5%88%B6%E4%B8%BB%E5%BA%93%E8%B7%AF%E7%94%B1) for more detailed information.
   > 
   > ```sql
   > /* ShardingSphere hint: writeRouteOnly=true */
   > SELECT * FROM t_order;
   > ```
   
   I am using shardingsphere proxy,not  shardingsphere 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.

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

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



[GitHub] [shardingsphere] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   > @lwclover Proxy can also support this feature.
   proxy props config below:
   sql-show: true
   proxy-hint-enabled: true
   sql-comment-parse-enabled: true
   
   executing sql '/* ShardingSphere hint: writeRouteOnly=true */ select * from test', there is no effect. 
   Where did I configure it wrong?
   
   


-- 
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] lwclover commented on issue #14699: About using readwrite splitting hint function

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


   > @lwclover Please try the latest master branch, because this is a new feature.
   
   the latest branch has the feature, thank you


-- 
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] lwclover removed a comment on issue #14699: About using readwrite splitting hint function

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


   > @lwclover Please try the latest master branch, because this is a new feature.
   
   And how


-- 
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] strongduanmu commented on issue #14699: About using readwrite splitting hint function

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


   @lwclover Proxy can also support this feature. 


-- 
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] strongduanmu commented on issue #14699: About using readwrite splitting hint function

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


   @lwclover Please try the latest master branch, because this is a new feature.


-- 
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] tuichenchuxin commented on issue #14699: About using readwrite splitting hint function

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


   @lwclover If you use SQL hint like `/* ShardingSphere hint: writeRouteOnly=true */ select * from test`,
   This way we didn't use HintManager at all. So, there is no risk about threadLocal.


-- 
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] strongduanmu commented on issue #14699: About using readwrite splitting hint function

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


   > 
   
   @lwclover Which version are you using? Is it possible to provide the log information printed by sql-show?


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