-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test number range sharding algorithm (#279)
* test: test number range sharding algorithm
- Loading branch information
1 parent
5a461ec
commit 1d12859
Showing
12 changed files
with
7,547 additions
and
23 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
probe_port: 9999 | ||
termination_drain_duration: 3s | ||
app_config: | ||
# appid, replace with your own appid | ||
svc: | ||
distributed_transaction: | ||
retry_dead_threshold: 130000 | ||
rollback_retry_timeout_unlock_enable: true | ||
etcd_config: | ||
endpoints: | ||
- etcd:2379 | ||
|
||
listeners: | ||
- protocol_type: mysql | ||
socket_address: | ||
address: 0.0.0.0 | ||
port: 13306 | ||
config: | ||
users: | ||
dksl: "123456" | ||
server_version: "8.0.27" | ||
executor: redirect | ||
|
||
executors: | ||
- name: redirect | ||
mode: shd | ||
config: | ||
transaction_timeout: 60000 | ||
db_groups: | ||
- name: world_0 | ||
load_balance_algorithm: RandomWeight | ||
data_sources: | ||
- name: world_0 | ||
weight: r10w10 | ||
- name: world_1 | ||
load_balance_algorithm: RandomWeight | ||
data_sources: | ||
- name: world_1 | ||
weight: r10w10 | ||
global_tables: | ||
- country | ||
- countrylanguage | ||
- pt_city_0 | ||
logic_tables: | ||
- db_name: world | ||
table_name: city | ||
allow_full_scan: true | ||
sharding_rule: | ||
column: id | ||
sharding_algorithm: NumberRange | ||
config: | ||
"0": "1-500" | ||
"1": "500-1000" | ||
"2": "1000-1500" | ||
"3": "1500-2000" | ||
"4": "2000-2500" | ||
"5": "2500-3000" | ||
"6": "3000-3500" | ||
"7": "3500-4000" | ||
"8": "4000-4500" | ||
"9": "4500-5000" | ||
sequence_generator: | ||
# type: segment | ||
type: snowflake | ||
config: | ||
worker_id: 123 | ||
# dsn: root:123456@tcp(dbpack-mysql1:3306)/world?timeout=10s&readTimeout=10s&writeTimeout=10s&parseTime=true&loc=Local&charset=utf8mb4,utf8 | ||
topology: | ||
"0": 0-4 | ||
"1": 5-9 | ||
shadow_rules: | ||
- table_name: city | ||
column: country_code | ||
expr: "%s == \"US\"" | ||
shadow_table_prefix: pt_ | ||
|
||
data_source_cluster: | ||
- name: world_0 | ||
capacity: 10 | ||
max_capacity: 20 | ||
idle_timeout: 60s | ||
dsn: root:123456@tcp(dbpack-mysql1:3306)/world?timeout=10s&readTimeout=10s&writeTimeout=10s&parseTime=true&loc=Local&charset=utf8mb4,utf8 | ||
ping_interval: 20s | ||
ping_times_for_change_status: 3 | ||
filters: | ||
- mysqlDTFilter | ||
|
||
- name: world_1 | ||
capacity: 10 | ||
max_capacity: 20 | ||
idle_timeout: 60s | ||
dsn: root:123456@tcp(dbpack-mysql2:3306)/world?timeout=60s&readTimeout=60s&writeTimeout=60s&parseTime=true&loc=Local&charset=utf8mb4,utf8 | ||
ping_interval: 20s | ||
ping_times_for_change_status: 3 | ||
filters: | ||
- mysqlDTFilter | ||
|
||
filters: | ||
- name: mysqlDTFilter | ||
kind: MysqlDistributedTransaction | ||
conf: | ||
appid: svc | ||
lock_retry_interval: 50ms | ||
lock_retry_times: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
version: "2.3" | ||
services: | ||
etcd: | ||
image: docker.io/bitnami/etcd:3 | ||
container_name: etcd | ||
environment: | ||
- ALLOW_NONE_AUTHENTICATION=yes | ||
- ETCD_NAME=etcd | ||
- ETCD_INITIAL_ADVERTISE_PEER_URLS=http://etcd:2380 | ||
- ETCD_LISTEN_PEER_URLS=http://0.0.0.0:2380 | ||
- ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379 | ||
- ETCD_ADVERTISE_CLIENT_URLS=http://etcd:2379 | ||
- ETCD_INITIAL_CLUSTER_TOKEN=etcd-cluster | ||
- ETCD_INITIAL_CLUSTER=etcd=http://etcd:2380 | ||
- ETCD_INITIAL_CLUSTER_STATE=new | ||
networks: | ||
- local | ||
ports: | ||
- "2379:2379" | ||
mysql1: | ||
image: mysql:8.0 | ||
container_name: dbpack-mysql1 | ||
networks: | ||
- local | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
MYSQL_ROOT_PASSWORD: "123456" | ||
volumes: | ||
- ./scripts/range_world_0.sql:/docker-entrypoint-initdb.d/world_0.sql:rw | ||
command: ['mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci'] | ||
mysql2: | ||
image: mysql:8.0 | ||
container_name: dbpack-mysql2 | ||
networks: | ||
- local | ||
ports: | ||
- "3307:3306" | ||
environment: | ||
MYSQL_ROOT_PASSWORD: "123456" | ||
volumes: | ||
- ./scripts/range_world_1.sql:/docker-entrypoint-initdb.d/world_1.sql:rw | ||
command: [ 'mysqld', '--character-set-server=utf8mb4', '--collation-server=utf8mb4_unicode_ci' ] | ||
dbpack: | ||
build: | ||
context: ${PWD} | ||
dockerfile: ./docker/Dockerfile | ||
container_name: dbpack | ||
networks: | ||
- local | ||
ports: | ||
- "13306:13306" | ||
volumes: | ||
- ./conf/config_shd_range.yaml:/config.yaml | ||
- ./scripts/wait-for-mysql.sh:/wait-for-mysql.sh | ||
depends_on: | ||
- etcd | ||
- mysql1 | ||
- mysql2 | ||
command: ["./wait-for-mysql.sh","--","/dbpack", "start", "-c", "config.yaml"] | ||
networks: | ||
local: | ||
name: dbpack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.