【 TiDB 使用环境】单机模拟集群
【复现路径】直接使用手册上线的语句先生成tpcc负载:
tiup bench tpcc -H 172.16.5.140 -P 4000 -D tpcc --warehouses 10 prepare -T 32
再导入tpch的视图
tiup bench ch -H 172.16.5.140 -P 4000 -D tpcc prepare
【遇到的问题:问题现象及影响】order_line表中ol_delivery_date所有非空值均为同一个数据,生成数据时的时间。
https://github.com/pingcap/go-tpc/blob/master/tpcc/load.go#L328C12-L328C12
代码确实是这么写的。我不清楚逻辑是否应该如此。
你要觉得不妥,改这一行重新编译就可以了。
func (w *Workloader) loadOrderLine(ctx context.Context, warehouse int, district int, olCnts []int) error {
fmt.Printf("load to order_line in warehouse %d district %d\n", warehouse, district)
s := getTPCCState(ctx)
hint := `INSERT INTO order_line (ol_o_id, ol_d_id, ol_w_id, ol_number,
ol_i_id, ol_supply_w_id, ol_delivery_d, ol_quantity, ol_amount, ol_dist_info) VALUES `
l := sink.NewSQLSink(w.db, hint, w.cfg.PrepareRetryCount, w.cfg.PrepareRetryInterval)
for i := 0; i < orderPerDistrict; i++ {
for j := 0; j < olCnts[i]; j++ {
s.Buf.Reset()
olOID := i + 1
olDID := district
olWID := warehouse
olNumber := j + 1
olIID := randInt(s.R, 1, 100000)
olSupplyWID := warehouse
olQuantity := 5
var olAmount float64
var olDeliveryD sql.NullString
if olOID < 2101 {
olDeliveryD = sql.NullString{
String: w.initLoadTime,
Valid: true,
}
olAmount = 0.00
} else {
olAmount = float64(randInt(s.R, 1, 999999)) / 100.0
// Update olDeliveryD logic here
olDeliveryD = sql.NullString{
String: /* Set your specific condition here */,
Valid: true,
}
}
olDistInfo := randChars(s.R, s.Buf, 24, 24)
if err := l.WriteRow(ctx,
olOID, olDID, olWID, olNumber, olIID, olSupplyWID,
olDeliveryD, olQuantity, olAmount, olDistInfo,
); err != nil {
return err
}
}
}
return l.Flush(ctx)
}
-F “ol_delivery_date=datetime.random” 试下加这个参数