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

   ## Bug Report
   
   Table 'cmdb_user' is configured with three databases, and each database is 
configured with three sub-tables.
   
   When I execute `insert into cmdb_user (user_id, id1, id2 )values(2,1,1);`, 
it insert one records correctly.
   
   When I execute `insert into cmdb_user (user_id, id1, id2 )values(2,1,1);`, 
it insert a records into each of the sub-tables of three databases,  insert 9 
records totally. 
   
   ### Which version of ShardingSphere did you use?
   
   tag:5.2.0, commitid:8dee990098fd2cb000079ce1a933c530e8d0a704
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   
   ShardingSphere-Proxy
   
   ### Expected behavior
   
   execute`insert into cmdb_user insert into cmdb_user (user_id, id1, id2 ) 
select 3, 3, 3;` can insert one record based databaseStrategy and 
tableStrategy, which is similar to `insert into cmdb_user (user_id, id1, id2 
)values(2,1,1);`.
   
   ### Actual behavior
   
   It insert the same record into each table, insert 9 records totally. 
   
   ### Reason analyze (If you can)
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
![image-20220921155619430](https://user-images.githubusercontent.com/27768675/191448248-cbdd5b9a-601e-4d64-a651-045cc914954e.png)
   
![image-20220921153808493](https://user-images.githubusercontent.com/27768675/191448244-16589278-056d-4ab6-91a2-5a8141a2a1b7.png)
   
   
   
   ### Example codes for reproduce this issue (such as a github link).
   
   ```yaml
   rules:
     - !AUTHORITY
       users:
         - root@%:root
         - sharding@:sharding
       provider:
         type: ALL_PRIVILEGES_PERMITTED
     - !TRANSACTION
       defaultType: XA
       providerType: Atomikos
   props:
     max-connections-size-per-query: 1
     executor-size: 16  # Infinite by default.
     sql-show: true
     proxy-frontend-flush-threshold: 128  # The default value is 128.
     proxy.transaction.type: XA
   ```
   
   ```yaml
   databaseName: sharding_db
   dataSources:
     ds_0:
       url: 
jdbc:opengauss://XXX:XXX/tpccdb?serverTimezone=UTC&useSSL=false&connectTimeout=10&batchMode=on&loggerLevel=OFF
       username: XXX
       password: Huawei@123
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     ds_1:
       url: 
jdbc:opengauss://XXX:XXX/tpccdb?serverTimezone=UTC&useSSL=false&connectTimeout=10&batchMode=on&loggerLevel=OFF
       username: XXX
       password: Huawei@123
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
     ds_2:
       url: 
jdbc:opengauss://XXX:XXX/tpccdb?serverTimezone=UTC&useSSL=false&connectTimeout=10&batchMode=on&loggerLevel=OFF
       username: XXX
       password: Huawei@123
       connectionTimeoutMilliseconds: 30000
       idleTimeoutMilliseconds: 60000
       maxLifetimeMilliseconds: 1800000
       maxPoolSize: 50
   
   rules:
     - !SHARDING
       tables:
         cmdb_user:
           actualDataNodes: ds_${0..2}.cmdb_user_${0..2}
           databaseStrategy:
             standard:
               shardingAlgorithmName: ds_user_alg
               shardingColumn: user_id
           tableStrategy:
             standard:
               shardingAlgorithmName: ts_user_alg
               shardingColumn: user_id
         t_order:
           actualDataNodes: ds_${0..1}.t_order_${0..1}
           tableStrategy:
             standard:
               shardingColumn: order_id
               shardingAlgorithmName: t-order-inline
           keyGenerateStrategy:
             column: order_id
             keyGeneratorName: snowflake
         t_order_item:
           actualDataNodes: ds_${0..1}.t_order_item_${0..1}
           tableStrategy:
             standard:
               shardingColumn: order_id
               shardingAlgorithmName: t_order-item-inline
           keyGenerateStrategy:
             column: order_item_id
             keyGeneratorName: snowflake
         t_account:
           actualDataNodes: ds_${0..1}.t_account_${0..1}
           tableStrategy:
             standard:
               shardingAlgorithmName: t-account-inline
           keyGenerateStrategy:
             column: account_id
             keyGeneratorName: snowflake
       defaultShardingColumn: account_id
       bindingTables:
         - t_order,t_order_item
         - cmdb_user
       broadcastTables:
         - t_address
       defaultDatabaseStrategy:
         standard:
           shardingColumn: user_id
           shardingAlgorithmName: database-inline
       defaultTableStrategy:
         none:
   
       shardingAlgorithms:
         ds_user_alg:
           props:
             algorithm-expression: ds_${user_id % 3}
           type: INLINE
         ts_user_alg:
           props:
             algorithm-expression: cmdb_user_${user_id % 3}
           type: INLINE
         database-inline:
           type: INLINE
           props:
             algorithm-expression: ds_${user_id % 2}
         t-order-inline:
           type: INLINE
           props:
             algorithm-expression: t_order_${order_id % 2}
         t_order-item-inline:
           type: INLINE
           props:
             algorithm-expression: t_order_item_${order_id % 2}
         t-account-inline:
           type: INLINE
           props:
             algorithm-expression: t_account_${account_id % 2}
       keyGenerators:
         snowflake:
           type: SNOWFLAKE
   ```
   
   


-- 
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: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to