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

   for the below configuration, if I comment out the `sharding` rule then the 
`shadow` function is working well:
   
   *configuration*
   ```yaml
   mode:
     type: Standalone
   props:
     sql-show: true
   dataSources:
     db-order0:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3306/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
     db-order1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3307/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
     db-order2:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3308/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
   rules:
     - !SINGLE
       tables:
         - "*.*"
   #  - !SHARDING
   #    tables:
   #      user:
   #        actualDataNodes: db-order$->{0..2}.user
   #        databaseStrategy:
   #          standard:
   #            shardingColumn: id
   #            shardingAlgorithmName: inline
   #    shardingAlgorithms:
   #      inline:
   #        type: INLINE
   #        props:
   #          algorithm-expression: db-order$->{id % 2}
     - !SHADOW
       dataSources:
         shadowDataSource:
           productionDataSourceName: db-order1
           shadowDataSourceName: db-order2
       tables:
         user:
           dataSourceNames:
             - shadowDataSource
           shadowAlgorithmNames:
             - user_id_insert_match_algorithm
       defaultShadowAlgorithmName:
       shadowAlgorithms:
         user_id_insert_match_algorithm:
           type: VALUE_MATCH
           props:
             operation: insert
             column: id
             value: 1
   ```
   
   *output*
   ```sql
   Logic SQL: INSERT INTO user  ( id )  VALUES (  ?  )
   # This SQL is successfully rotated to shadow database db-order2
   Actual SQL: db-order2 ::: INSERT INTO user  ( id )  VALUES (  ?  ) ::: [1]
   Logic SQL: INSERT INTO user  ( id )  VALUES (  ?  )
   Actual SQL: db-order1 ::: INSERT INTO user  ( id )  VALUES (  ?  ) ::: [2]
   ```
   
   But if I add `sharding` rules, the `shadow` function doesn't work using the 
exact same sql.
   
   *conofiguration*
   
   ```yaml
   mode:
     type: Standalone
   props:
     sql-show: true
   dataSources:
     db-order0:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3306/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
     db-order1:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3307/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
     db-order2:
       dataSourceClassName: com.zaxxer.hikari.HikariDataSource
       driverClassName: com.mysql.cj.jdbc.Driver
       jdbcUrl: 
jdbc:mysql://localhost:3308/sharding?allowPublicKeyRetrieval=true
       username: root
       password: 123456
   rules:
     - !SINGLE
       tables:
         - "*.*"
     - !SHARDING
       tables:
         user:
           actualDataNodes: db-order$->{0..2}.user
           databaseStrategy:
             standard:
               shardingColumn: id
               shardingAlgorithmName: inline
       shardingAlgorithms:
         inline:
           type: INLINE
           props:
             algorithm-expression: db-order$->{id % 2}
     - !SHADOW
       dataSources:
         shadowDataSource:
           productionDataSourceName: db-order1
           shadowDataSourceName: db-order2
       tables:
         user:
           dataSourceNames:
             - shadowDataSource
           shadowAlgorithmNames:
             - user_id_insert_match_algorithm
       defaultShadowAlgorithmName:
       shadowAlgorithms:
         user_id_insert_match_algorithm:
           type: VALUE_MATCH
           props:
             operation: insert
             column: id
             value: 1
   ```
   
   *output*
   
   ```sql
   Logic SQL: INSERT INTO user  ( id )  VALUES (  ?  )
   # This SQL should be routed to shadow database db-order2
   Actual SQL: db-order1 ::: INSERT INTO user  ( id )  VALUES (?) ::: [1]
   Logic SQL: INSERT INTO user  ( id )  VALUES (  ?  )
    Actual SQL: db-order0 ::: INSERT INTO user  ( id )  VALUES (?) ::: [2]
   ```
   
   I'm not sure is it normal or something went wrong in my configuration.


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