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/04/25 08:57:20 UTC

[GitHub] [shardingsphere] zjcnb opened a new pull request, #17088: In-memory RuleConfiguration not change when scaling job not finished.

zjcnb opened a new pull request, #17088:
URL: https://github.com/apache/shardingsphere/pull/17088

   Fixes #16924 , #17045 
   
   
   ```
   mysql> SHOW SHARDING TABLE RULE t_order \G;
   *************************** 1. row ***************************
                               table: t_order
                   actual_data_nodes: ds_${0..1}.t_order_${0..1}
                 actual_data_sources:
              database_strategy_type: INLINE
            database_sharding_column: user_id
    database_sharding_algorithm_type: INLINE
   database_sharding_algorithm_props: algorithm-expression=ds_${user_id % 2}
                 table_strategy_type: INLINE
               table_sharding_column: order_id
       table_sharding_algorithm_type: INLINE
      table_sharding_algorithm_props: algorithm-expression=t_order_${order_id % 2}
                 key_generate_column: order_id
                  key_generator_type: SNOWFLAKE
                 key_generator_props:
   1 row in set (0.00 sec)
   
   ERROR:
   No query specified
   
   mysql>
   mysql>
   mysql>
   mysql>
   mysql> ALTER SHARDING TABLE RULE t_order(
       ->    RESOURCES(ds_2,ds_3,ds_4),
       ->    SHARDING_COLUMN=order_id,
       ->    TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
       ->    KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       ->    ), t_order_item(
       ->    RESOURCES(ds_2,ds_3,ds_4),
       ->    SHARDING_COLUMN=order_id,
       ->    TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
       ->    KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       ->    );
   Query OK, 0 rows affected (3.50 sec)
   
   mysql> SHOW SHARDING TABLE RULE t_order \G;
   *************************** 1. row ***************************
                               table: t_order
                   actual_data_nodes: ds_${0..1}.t_order_${0..1}
                 actual_data_sources:
              database_strategy_type: INLINE
            database_sharding_column: user_id
    database_sharding_algorithm_type: INLINE
   database_sharding_algorithm_props: algorithm-expression=ds_${user_id % 2}
                 table_strategy_type: INLINE
               table_sharding_column: order_id
       table_sharding_algorithm_type: INLINE
      table_sharding_algorithm_props: algorithm-expression=t_order_${order_id % 2}
                 key_generate_column: order_id
                  key_generator_type: SNOWFLAKE
                 key_generator_props:
   1 row in set (0.01 sec)
   ```


-- 
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 pull request #17088: In-memory RuleConfiguration not change when scaling job not finished.

Posted by GitBox <gi...@apache.org>.
zjcnb commented on PR #17088:
URL: https://github.com/apache/shardingsphere/pull/17088#issuecomment-1108416389

   ```
   zhaojinchao@zhaojinchaoçš„MacBook ~ % mysql -uroot -h127.0.0.1 -P3307 -proot
   mysql: [Warning] Using a password on the command line interface can be insecure.
   Welcome to the MySQL monitor.  Commands end with ; or \g.
   Your MySQL connection id is 1
   Server version: 5.7.22-ShardingSphere-Proxy 5.1.2-SNAPSHOT-03222c7
   
   Copyright (c) 2000, 2021, Oracle and/or its affiliates.
   
   Oracle is a registered trademark of Oracle Corporation and/or its
   affiliates. Other names may be trademarks of their respective
   owners.
   
   Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
   
   mysql> create database test1;
   Query OK, 0 rows affected (0.13 sec)
   
   mysql> ADD RESOURCE ds_0 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_0?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> ), ds_1 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_1?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> );
   ERROR 1046 (3D000): No database selected
   mysql> use test1;
   Database changed
   mysql> ADD RESOURCE ds_0 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_0?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> ), ds_1 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_1?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> );
   
   Query OK, 0 rows affected (1.10 sec)
   
   mysql>
   mysql> CREATE SHARDING TABLE RULE t_order(
       -> RESOURCES(ds_0,ds_1),
       -> SHARDING_COLUMN=order_id,
       -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=4)),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> ), t_order_item(
       -> RESOURCES(ds_0,ds_1),
       -> SHARDING_COLUMN=order_id,
       -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=4)),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> );
   Query OK, 0 rows affected (2.14 sec)
   
   mysql> CREATE TABLE t_order (order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, PRIMARY KEY (order_id));
   
   CREATE TABLE t_order_item (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, creation_date DATE, PRIMARY KEY (item_id));
   Query OK, 0 rows affected (0.47 sec)
   
   mysql>
   mysql> CREATE TABLE t_order_item (item_id INT NOT NULL, order_id INT NOT NULL, user_id INT NOT NULL, status VARCHAR(45) NULL, creation_date DATE, PRIMARY KEY (item_id));
   Query OK, 0 rows affected (0.11 sec)
   
   mysql> insert into t_order (order_id, user_id, status) values (1,2,'ok'),(2,4,'ok'),(3,6,'ok'),(4,1,'ok'),(5,3,'ok'),(6,5,'ok');
   Query OK, 6 rows affected (0.11 sec)
   
   mysql>
   mysql> insert into t_order_item (item_id, order_id, user_id, status) values (1,1,2,'ok'),(2,2,4,'ok'),(3,3,6,'ok'),(4,4,1,'ok'),(5,5,3,'ok'),(6,6,5,'ok');
   Query OK, 6 rows affected (0.03 sec)
   
   mysql> preview select count(1) from t_order;
   +------------------+-------------------------------------------------------------------------+
   | data_source_name | actual_sql                                                              |
   +------------------+-------------------------------------------------------------------------+
   | ds_0             | select count(1) from t_order_0 UNION ALL select count(1) from t_order_2 |
   | ds_1             | select count(1) from t_order_1 UNION ALL select count(1) from t_order_3 |
   +------------------+-------------------------------------------------------------------------+
   2 rows in set (0.10 sec)
   
   mysql>
   mysql> preview select count(1) from t_order_item;
   +------------------+-----------------------------------------------------------------------------------+
   | data_source_name | actual_sql                                                                        |
   +------------------+-----------------------------------------------------------------------------------+
   | ds_0             | select count(1) from t_order_item_0 UNION ALL select count(1) from t_order_item_2 |
   | ds_1             | select count(1) from t_order_item_1 UNION ALL select count(1) from t_order_item_3 |
   +------------------+-----------------------------------------------------------------------------------+
   2 rows in set (0.00 sec)
   
   mysql> ADD RESOURCE ds_2 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_10?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> ), ds_3 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_11?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> ), ds_4 (
       ->     URL="jdbc:mysql://127.0.0.1:3306/scaling_ds_12?serverTimezone=UTC&useSSL=false",
       ->     USER=root,
       ->     PASSWORD=123456,
       ->     PROPERTIES("maximumPoolSize"=50,"idleTimeout"="60000")
       -> );
   Query OK, 0 rows affected (0.73 sec)
   
   mysql> CREATE SHARDING SCALING RULE scaling_auto2 (
       -> COMPLETION_DETECTOR(TYPE(NAME=IDLE, PROPERTIES("incremental-task-idle-minute-threshold"=1))),
       -> DATA_CONSISTENCY_CHECKER(TYPE(NAME=CRC32_MATCH))
       -> );
   Query OK, 0 rows affected (0.25 sec)
   
   mysql> ALTER SHARDING TABLE RULE t_order(
       -> RESOURCES(ds_2,ds_3,ds_4),
       -> SHARDING_COLUMN=order_id,
       -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> ), t_order_item(
       -> RESOURCES(ds_2,ds_3,ds_4),
       -> SHARDING_COLUMN=order_id,
       -> TYPE(NAME=hash_mod,PROPERTIES("sharding-count"=6)),
       -> KEY_GENERATE_STRATEGY(COLUMN=order_id,TYPE(NAME=snowflake))
       -> );
   Query OK, 0 rows affected (0.14 sec)
   
   mysql>  show scaling list;
   +----------------------------------+----------------------+----------------------+--------+---------------------+-----------+
   | id                               | tables               | sharding_total_count | active | create_time         | stop_time |
   +----------------------------------+----------------------+----------------------+--------+---------------------+-----------+
   | 0130317c30317c3054317c7465737431 | t_order,t_order_item | 2                    | true   | 2022-04-25 18:54:55 | NULL      |
   +----------------------------------+----------------------+----------------------+--------+---------------------+-----------+
   1 row in set (0.10 sec)
   
   mysql> show scaling status 0130317c30317c3054317c7465737431
       -> ;
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | item | data_source | status                   | active | inventory_finished_percentage | incremental_idle_seconds |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | 0    | ds_0        | EXECUTE_INCREMENTAL_TASK | true   | 100                           | 6                        |
   | 1    | ds_1        | EXECUTE_INVENTORY_TASK   | true   | 50                            | 0                        |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   2 rows in set (0.01 sec)
   
   mysql> show scaling status 0130317c30317c3054317c7465737431;
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | item | data_source | status                   | active | inventory_finished_percentage | incremental_idle_seconds |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | 0    | ds_0        | EXECUTE_INCREMENTAL_TASK | true   | 100                           | 25                       |
   | 1    | ds_1        | EXECUTE_INCREMENTAL_TASK | true   | 100                           | 24                       |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   2 rows in set (0.01 sec)
   
   mysql> show scaling status 0130317c30317c3054317c7465737431;
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | item | data_source | status                   | active | inventory_finished_percentage | incremental_idle_seconds |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   | 0    | ds_0        | EXECUTE_INCREMENTAL_TASK | true   | 100                           | 26                       |
   | 1    | ds_1        | EXECUTE_INCREMENTAL_TASK | true   | 100                           | 26                       |
   +------+-------------+--------------------------+--------+-------------------------------+--------------------------+
   2 rows in set (0.01 sec)
   
   mysql> show scaling status 0130317c30317c3054317c7465737431;
   +------+-------------+----------+--------+-------------------------------+--------------------------+
   | item | data_source | status   | active | inventory_finished_percentage | incremental_idle_seconds |
   +------+-------------+----------+--------+-------------------------------+--------------------------+
   | 0    | ds_0        | FINISHED | false  | 100                           | 81                       |
   | 1    | ds_1        | FINISHED | false  | 100                           | 81                       |
   +------+-------------+----------+--------+-------------------------------+--------------------------+
   2 rows in set (0.01 sec)
   ```


-- 
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] sandynz merged pull request #17088: In-memory RuleConfiguration not change when scaling job not finished.

Posted by GitBox <gi...@apache.org>.
sandynz merged PR #17088:
URL: https://github.com/apache/shardingsphere/pull/17088


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