Skip to content

Commit ede2d33

Browse files
committed
[local deployment/crdb] Ensure that each USS has at least a replica of the tables
1 parent 6efa7a4 commit ede2d33

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

build/dev/docker-compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
image: cockroachdb/cockroach:v24.1.3
77
entrypoint: /db-entrypoint.sh
88
# 128MB limits allow larger numbers of nodes on a single machine
9-
command: /cockroach/cockroach.sh start --insecure --join=db1.uss1.localutm --cache=128MiB --max-sql-memory=128MiB
9+
command: /cockroach/cockroach.sh start --insecure --join=db1.uss1.localutm --cache=128MiB --max-sql-memory=128MiB --locality=uss=${USS_IDX:?},node=${USS_IDX:?}-${USS_NODE_IDX:?}
1010
volumes:
1111
- $PWD/startup/db-entrypoint.sh:/db-entrypoint.sh:ro
1212
profiles: [crdb]
@@ -66,11 +66,12 @@ services:
6666
image: cockroachdb/cockroach:v24.1.3
6767
profiles: [bootstrap-crdb]
6868
depends_on: [crdb]
69-
entrypoint: >
69+
entrypoint: > # note that this sets the CRDB zones to have as many replicas as there are USSs (for all tables), combined with the fact that CRDB will try to distribute replicas uniformly over zones (which are defined by locality), this ensures that each USS has at least a replica
7070
sh -c "
7171
out=$$(/cockroach/cockroach.sh init --insecure --host=db1.uss1.localutm 2>&1);
7272
if [ $$? -eq 0 ]; then
7373
echo "$$out";
74+
/cockroach/cockroach.sh sql --insecure --host=db1.uss1.localutm -e 'ALTER RANGE default CONFIGURE ZONE USING num_replicas = ${NUM_USS:?};';
7475
exit 0;
7576
fi;
7677
echo "$$out";

build/dev/run_locally.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fi
2020

2121
cd "${BASEDIR}" || exit 1
2222

23-
NUM_USS=${NUM_USS:-2}
23+
export NUM_USS=${NUM_USS:-2}
2424
NUM_NODES=${NUM_NODES:-1}
2525
DB_TYPE=${DB_TYPE:-crdb}
2626

0 commit comments

Comments
 (0)