Skip to content

Conversation

@herkolategan
Copy link
Collaborator

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

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
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@herkolategan herkolategan force-pushed the hbl/workload-row-validation-unit-tests branch 3 times, most recently from 4fc9159 to 53cc189 Compare November 7, 2025 14:07
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.
@herkolategan herkolategan force-pushed the hbl/workload-row-validation-unit-tests branch from 53cc189 to 4779e11 Compare November 7, 2025 14:42
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

Potential Bug(s) Detected

The three-stage Claude Code analysis has identified potential bug(s) in this PR that may warrant investigation.

Next Steps:
Please review the detailed findings in the workflow run.

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:

  • If the detected issue is real or was helpful in any way, please tag the issue with O-AI-Review-Real-Issue-Found
  • If the detected issue was not helpful in any way, please tag the issue with O-AI-Review-Not-Helpful

@github-actions github-actions bot added the o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. label Nov 7, 2025
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 {
Copy link
Collaborator Author

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.

@herkolategan herkolategan removed the o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. label Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

workload/bank: running with --rows=1 causes panic

2 participants