apache / apache/shardingsphere

Shadowing with batch insert does not have effect.

Open
#31,448 2 comments 0 reactions 0 assignees View on GitHub
feature: shadow status: volunteer wanted type: bug
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
11h 35m
Merged PRs (30d)
326

Description

## Question
shardingsphere: 5.5.0

config.yaml:
```
rules:
- !SINGLE
tables:
- "*.*"
- !SHADOW
dataSources:
shadowDataSource:
productionDataSourceName: ds
shadowDataSourceName: ds_shadow
tables:
t_user:
dataSourceNames:
- shadowDataSource
shadowAlgorithmNames:
- user_id_insert_match_algorithm
- user_id_delete_match_algorithm
- user_id_select_match_algorithm
- sql_hint_algorithm
shadowAlgorithms:
user_id_insert_match_algorithm:
type: REGEX_MATCH
props:
operation: insert
column: user_type
regex: "[1]"
user_id_delete_match_algorithm:
type: REGEX_MATCH
props:
operation: delete
column: user_type
regex: "[1]"
user_id_select_match_algorithm:
type: REGEX_MATCH
props:
operation: select
column: user_type
regex: "[1]"
sql_hint_algorithm:
type: SQL_HINT
props:
shadow: true
foo: bar
#打印sql
props:
sql-show: true
```
the sql printed in console as follows, records by rule do not come into shadow db:
```
2024-05-30T16:29:26.851+08:00 INFO 17544 --- [nio-8088-exec-9] ShardingSphere-SQL : Logic SQL: insert into t_user (user_id, user_type, username, pwd)
values

(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?)
2024-05-30T16:29:26.852+08:00 INFO 17544 --- [nio-8088-exec-9] ShardingSphere-SQL : Actual SQL: ds ::: insert into t_user (user_id, user_type, username, pwd)
values

(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?)
,
(?, ?, ?,
?) ::: [0, 0, test2, 123456, 0, 1, test3, 123456, 0, 0, test4, 123456, 0, 1, test5, 123456, 0, 0, test6, 123456]
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the batch insert from the issue with the provided config.yaml and inspect the shadow-routing path for batch values. Compare the routing result with the expected ds_shadow destination, then verify the behavior with a regression case using the shown insert and matching user_type values.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.