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/07/18 01:52:44 UTC

[GitHub] [shardingsphere] peilinqian opened a new issue, #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint

peilinqian opened a new issue, #19303:
URL: https://github.com/apache/shardingsphere/issues/19303

   ## 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/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 anymore 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?
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ### Expected behavior
   sql hint and other strategies are configured at the same time, routed by the order of strategies
   ### Actual behavior
   sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
   1、create traffic rule
   ```
   drop traffic rule sql_hint_traffic;
   drop traffic rule sql_match_traffic;
   create traffic rule sql_match_traffic (labels(sharding2),
   traffic_algorithm(type(name=sql_match,properties("sql" = "SELECT * FROM t_order WHERE content IN (?, ?);update t_order set content='test11' where user_id=11;"))),
   load_balancer(type(name=round_robin)));
   create traffic rule sql_hint_traffic(labels(sharding1),
   traffic_algorithm(type(name=SQL_HINT)),
   load_balancer(type(name=round_robin)));
   show traffic rules;
   ```
   
   2、ss-jdbc excute sql,hint:useTraffic=true
   ```
   	@Test
   	public void testTraffic_22() throws SQLException {
   		String sql = "/* shardingsphere hint:useTraffic=true */SELECT * FROM t_order WHERE content IN (?, ?)";
   		String sql2 = "/* shardingsphere hint:useTraffic=true */update  t_order   set content='test11'   where   user_id=11;";
   		for (int i = 0; i < 10; i++) {
   			PreparedStatement statement = getPreparedStatement(sql, Arrays.asList("test1", "test10"));
   			statement.executeQuery();
   			getStatement().executeUpdate(sql2);
   		}
   	}
   ```
   
   3、change traffic rules's order
   ```
   drop traffic rule sql_hint_traffic;
   drop traffic rule sql_match_traffic;
   create traffic rule sql_hint_traffic(labels(sharding1),
   traffic_algorithm(type(name=SQL_HINT)),
   load_balancer(type(name=round_robin)));
   create traffic rule sql_match_traffic (labels(sharding2),
   traffic_algorithm(type(name=sql_match,properties("sql" = "SELECT * FROM t_order WHERE content IN (?, ?);update t_order set content='test11' where user_id=11;"))),
   load_balancer(type(name=round_robin)));
   show traffic rules;
   ```
   
   4、repeat step 2
   
   ### Example codes for reproduce this issue (such as a github link).
   


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

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


[GitHub] [shardingsphere] strongduanmu commented on issue #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint

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

   Hi @peilinqian, I have test your case. Since SQL comments are also part of the SQL content, `/* shardingsphere hint:useTraffic=true */SELECT * FROM t_order WHERE content IN (?, ?)` cannot match the SQL_MATCH algorithm. You can modify the parameters in the SQL_MATCH algorithm, or adjust the SQL for the 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] strongduanmu commented on issue #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint

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

   This is not a bug, but a misuse of the SQL_MATCH algorithm, so I will close this 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] strongduanmu closed issue #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint

Posted by GitBox <gi...@apache.org>.
strongduanmu closed issue #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint
URL: https://github.com/apache/shardingsphere/issues/19303


-- 
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 #19303: sql hint and other strategies are configured at the same time, regardless of the order of strategies, they are routed by sqlhint

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

   @peilinqian Thank you for your feedback, I will investigate this 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