-
Notifications
You must be signed in to change notification settings - Fork 4k
workload: validate bank rows flag #157050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
workload: validate bank rows flag #157050
Conversation
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: cockroachdb#153849
4fc9159 to
53cc189
Compare
The validation added in the bank workload now requires at least two rows for validation to pass. This change updates the unit tests to pass at least 2 accounts.
53cc189 to
4779e11
Compare
Potential Bug(s) DetectedThe three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation. Next Steps: Note: When viewing the workflow output, scroll to the bottom to find the Final Analysis Summary. After you review the findings, please tag the issue as follows:
|
Previously, the logic in the bank `Ops` function tried to work around the fact that the number of rows (accounts) might be 0 or 1. This logic didn't seem right, as the `to` bank account was never allowed to be on the tail end. This change uses the condition enforced by the validation that we always expect rows to be at least 2. This allows us to simplify the from and to selection here, which is not allowed to point to the same account.
| // Rows are always expected to be at least two (via validation). | ||
| from := rng.IntN(b.rows) | ||
| to := rng.IntN(b.rows - 1) | ||
| for from == to && b.rows != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential Bug(s) Detected
If we have 2 rows (allowed), this could potentially indefinitely loop.
Both from and to select 0, hence from == to and b.rows != 1 (= 2).
And b.rows - 1 = 1 resulting in to staying 0 during the loop, resulting in an indefinite loop.
With a minimum of 2 rows now being validated we can update this logic to account for that.
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