From ede2d33e36119a970abaee2c3e2b4674c19152b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Misbach?= Date: Thu, 2 Jul 2026 14:57:43 +0200 Subject: [PATCH] [local deployment/crdb] Ensure that each USS has at least a replica of the tables --- build/dev/docker-compose.yaml | 5 +++-- build/dev/run_locally.sh | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build/dev/docker-compose.yaml b/build/dev/docker-compose.yaml index 42a4887992..12590f2c84 100644 --- a/build/dev/docker-compose.yaml +++ b/build/dev/docker-compose.yaml @@ -6,7 +6,7 @@ services: image: cockroachdb/cockroach:v24.1.3 entrypoint: /db-entrypoint.sh # 128MB limits allow larger numbers of nodes on a single machine - command: /cockroach/cockroach.sh start --insecure --join=db1.uss1.localutm --cache=128MiB --max-sql-memory=128MiB + 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:?} volumes: - $PWD/startup/db-entrypoint.sh:/db-entrypoint.sh:ro profiles: [crdb] @@ -66,11 +66,12 @@ services: image: cockroachdb/cockroach:v24.1.3 profiles: [bootstrap-crdb] depends_on: [crdb] - entrypoint: > + 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 sh -c " out=$$(/cockroach/cockroach.sh init --insecure --host=db1.uss1.localutm 2>&1); if [ $$? -eq 0 ]; then echo "$$out"; + /cockroach/cockroach.sh sql --insecure --host=db1.uss1.localutm -e 'ALTER RANGE default CONFIGURE ZONE USING num_replicas = ${NUM_USS:?};'; exit 0; fi; echo "$$out"; diff --git a/build/dev/run_locally.sh b/build/dev/run_locally.sh index 84b7af11d7..23ef08518f 100755 --- a/build/dev/run_locally.sh +++ b/build/dev/run_locally.sh @@ -20,7 +20,7 @@ fi cd "${BASEDIR}" || exit 1 -NUM_USS=${NUM_USS:-2} +export NUM_USS=${NUM_USS:-2} NUM_NODES=${NUM_NODES:-1} DB_TYPE=${DB_TYPE:-crdb}