Skip to content

Commit c3cbd57

Browse files
committed
workload: use same key sequence during KV --insert-count
When inserting an initial --insert-count keys, use the configured key schema to insert the keys. This ensures that a subsequent call passing an appropriate --write-seq flag will read the keys inserted through --insert-count. Fix #107874. Epic: none Release note: none
1 parent fd6d253 commit c3cbd57

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

pkg/workload/kv/kv.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,6 @@ func splitFinder(i, splits int, r keyRange, k keyTransformer) interface{} {
389389
return k.getKey(splitPoint)
390390
}
391391

392-
func insertCountKey(idx, count int64, kr keyRange) int64 {
393-
stride := kr.max/(count+1) - kr.min/(count+1)
394-
key := kr.min + (idx+1)*stride
395-
return key
396-
}
397-
398392
// Tables implements the Generator interface.
399393
func (w *kv) Tables() []workload.Table {
400394
// Tables should only run on initialized workload, safe to call create without
@@ -429,6 +423,9 @@ func (w *kv) Tables() []workload.Table {
429423
table.InitialRows = workload.BatchedTuples{
430424
NumBatches: (w.insertCount + batchSize - 1) / batchSize,
431425
FillBatch: func(batchIdx int, cb coldata.Batch, a *bufalloc.ByteAllocator) {
426+
// Grab a new state for each batch, under the assumption that
427+
// FillBatch may be called concurrently.
428+
ks := kg.newState()
432429
rowBegin, rowEnd := batchIdx*batchSize, (batchIdx+1)*batchSize
433430
if rowEnd > w.insertCount {
434431
rowEnd = w.insertCount
@@ -444,11 +441,11 @@ func (w *kv) Tables() []workload.Table {
444441
{
445442
seq := rowBegin
446443
kg.transformer.fillColumnBatch(cb, a, func() (s int64, ok bool) {
447-
if seq < rowEnd {
448-
seq++
449-
return insertCountKey(int64(seq-1), int64(w.insertCount), kg.kr), true
444+
if seq >= rowEnd {
445+
return 0, false
450446
}
451-
return 0, false
447+
seq++
448+
return ks.mapKey.mapKey(int64(seq)), true
452449
})
453450
}
454451

0 commit comments

Comments
 (0)