Skip to content
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

[testbed] fix load gen worker tick interval math to avoid div by zero #38084

Merged

Conversation

gavincabbage
Copy link
Contributor

Description

Previously, certain combinations of load generation options could lead to an attempt to divide by zero, resulting in a panic. Specifically, if the desired batches per second of a single worker was calculated to be less than one, integer division caused it to be rounded to zero before using it as the divisor in subsequent calculations.

Testing

The logic was refactored into a standalone method and tested by unit tests added in this PR.

@gavincabbage gavincabbage force-pushed the fix-testbed-div-by-zero branch from c23fc23 to 9503ba8 Compare February 20, 2025 18:22
@gavincabbage gavincabbage changed the title fix load gen worker tick interval math to avoid div by zero [testbed] fix load gen worker tick interval math to avoid div by zero Feb 27, 2025
// Because of the way perWorkerTickDuration calculates the tick interval using dataItemsPerSecond,
// it is important to test its behavior with respect to a one-second Duration in particular.
{
name: "less than one second",
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this change is to resolve the divide by zero risk, we should have a test case that would have previously resulted in the divide by zero panic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review @dehaansa! One of the test cases was as you describe (indeed it was the set of configuration that caused me to find this bug in the first place). I've made the comment and test name more explicit on this point.

@dehaansa dehaansa added the ready to merge Code review completed; ready to merge by maintainers label Feb 28, 2025
@andrzej-stencel andrzej-stencel merged commit bc7f155 into open-telemetry:main Mar 3, 2025
167 checks passed
@github-actions github-actions bot added this to the next release milestone Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers testbed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants