Skip to content

Commit a0ff08e

Browse files
committed
drtprod: generate tpcc run server side support
Previously, we used client-partitions for the scale 300 node test. This change adds support for server side partitions in the TPCC run script. The PGURLS also always specified all the nodes in the cluster, on all workload nodes. This has been updated to only select nodes that pertain to the partitions for that workload. Epic: None Release note: None
1 parent 33d8d14 commit a0ff08e

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

pkg/cmd/drtprod/scripts/generate_tpcc_run.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# Usage: <script_suffix> <execute:true|false> [workload flags]
1010
# Requires: CLUSTER, WORKLOAD_CLUSTER, WORKLOAD_NODES env vars
1111
# Optional: TOTAL_PARTITIONS (defaults to WORKLOAD_NODES if WORKLOAD_NODES>1)
12+
# Optional: PARTITION_TYPE (defaults to client-partitions)
1213
if [ "$#" -lt 2 ]; then
1314
echo "Usage: $0 <script_suffix> <execute:true|false> <flags to init:--warehouses,--db>"
1415
exit 1
@@ -40,6 +41,12 @@ if [ -z "${WORKLOAD_NODES}" ]; then
4041
exit 1
4142
fi
4243

44+
if [ -z "${CLUSTER_NODES}" ]; then
45+
echo "environment CLUSTER_NODES is not set"
46+
exit 1
47+
fi
48+
49+
4350
# Set TOTAL_PARTITIONS equal to WORKLOAD_NODES if not set
4451
if [ -z "${TOTAL_PARTITIONS}" ] && [ "${WORKLOAD_NODES}" -gt 1 ]; then
4552
TOTAL_PARTITIONS=$WORKLOAD_NODES
@@ -51,6 +58,11 @@ if [ -n "${TOTAL_PARTITIONS}" ] && [ "${TOTAL_PARTITIONS}" -lt "${WORKLOAD_NODES
5158
echo "TOTAL_PARTITIONS ($TOTAL_PARTITIONS) must be greater than or equal to WORKLOAD_NODES ($WORKLOAD_NODES)"
5259
exit 1
5360
fi
61+
62+
# If PARTITION_TYPE is not set default to client-partitions
63+
if [ -z "${PARTITION_TYPE}" ]; then
64+
PARTITION_TYPE="client-partitions"
65+
fi
5466

5567
export ROACHPROD_DISABLED_PROVIDERS=IBM
5668

@@ -79,6 +91,13 @@ absolute_path=$(drtprod run "${WORKLOAD_CLUSTER}":1 -- "realpath ./cockroach")
7991
pwd=$(drtprod run "${WORKLOAD_CLUSTER}":1 -- "dirname ${absolute_path}")
8092

8193
for ((NODE=0; NODE<WORKLOAD_NODES; NODE++)); do
94+
# Calculate node range for this workload node (if PARTITION_TYPE is partitions, we use the selected_nodes)
95+
NODES_PER_WORKLOAD=$((CLUSTER_NODES / WORKLOAD_NODES))
96+
NODES_REMAINDER=$((CLUSTER_NODES % WORKLOAD_NODES))
97+
NODE_START=$((NODE * NODES_PER_WORKLOAD + (NODE < NODES_REMAINDER ? NODE : NODES_REMAINDER) + 1))
98+
NODE_END=$((NODE_START + NODES_PER_WORKLOAD + (NODE < NODES_REMAINDER ? 1 : 0) - 1))
99+
selected_nodes="${NODE_START}-${NODE_END}"
100+
82101
# Handle partitioning if TOTAL_PARTITIONS is set
83102
partition_args=""
84103
if [ -n "${TOTAL_PARTITIONS}" ]; then
@@ -94,7 +113,7 @@ for ((NODE=0; NODE<WORKLOAD_NODES; NODE++)); do
94113
exit 1
95114
fi
96115
echo "Partition assignment: $parts"
97-
partition_args="--client-partitions=$TOTAL_PARTITIONS --partition-affinity=$parts"
116+
partition_args="--$PARTITION_TYPE=$TOTAL_PARTITIONS --partition-affinity=$parts"
98117
fi
99118

100119
# Create the workload script
@@ -104,11 +123,15 @@ for ((NODE=0; NODE<WORKLOAD_NODES; NODE++)); do
104123
export ROACHPROD_DISABLED_PROVIDERS=IBM
105124
export ROACHPROD_GCE_DEFAULT_PROJECT=$ROACHPROD_GCE_DEFAULT_PROJECT
106125
./drtprod sync
107-
$([ "$execute_script" = "true" ] && [ "$NODE" -eq 0 ] && echo "${pwd}/tpcc_init_${suffix}.sh")
126+
108127
PGURLS=\$(./drtprod load-balancer pgurl $CLUSTER | sed s/\'//g)
109128
if [ -z "\$PGURLS" ]; then
110129
echo ">> No load-balancer configured; falling back to direct pgurl"
111-
PGURLS=\$(./drtprod pgurl $CLUSTER | sed s/\'//g)
130+
if [ "$PARTITION_TYPE" = "partitions" ]; then
131+
PGURLS=\$(./drtprod pgurl $CLUSTER:$selected_nodes | sed s/\'//g)
132+
else
133+
PGURLS=\$(./drtprod pgurl $CLUSTER | sed s/\'//g)
134+
fi
112135
fi
113136
read -r -a PGURLS_ARR <<< "\$PGURLS"
114137
j=0

0 commit comments

Comments
 (0)