Skip to content

Commit df7d315

Browse files
craig[bot]csgourav
andcommitted
Merge #144458
144458: workload: use multi region partitioner in auditor r=srosenberg a=csgourav Audtior should user multi region partitioner in multi region run of tpcc. Otherwise the audit checks fail for some warehouses. Fixes: [CRDB-49260](https://cockroachlabs.atlassian.net/browse/CRDB-49260) Epic: none Co-authored-by: Gourav Kumar <[email protected]>
2 parents 420663f + 584d9d8 commit df7d315

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

pkg/workload/tpcc/new_order.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,17 @@ func (n *newOrder) run(ctx context.Context, wID int) (interface{}, time.Duration
187187
allLocal = 0
188188
// To avoid picking the local warehouse again, randomly choose among n-1
189189
// warehouses and swap in the nth if necessary.
190-
item.olSupplyWID = n.config.wPart.randActive(rng)
191-
for item.olSupplyWID == wID {
190+
if len(n.config.multiRegionCfg.regions) > 0 {
191+
// For multi-region configurations, use the multi-region partitioner
192+
item.olSupplyWID = n.config.wMRPart.randActive(rng)
193+
for item.olSupplyWID == wID {
194+
item.olSupplyWID = n.config.wMRPart.randActive(rng)
195+
}
196+
} else {
192197
item.olSupplyWID = n.config.wPart.randActive(rng)
198+
for item.olSupplyWID == wID {
199+
item.olSupplyWID = n.config.wPart.randActive(rng)
200+
}
193201
}
194202
n.config.auditor.Lock()
195203
n.config.auditor.orderLineRemoteWarehouseFreq[item.olSupplyWID]++

pkg/workload/tpcc/payment.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,19 @@ func (p *payment) run(ctx context.Context, wID int) (interface{}, time.Duration,
223223
d.cWID = wID
224224
d.cDID = d.dID
225225
} else {
226-
d.cWID = p.config.wPart.randActive(rng)
227-
// Find a cWID != w_id if there's more than 1 configured warehouse.
228-
for d.cWID == wID && p.config.activeWarehouses > 1 {
226+
if len(p.config.multiRegionCfg.regions) > 0 {
227+
// For multi-region configurations, use the multi-region partitioner
228+
d.cWID = p.config.wMRPart.randActive(rng)
229+
// Find a cWID != w_id if there's more than 1 configured warehouse.
230+
for d.cWID == wID && p.config.activeWarehouses > 1 {
231+
d.cWID = p.config.wMRPart.randActive(rng)
232+
}
233+
} else {
229234
d.cWID = p.config.wPart.randActive(rng)
235+
// Find a cWID != w_id if there's more than 1 configured warehouse.
236+
for d.cWID == wID && p.config.activeWarehouses > 1 {
237+
d.cWID = p.config.wPart.randActive(rng)
238+
}
230239
}
231240
p.config.auditor.Lock()
232241
p.config.auditor.paymentRemoteWarehouseFreq[d.cWID]++

pkg/workload/tpcc/tpcc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,11 @@ func (w *tpcc) Hooks() workload.Hooks {
484484
if err != nil {
485485
return errors.Wrap(err, "error creating multi-region partitioner")
486486
}
487+
w.auditor = newAuditor(w.activeWarehouses, w.wMRPart, w.affinityPartitions)
488+
} else {
489+
w.auditor = newAuditor(w.activeWarehouses, w.wPart, w.affinityPartitions)
487490
}
488491

489-
w.auditor = newAuditor(w.activeWarehouses, w.wPart, w.affinityPartitions)
490492
return initializeMix(w)
491493
},
492494
PreCreate: func(db *gosql.DB) error {

0 commit comments

Comments
 (0)