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/06/19 10:30:52 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #18424: Is it possible to detect unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY for tables rule

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

   ## Feature Request
   
   ### Is your feature request related to a problem?
   Yes
   
   ### Describe the feature you would like.
   I've found several times in GitHub issues and our forums, unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY might cause issue.
   
   Is it possible to detect unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY for tables rule?
   
   #### 2 examples that cause issue
   
   Example 1:
   ```
   mysql> CREATE SHARDING ALGORITHM database_inline (
       -> TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 2}"))
       -> );
   Query OK, 0 rows affected (0.87 sec)
   
   mysql> CREATE SHARDING ALGORITHM t_order_inline (
       -> TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_${order_id % 2}"))
       -> );
   Query OK, 0 rows affected (0.45 sec)
   
   mysql> CREATE SHARDING TABLE RULE t_order (
       -> DATANODES("ds_${0..1}.t_order_0"),
       -> DATABASE_STRATEGY(TYPE=standard,SHARDING_COLUMN=user_id,SHARDING_ALGORITHM=database_inline),
       -> TABLE_STRATEGY(TYPE=standard,SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=t_order_inline),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> );
   Query OK, 0 rows affected (0.55 sec)
   ```
   `DATANODES("ds_${0..1}.t_order_0")` is wrong, it should be `DATANODES("ds_${0..1}.t_order_${0..1}")`, but it's not detected.
   
   Example 2:
   ```
   mysql> CREATE SHARDING ALGORITHM database_inline (
       -> TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 2}"))
       -> );
   Query OK, 0 rows affected (0.87 sec)
   
   mysql> CREATE SHARDING ALGORITHM t_order_inline (
       -> TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="t_order_${order_id % 2}"))
       -> );
   Query OK, 0 rows affected (0.45 sec)
   
   mysql> CREATE SHARDING TABLE RULE t_order (
       -> DATANODES("ds_${0..1}.t_order_${0..1}"),
       -> DATABASE_STRATEGY(TYPE=standard,SHARDING_COLUMN=user_id,SHARDING_ALGORITHM=database_inline),
       -> TABLE_STRATEGY(TYPE=standard,SHARDING_COLUMN=order_id,SHARDING_ALGORITHM=t_order_inline),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> );
   Query OK, 0 rows affected (0.55 sec)
   
   mysql> CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   Query OK, 0 rows affected (0.86 sec)
   
   mysql> ALTER SHARDING ALGORITHM database_inline (
       -> TYPE(NAME=INLINE,PROPERTIES("algorithm-expression"="ds_${user_id % 3 + 2}"))
       -> );
   Query OK, 0 rows affected (0.55 sec)
   
   mysql> insert into t_order (order_id, user_id, status) values (1,2,'ok');
   ERROR 1997 (C1997): Runtime exception: [Route table ds_4 does not exist, available actual table: [ds_0, ds_1]]
   ```
   
   #### Possible solution?
   
   It might be difficult to detect it, since we could not iterate all values and evaluate `algorithm-expression` to get all data nodes.
   
   Any ideas?
   
   


-- 
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] github-actions[bot] closed issue #18424: Is it possible to detect unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY for tables rule

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed issue #18424: Is it possible to detect unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY for tables rule
URL: https://github.com/apache/shardingsphere/issues/18424


-- 
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] github-actions[bot] commented on issue #18424: Is it possible to detect unmatched DATANODES and DATABASE_STRATEGY / TABLE_STRATEGY for tables rule

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #18424:
URL: https://github.com/apache/shardingsphere/issues/18424#issuecomment-1272349599

   Hello , this issue has not received a reply for several days.
   This issue is supposed to be closed.


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