From f97261a661dba495bb3f9026a0e75dd60cb7425d Mon Sep 17 00:00:00 2001 From: Hanzhou Tang Date: Tue, 3 Feb 2026 00:50:19 +0000 Subject: [PATCH] Handle scale factors less than 1 in worker creation Ensure totalWarehouses defaults to 1 when scale factor truncates to 0. This fixes TestTPCCWorker failures where DB_SCALE_FACTOR=0.01 caused "The end index must be >= 1" assertion errors. --- .../com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java b/src/main/java/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java index f466001..26cb485 100644 --- a/src/main/java/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java +++ b/src/main/java/com/oltpbenchmark/benchmarks/tpcc/TPCCBenchmark.java @@ -85,6 +85,9 @@ private List createTerminalsOldWay() throws SQLException { // totalWarehouses is equal to numWarehouses in case of non-partitioned use case int totalWarehouses = (int) workConf.getScaleFactor(); + if (totalWarehouses <= 0) { + totalWarehouses = 1; + } // [startWarehouseIndex, endWarehouseIndex] are both included. // Use defaults if not configured: start=1, end=totalWarehouses, stride=1 @@ -109,8 +112,8 @@ private List createTerminalsOldWay() throws SQLException { assert startWarehouseIndex >= 1 : "The start index must be >= 1"; assert endWarehouseIndex >= 1 : "The end index must be >= 1"; - assert endWarehouseIndex <= workConf.getScaleFactor() - : "The end index must be within the scale factor"; + assert endWarehouseIndex <= totalWarehouses + : "The end index must be within the total warehouse number"; assert numWarehouses >= 1 : "At least need 1 warehouse to do benchmark"; // We distribute terminals evenly across the warehouses