Skip to content

Commit

Permalink
Merge branch 'master' into coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
debebantur committed Aug 8, 2023
2 parents 4c01073 + a92cd05 commit 280ee50
Show file tree
Hide file tree
Showing 17 changed files with 427 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docker/coordinator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM spqr-base-image

ENTRYPOINT /spqr/spqr-coordinator -c ${SPQR_CONFIG=/spqr/docker/coordinator/cfg.yaml}
ENTRYPOINT /spqr/spqr-coordinator -c ${COORDINATOR_CONFIG=/spqr/docker/coordinator/cfg.yaml}
2 changes: 1 addition & 1 deletion docker/router/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM spqr-base-image

ENTRYPOINT CONFIG_PATH=${SPQR_CONFIG=/spqr/docker/router/cfg.yaml} && CUR_HOST=$(cat ${CONFIG_PATH} | grep "host:") && sed -i "s/${CUR_HOST}/${ROUTER_HOST=${CUR_HOST}}/g" ${CONFIG_PATH} && /spqr/spqr-router run -c ${CONFIG_PATH} --proto-debug
ENTRYPOINT CONFIG_PATH=${ROUTER_CONFIG=/spqr/docker/router/cfg.yaml} && CUR_HOST=$(cat ${CONFIG_PATH} | grep "host:") && sed -i "s/${CUR_HOST}/${ROUTER_HOST=${CUR_HOST}}/g" ${CONFIG_PATH} && /spqr/spqr-router run -c ${CONFIG_PATH} --proto-debug
8 changes: 4 additions & 4 deletions docs/Router.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ All SPQR configurations can be written in json, yaml or toml format. See example
| `admin_console_port` | the admin console port |
| `grpc_api_port` | the API port |
| | |
| `init_sql` | a path to a sql commands, that will be run on the startup of the router. |
| `init_sql` | a path to a SQL command, that will be run on the router's startup. It will be ignored if memqdb_backup_path exists. |
| `router_mode` | mode in which router will be run. Can be LOCAL and PROXY. In local mode spqr works like an usual connection pooler with one shard, in proxy mode works with many shards. |
| `jaeger_url` | a path to the Jaeger instance - open source software for tracing transactions between distributed services |
| `world_shard_fallback` | can be true or false. If false, then router will raise an error when query will be impossible to send to particular shard. If true, then router will route unrouted query to the world shard. |
| `show_notice_messages` | can be true or false. May help to debug the router and see to where it is actualy sending queries |
| `time_quantiles` | list of time quantiles to show querry time statistics. When empty, no statistics is collected |
| `memqdb_backup_path` | if specified, memqdb will backup state into file, and router will try to restore from this backup on starup |
| `show_notice_messages` | can be true or false. May help to debug the router and see to where it is actualy sending queries |
| `time_quantiles` | list of time quantiles to show querry time statistics. When empty, no statistics is collected |
| `memqdb_backup_path` | MemQDB backup state path. MemQDB's state restored if a file backup exists during the router startup. If there is no file, init.sql will be used. |


### frontend_tls
Expand Down
2 changes: 1 addition & 1 deletion router/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewRouter(ctx context.Context, rcfg *config.Router) (*InstanceImpl, error)
return nil, err
}

