Skip to content

Commit d16c011

Browse files
committed
workload: add --scatter flag to kv workload
The user can now run `./workload init kv --scatter ....` which scatters the kv table across the cluster after the initial data load. This flag is best used with `--splits`, `--max-block-bytes`, and `--insert-count`. Epic: none Release note: none
1 parent 0d890b5 commit d16c011

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

pkg/workload/kv/kv.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type kv struct {
8888
zipfian bool
8989
sfuDelay time.Duration
9090
splits int
91+
scatter bool
9192
secondaryIndex bool
9293
shards int
9394
targetCompressionRatio float64
@@ -127,6 +128,7 @@ var kvMeta = workload.Meta{
127128
`span-limit`: {RuntimeOnly: true},
128129
`del-percent`: {RuntimeOnly: true},
129130
`splits`: {RuntimeOnly: true},
131+
`scatter`: {RuntimeOnly: true},
130132
`timeout`: {RuntimeOnly: true},
131133
}
132134
g.flags.IntVar(&g.batchSize, `batch`, 1,
@@ -157,6 +159,8 @@ var kvMeta = workload.Meta{
157159
`previous --sequential run and R implies a previous random run.`)
158160
g.flags.IntVar(&g.splits, `splits`, 0,
159161
`Number of splits to perform before starting normal operations.`)
162+
g.flags.BoolVar(&g.scatter, `scatter`, false,
163+
`Scatter ranges before starting normal operations.`)
160164
g.flags.BoolVar(&g.secondaryIndex, `secondary-index`, false,
161165
`Add a secondary index to the schema.`)
162166
g.flags.IntVar(&g.shards, `num-shards`, 0,
@@ -189,13 +193,20 @@ func (w *kv) Flags() workload.Flags { return w.flags }
189193
func (w *kv) Hooks() workload.Hooks {
190194
return workload.Hooks{
191195
PostLoad: func(_ context.Context, db *gosql.DB) error {
192-
if !w.enum {
193-
return nil
194-
}
195-
_, err := db.Exec(`
196+
if w.enum {
197+
_, err := db.Exec(`
196198
CREATE TYPE enum_type AS ENUM ('v');
197199
ALTER TABLE kv ADD COLUMN e enum_type NOT NULL AS ('v') STORED;`)
198-
return err
200+
if err != nil {
201+
return err
202+
}
203+
}
204+
if w.scatter {
205+
if _, err := db.Exec(`ALTER TABLE kv SCATTER`); err != nil {
206+
return err
207+
}
208+
}
209+
return nil
199210
},
200211
Validate: w.validateConfig,
201212
}

0 commit comments

Comments
 (0)