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/11/10 11:30:36 UTC

[GitHub] [shardingsphere] RaigorJiang commented on issue #22058: DROP READWRITE_SPLITTING RULE failed

RaigorJiang commented on issue #22058:
URL: https://github.com/apache/shardingsphere/issues/22058#issuecomment-1310145360

   Hi @peilinqian 
   Thanks for your feedback, and I have reproduced the problem from master branch.
   
   We get this error message because a single table already exists in the resource registered, and after creating the `READWRITE_SPLITTING RULE`, the single table will use the aggregate data source `readwrite_ds`.
   Therefore, if there is no table in the registered resource, this `readwrite_ds` can be dropped.
   
   ### The latest reproduction process:
   ```sql
   REGISTER STORAGE UNIT write_ds (
       HOST="127.0.0.1",
       PORT=3306,
       DB="demo_write_ds",
       USER="root",
       PASSWORD="123456"
   ), read_ds (
       HOST="127.0.0.1",
       PORT=3306,
       DB="demo_read_ds",
       USER="root",
       PASSWORD="123456"
   );
   
   SET DEFAULT SINGLE TABLE STORAGE UNIT = write_ds;
   
   CREATE TABLE `t_order` (
     `order_id` bigint(20) NOT NULL AUTO_INCREMENT,
     `user_id` int(11) NOT NULL,
     `status` varchar(50) DEFAULT NULL,
     PRIMARY KEY (`order_id`)
   );
   
   CREATE READWRITE_SPLITTING RULE group_0 (
   WRITE_STORAGE_UNIT=write_ds,
   READ_STORAGE_UNITS(read_ds),
   TYPE(NAME="random")
   );
   
   DROP READWRITE_SPLITTING RULE group_0;
   ````
   
   Error: Readwrite splitting rules `[group_0]` in database `xxx` are still in used.
   
   ### Analyze
   I would say that this restriction is actually correct. Consider a scenario:
   When `write_ds` and `read_ds` are a set of primary-replica cluster, when there is already a table, dropping the rule may cause `INSERT SQL` to be routed to `read_ds`, which will cause serious errors.
   
   Therefore, if there is already a single table in the logic database that uses `readwrite_ds`, dropping rule is not allowed.
   
   So, what are the scenarios where you need to drop the rules when using the primary-replica cluster?


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