Skip to content

Commit 15b5f82

Browse files
committed
workload: add last-duration flag to tpcc check
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. Epic: None Release note: None
1 parent 2c99066 commit 15b5f82

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/workload/tpcc/tpcc.go

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

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

187218
type fileLoggerQueryTracer struct {
@@ -267,6 +298,7 @@ var tpccMeta = workload.Meta{
267298
`txn-retries`: {RuntimeOnly: true},
268299
`repair-order-ids`: {RuntimeOnly: true},
269300
`expensive-checks`: {RuntimeOnly: true, CheckConsistencyOnly: true},
301+
`last-duration`: {RuntimeOnly: true, CheckConsistencyOnly: true},
270302
`local-warehouses`: {RuntimeOnly: true},
271303
`regions`: {RuntimeOnly: true},
272304
`survival-goal`: {RuntimeOnly: true},
@@ -321,6 +353,7 @@ var tpccMeta = workload.Meta{
321353
"This is an optional parameter to specify AOST; used exclusively in conjunction with the TPC-C consistency "+
322354
"check. Example values are (\"'-1m'\", \"'-1h'\")")
323355
g.flags.BoolVar(&g.literalImplementation, "literal-implementation", false, "If true, use a literal implementation of the TPC-C kit instead of an optimized version")
356+
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).")
324357

325358
RandomSeed.AddFlag(&g.flags)
326359
g.connFlags = workload.NewConnFlags(&g.flags)

0 commit comments

Comments
 (0)