Skip to content

Remove mt_getrandmax() from WithTransaction jitter#1860

Merged
GromNaN merged 1 commit intomongodb:v2.xfrom
GromNaN:jitter
Mar 18, 2026
Merged

Remove mt_getrandmax() from WithTransaction jitter#1860
GromNaN merged 1 commit intomongodb:v2.xfrom
GromNaN:jitter

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Mar 13, 2026

Also, generating a float between [0,1] included is accepted.

Copilot AI review requested due to automatic review settings March 13, 2026 20:51
@GromNaN GromNaN requested a review from a team as a code owner March 13, 2026 20:51
@GromNaN GromNaN requested a review from paulinevos March 13, 2026 20:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Replaces mt_getrandmax() with 2 ** 53 for generating jitter in the WithTransaction operation, producing a random float in [0, 1] with full double-precision mantissa resolution.

Changes:

  • Replace mt_getrandmax()-based jitter with random_int(0, 2 ** 53) / 2 ** 53 for better precision
  • Add test verifying jitter output is within [0, 1]

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Operation/WithTransaction.php Replace jitter calculation to remove mt_getrandmax() dependency
tests/Operation/WithTransactionTest.php Add test for jitter range validation

You can also share your feedback on Copilot code review. Take the survey.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.75%. Comparing base (85fef97) to head (918fb63).
⚠️ Report is 7 commits behind head on v2.x.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               v2.x    #1860   +/-   ##
=========================================
  Coverage     87.75%   87.75%           
  Complexity     3308     3308           
=========================================
  Files           447      447           
  Lines          6607     6607           
=========================================
  Hits           5798     5798           
  Misses          809      809           
Flag Coverage Δ
6.0-replica_set 86.58% <100.00%> (ø)
6.0-server 82.60% <100.00%> (ø)
6.0-sharded_cluster 86.37% <100.00%> (ø)
8.0-replica_set 87.61% <100.00%> (ø)
8.0-server 83.35% <100.00%> (ø)
8.0-sharded_cluster 87.45% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GromNaN GromNaN requested a review from alcaeus March 18, 2026 09:20
@GromNaN GromNaN merged commit fc5f9d9 into mongodb:v2.x Mar 18, 2026
39 checks passed
@GromNaN GromNaN deleted the jitter branch March 18, 2026 14:23
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.

4 participants