Skip to content

Commit 211a8ec

Browse files
craig[bot]herkolategan
andcommitted
Merge #148264
148264: workload: add last-duration flag to tpcc check r=srosenberg a=herkolategan Previously, if a workload is run with a long duration, some of the consistency checks would be skipped. This check is only done when running a workload, but some tests also run a separate post check. This post check is not aware of the previous workload's duration and will run the checks even if the workload is run with a long duration. This change adds a new flag, `last-duration`, which can be used to set the duration of the previous workload run. This flag can be used during a post consistency check to determine which checks to skip for long duration workloads. Fixes: #147397 Epic: None Release note: None Co-authored-by: Herko Lategan <[email protected]>
2 parents adb31c9 + 62c6a23 commit 211a8ec

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

pkg/cmd/roachtest/tests/tpcc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ func runTPCC(
471471
cmd := roachtestutil.NewCommand("%s workload check %s", test.DefaultCockroachPath, opts.getWorkloadCmd()).
472472
MaybeFlag(opts.DB != "", "db", opts.DB).
473473
MaybeOption(opts.ExpensiveChecks, "expensive-checks").
474+
Flag("last-duration", opts.Duration).
474475
Flag("warehouses", opts.Warehouses).
475476
Arg("{pgurl:1}")
476477

pkg/workload/tpcc/tpcc.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,37 @@ func (w *waitSetter) String() string {
184184
}
185185
}
186186

187+
// lastDurationSetter is a pflag.Value implementation that sets the last
188+
// duration of a workload run for consistency checks. It is used to determine
189+
// which consistency checks to skip for long duration workloads. It sets the
190+
// `isLongDurationWorkload` field on the `tpcc` to true if the duration is
191+
// greater than or equal to the long duration workload threshold.
192+
type lastDurationSetter struct {
193+
val *time.Duration
194+
tpcc *tpcc
195+
}
196+
197+
// Set implements the pflag.Value interface.
198+
func (p *lastDurationSetter) Set(val string) error {
199+
duration, err := time.ParseDuration(val)
200+
if err != nil {
201+
return err
202+
}
203+
p.val = &duration
204+
p.tpcc.isLongDurationWorkload = duration >= longDurationWorkloadThreshold
205+
return nil
206+
}
207+
208+
// String implements the pflag.Value interface.
209+
func (p *lastDurationSetter) String() string {
210+
return p.val.String()
211+
}
212+
213+
// Type implements the pflag.Value interface.
214+
func (p *lastDurationSetter) Type() string {
215+
return "duration"
216+
}
217+
187218
var _ pgx.QueryTracer = fileLoggerQueryTracer{}
188219

189220
type fileLoggerQueryTracer struct {
@@ -270,6 +301,7 @@ var tpccMeta = workload.Meta{
270301
`txn-retries`: {RuntimeOnly: true},
271302
`repair-order-ids`: {RuntimeOnly: true},
272303
`expensive-checks`: {RuntimeOnly: true, CheckConsistencyOnly: true},
304+
`last-duration`: {RuntimeOnly: true, CheckConsistencyOnly: true},
273305
`local-warehouses`: {RuntimeOnly: true},
274306
`regions`: {RuntimeOnly: true},
275307
`survival-goal`: {RuntimeOnly: true},
@@ -324,6 +356,7 @@ var tpccMeta = workload.Meta{
324356
"This is an optional parameter to specify AOST; used exclusively in conjunction with the TPC-C consistency "+
325357
"check. Example values are (\"'-1m'\", \"'-1h'\")")
326358
g.flags.BoolVar(&g.literalImplementation, "literal-implementation", false, "If true, use a literal implementation of the TPC-C kit instead of an optimized version")
359+
g.flags.Var(&lastDurationSetter{val: &[]time.Duration{0}[0], tpcc: g}, "last-duration", "The duration of the previous workload run (Used to determine which consistency checks to skip for long duration workloads).")
327360

328361
RandomSeed.AddFlag(&g.flags)
329362
g.connFlags = workload.NewConnFlags(&g.flags)

0 commit comments

Comments
 (0)