Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build/dev/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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:?};';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do this work reliably, or there is a chance that migrations create database/tables before and use a different default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • migrations (from the (rid|scd|aux)_bootstrapper) explicitely wait for crdb-init to be completed before being ran
  • even if this is applied after creation of the table, the setting is applied, as we apply it on the zone

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect 👍

exit 0;
fi;
echo "$$out";
Expand Down
2 changes: 1 addition & 1 deletion build/dev/run_locally.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
Loading