Skip to content

Conversation

@jeffswenson
Copy link
Collaborator

@jeffswenson jeffswenson commented Nov 17, 2025

This test will sometimes fail due to a randomly picking a value that
rounds to 1/2. The frequency of this is a bit higher than one would
expect because the rounding behavior depends on the width of the
duration, not the width of a float64. The test was adjusted to retry
if the jittered value equals the input.

Release note: none
Fixes: #128381
Fixes: #157113

@jeffswenson jeffswenson requested a review from msbutler November 17, 2025 21:54
@jeffswenson jeffswenson requested review from a team as code owners November 17, 2025 21:54
@jeffswenson jeffswenson added the backport-all Flags PRs that need to be backported to all supported release branches label Nov 17, 2025
@cockroach-teamcity
Copy link
Member

This change is Reviewable

// where the test flakes because the random value rounds to 1/2. This is more
// common than you would expect because its probability is based on the width
// of the duration, not the width of the random float.
rand.Seed(4)
Copy link
Collaborator

@stevendanna stevendanna Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little concerned that setting this global seed might impact other randomized tests. But then I read that perhaps this isn't doing what we want in the first place:

// As of Go 1.24 [Seed] is a no-op. To restore the previous behavior set
// GODEBUG=randseednop=0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on both counts. I switched strategies and rewrote the test to retry cases where input == output.

@jeffswenson jeffswenson force-pushed the jeffswenson-deflake-test-jitter-calculation branch 2 times, most recently from 044859b to 83f8447 Compare November 18, 2025 17:03
@github-actions
Copy link

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 18, 2025
@jeffswenson jeffswenson force-pushed the jeffswenson-deflake-test-jitter-calculation branch from 83f8447 to 4751283 Compare November 18, 2025 18:29
Copy link
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Might be worth a comment on why we might need to retry.

This test will sometimes fail due to a randomly picking a value that
rounds to 1/2. The frequency of this is a bit higher than one would
expect because the rounding behavior depends on the width of the
duration, not the width of a float64. The test was adjusted to retry
if the jittered value equals the input.

Release note: none
Fixes: cockroachdb#128381
Fixes: cockroachdb#157113
@jeffswenson jeffswenson force-pushed the jeffswenson-deflake-test-jitter-calculation branch from 4751283 to 4968c09 Compare November 19, 2025 18:06
@jeffswenson
Copy link
Collaborator Author

bors r+

@jeffswenson
Copy link
Collaborator Author

Thanks for a review! I added a comment.

@craig craig bot merged commit 032bf32 into cockroachdb:master Nov 19, 2025
24 checks passed
@craig
Copy link
Contributor

craig bot commented Nov 19, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-all Flags PRs that need to be backported to all supported release branches o-AI-Review-Potential-Issue-Detected AI reviewer found potential issue. Never assign manually—auto-applied by GH action only. target-release-26.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jobs: TestJitterCalculation failed jobs: TestJitterCalculation failed

3 participants