apache / apache/shardingsphere
Sharding5.3.2:shadow rule error
- Dominant language
- Java
- Stars
- 20.8k
- Forks
- 6.9k
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 326
Description
``` Version ```
Springboot 2.7.18
ShardingJdbc 5.3.2
``` Resource step ```
PartialSQLRouteExecutor#route
=> step1: sharding rule => RouteUnit(dataSourceMap, tableMap);
=> step2: shadow rule
=> ShadowSQLRouter#decorateRouteContext
=>AbstractShadowDMLStatementRouteEngine#route
=>ShadowRouteEngine#decorateRouteContext
``` yml ```
props:
sql-show: true
dataSources:
db_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://ip1:3306/db_0?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root
password: ***
db_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://ip1:3306/db_1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root
password: ***
shadow_0:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://ip1:3306/shadow_0?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root
password: ***
shadow_1:
dataSourceClassName: com.zaxxer.hikari.HikariDataSource
driverClassName: com.mysql.jdbc.Driver
jdbcUrl: jdbc:mysql://ip1:3306/shadow_1?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root
password: ***
rules:
- !SHARDING
shardingAlgorithms:
table_inline:
type: INLINE
props:
algorithm-expression: order_tbl_$->{Math.abs(order_no.hashCode()) % 2}
database_inline:
type: INLINE
props:
algorithm-expression: db_$->{Math.abs(user_id.hashCode()) % 2}
defaultDatabaseStrategy:
standard:
shardingColumn: user_id
shardingAlgorithmName: database_inline
defaultTableStrategy:
standard:
shardingColumn: order_no
shardingAlgorithmName: table_inline
tables:
order_tbl:
actualDataNodes: db_$->{0..1}.order_tbl_$->{0..1}
- !SHADOW
dataSources:
shadowDataSource1:
productionDataSourceName: db_1
shadowDataSourceName: shadow_1
tables:
order_tbl:
dataSourceNames:
- shadowDataSource1
shadowAlgorithmNames:
- user_id_value
shadowAlgorithms:
user_id_value:
type: VALUE_MATCH
props:
operation: select
column: user_id
value: x3
Contributor guide
Research direction
Start at PartialSQLRouteExecutor#route and trace the provided flow through ShadowSQLRouter#decorateRouteContext, AbstractShadowDMLStatementRouteEngine#route, and ShadowRouteEngine#decorateRouteContext. Reproduce the behavior with the supplied Spring Boot, sharding, and shadow-rule configuration, then determine where the shadow route diverges from the configured data sources and table. Done means the reported shadow-rule error is explained and corrected with a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mysql, spring-boot
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100