Skip to content

Commit

Permalink
Run coordinator together with router (pg-sharding#287)
Browse files Browse the repository at this point in the history
Dispatch coordinator goroutines with router binary start. Proxy all modifying requests to Coordinator via grpc.

Run admin console in proxy way for several type of queries:

    All modify requests to router console should be proxied to coordinator via particular gRPC-call. It is very dangerous to allow user to modify router metadata, like key-ranges or sharding rules, etc. This only should by done by coordinator or via coord. API.

    All show requests, like SHOW CLIENTS etc should be processed locally. In future, we can support installation-wide
    show requests processing using additional syntax, like SHOW CLIENTS is processed by router but SHOW GLOBAL CLIENTS to be proccesed by coordinator (coord. can process such queries already).
  • Loading branch information
diPhantxm authored and CBists committed Nov 10, 2023
1 parent 3c8946e commit 899e1d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
12 changes: 6 additions & 6 deletions test/feature/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ services:
- "router"
- "router2"
- "qdb01"

coordinator2:
build:
dockerfile: ./docker/coordinator/Dockerfile
context: ../../
ports:
- "7004:7002"
- "7005:7003"
- "7032:7002"
- "7033:7003"
environment:
- COORDINATOR_CONFIG=${COORDINATOR_CONFIG}
hostname: regress_coordinator
container_name: regress_coordinator2
- COORDINATOR_CONFIG=/spqr/test/feature/conf/coordinator2.yaml
hostname: regress_coordinator_2
container_name: regress_coordinator_2
depends_on:
- "router"
- "router2"
Expand Down
26 changes: 1 addition & 25 deletions test/feature/spqr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,7 @@ func (tctx *testContext) connectorWithCredentials(username string, password stri
func (tctx *testContext) getPostgresqlConnection(host string) (*sqlx.DB, error) {
db, ok := tctx.dbs[host]
if !ok {
addr, err := tctx.composer.GetAddr(host, coordinatorPort)
if err != nil {
return nil, fmt.Errorf("postgresql %s is not in cluster", host)
}

db, err := tctx.connectCoordinatorWithCredentials(shardUser, shardPassword, addr, postgresqlInitialConnectTimeout)
if err != nil {
return nil, fmt.Errorf("postgresql %s is not in cluster", host)
}
tctx.dbs[host] = db
return db, nil
return nil, fmt.Errorf("postgresql %s is not in cluster", host)
}
if strings.HasSuffix(host, "admin") || strings.HasPrefix(host, "coordinator") {
return db, nil
Expand Down Expand Up @@ -390,17 +380,6 @@ func (tctx *testContext) stepClusterIsUpAndRunning(createHaNodes bool) error {
return fmt.Errorf("failed to setup compose cluster: %s", err)
}

err = tctx.stepHostIsStopped("coordinator2")
if err != nil {
return err
}
defer func() {
err := tctx.stepHostIsStarted("coordinator2")
if err != nil {
spqrlog.Zero.Error().Err(err).Msg("failed to start second coordinator")
}
}()

// check databases
for _, service := range tctx.composer.Services() {
if strings.HasPrefix(service, spqrShardName) {
Expand Down Expand Up @@ -445,9 +424,6 @@ func (tctx *testContext) stepClusterIsUpAndRunning(createHaNodes bool) error {

// check coordinator
for _, service := range tctx.composer.Services() {
if strings.HasPrefix(service, spqrCoordinatorName+"2") {
continue
}
if strings.HasPrefix(service, spqrCoordinatorName) {
addr, err := tctx.composer.GetAddr(service, spqrCoordinatorPort)
if err != nil {
Expand Down

0 comments on commit 899e1d7

Please sign in to comment.