if skipInitSQL {
if !skipInitSQL {
for _, fname := range []string{
rcfg.InitSQL,
} {
Expand Down
3 changes: 3 additions & 0 deletions test/feature/conf/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ADD SHARDING RULE rule1 COLUMNS id;
ADD SHARDING RULE rule2 TABLE test COLUMNS idx;
ADD SHARDING RULE rule3 COLUMNS idy;
1 change: 0 additions & 1 deletion test/feature/conf/router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ admin_console_port: '7432'
grpc_api_port: '7000'
router_mode: PROXY
log_level: fatal
memqdb_backup_path: memqdb.backup
log_filename: router.log
time_quantiles:
- 0.75
Expand Down
47 changes: 47 additions & 0 deletions test/feature/conf/router_with_backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
host: 'regress_router'
router_port: '6432'
admin_console_port: '7432'
grpc_api_port: '7000'
router_mode: PROXY
log_level: fatal
memqdb_backup_path: memqdb.backup
log_filename: router.log
time_quantiles:
- 0.75
world_shard_fallback: true
show_notice_messages: true
frontend_rules:
- db: regress
usr: regress
pool_default: true
pool_mode: TRANSACTION
auth_rule:
auth_method: ok
shards:
sh1:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_1:6432'
sh2:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_2:6432'

backend_rules:
- db: regress
usr: regress
pool_discard: true
pool_rollback: true
auth_rules:
sh1:
auth_method: md5
password: 12345678
sh2:
auth_method: md5
password: 12345678
48 changes: 48 additions & 0 deletions test/feature/conf/router_with_backup_and_initsql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
host: 'regress_router'
router_port: '6432'
admin_console_port: '7432'
grpc_api_port: '7000'
router_mode: PROXY
log_level: fatal
memqdb_backup_path: memqdb.backup
init_sql: /spqr/test/feature/conf/init.sql
log_filename: router.log
time_quantiles:
- 0.75
world_shard_fallback: true
show_notice_messages: true
frontend_rules:
- db: regress
usr: regress
pool_default: true
pool_mode: TRANSACTION
auth_rule:
auth_method: ok
shards:
sh1:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_1:6432'
sh2:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_2:6432'

backend_rules:
- db: regress
usr: regress
pool_discard: true
pool_rollback: true
auth_rules:
sh1:
auth_method: md5
password: 12345678
sh2:
auth_method: md5
password: 12345678
48 changes: 48 additions & 0 deletions test/feature/conf/router_with_fake_initsql_and_backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
host: 'regress_router'
router_port: '6432'
admin_console_port: '7432'
grpc_api_port: '7000'
router_mode: PROXY
log_level: fatal
memqdb_backup_path: memqdb.backup
init_sql: /spqr/test/feature/conf/fake_init.sql
log_filename: router.log
time_quantiles:
- 0.75
world_shard_fallback: true
show_notice_messages: true
frontend_rules:
- db: regress
usr: regress
pool_default: true
pool_mode: TRANSACTION
auth_rule:
auth_method: ok
shards:
sh1:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_1:6432'
sh2:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_2:6432'

backend_rules:
- db: regress
usr: regress
pool_discard: true
pool_rollback: true
auth_rules:
sh1:
auth_method: md5
password: 12345678
sh2:
auth_method: md5
password: 12345678
47 changes: 47 additions & 0 deletions test/feature/conf/router_with_initsql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
host: 'regress_router'
router_port: '6432'
admin_console_port: '7432'
grpc_api_port: '7000'
router_mode: PROXY
log_level: fatal
init_sql: /spqr/test/feature/conf/init.sql
log_filename: router.log
time_quantiles:
- 0.75
world_shard_fallback: true
show_notice_messages: true
frontend_rules:
- db: regress
usr: regress
pool_default: true
pool_mode: TRANSACTION
auth_rule:
auth_method: ok
shards:
sh1:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_1:6432'
sh2:
db: regress
usr: regress
pwd: 12345678
type: DATA
hosts:
- 'spqr_shard_2:6432'

backend_rules:
- db: regress
usr: regress
pool_discard: true
pool_rollback: true
auth_rules:
sh1:
auth_method: md5
password: 12345678
sh2:
auth_method: md5
password: 12345678
6 changes: 3 additions & 3 deletions test/feature/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ services:
- "6432:6432"
- "7432:7432"
environment:
- SPQR_CONFIG=/spqr/test/feature/conf/router.yaml
- ROUTER_CONFIG=${ROUTER_CONFIG}
- 'ROUTER_HOST=host: ''regress_router'''
hostname: regress_router
container_name: regress_router
Expand All @@ -56,7 +56,7 @@ services:
- "6433:6432"
- "7433:7432"
environment:
- SPQR_CONFIG=/spqr/test/feature/conf/router.yaml
- ROUTER_CONFIG=${ROUTER_CONFIG}
- 'ROUTER_HOST=host: ''regress_router_2'''
hostname: regress_router_2
container_name: regress_router_2
Expand All @@ -74,7 +74,7 @@ services:
- "7002:7002"
- "7003:7003"
environment:
- SPQR_CONFIG=/spqr/test/feature/conf/coordinator.yaml
- COORDINATOR_CONFIG=${COORDINATOR_CONFIG}
hostname: regress_coordinator
container_name: regress_coordinator
depends_on:
Expand Down
6 changes: 1 addition & 5 deletions test/feature/features/coordinator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,7 @@ Feature: Coordinator test
Then command return code should be "0"
And SQL result should match regexp
"""
"Key range ID":"krid1".*"Lower bound":"0".*"Upper bound":"11"
"""
And SQL result should match regexp
"""
"Key range ID":"krid2".*"Lower bound":"11".*"Upper bound":"31"
\[\]
"""

Scenario: QDB is down
Expand Down
Loading

0 comments on commit 280ee50

Please sign in to comment.