Skip to content

Commit cc971a4

Browse files
committed
workload: validate bank rows flag
Previously, if a value of 1 was passed in for rows, the workload would panic. We need at least two accounts to be able to do transfers. This change ensures we validate the flag. Fixes: #153849
1 parent ccdd264 commit cc971a4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/workload/bank/bank.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ func (b *bank) ConnFlags() *workload.ConnFlags { return b.connFlags }
115115
func (b *bank) Hooks() workload.Hooks {
116116
return workload.Hooks{
117117
Validate: func() error {
118+
if b.rows < 2 {
119+
// We need at least two rows to do any transfers.
120+
return errors.Errorf(`Value of rows must be greater than one; was %d`, b.rows)
121+
}
118122
if b.rows < b.ranges {
119123
return errors.Errorf(
120124
"Value of 'rows' (%d) must be greater than or equal to value of 'ranges' (%d)",

0 commit comments

Comments
 (0)