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

[exporterhelper] Fix potential deadlock in the batch sender #10315

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Jun 4, 2024

Concurrent handling of the flush timeouts can run into a deadlock when a batch is simultaneously sent by reaching the minimum size and flush timeout. The deadlock can happen on the following lines:

@dmitryax dmitryax requested a review from a team as a code owner June 4, 2024 20:34
@dmitryax dmitryax requested a review from codeboten June 4, 2024 20:34
@dmitryax
Copy link
Member Author

dmitryax commented Jun 4, 2024

@carsonip PTAL

@dmitryax dmitryax force-pushed the fix-batch-splitting branch 2 times, most recently from 8c3311d to d658832 Compare June 4, 2024 20:36
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.57%. Comparing base (760f773) to head (4ca2db6).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10315      +/-   ##
==========================================
- Coverage   92.58%   92.57%   -0.01%     
==========================================
  Files         387      387              
  Lines       18254    18250       -4     
==========================================
- Hits        16900    16895       -5     
- Misses       1008     1009       +1     
  Partials      346      346              

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

Copy link
Contributor

@carsonip carsonip left a comment

Choose a reason for hiding this comment

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

bugfix lgtm, I've managed to reproduce the deadlock with an updated test (see code suggestion)

exporter/exporterhelper/batch_sender_test.go Outdated Show resolved Hide resolved
Concurrent handling of the flush timeouts can run into a deadlock when a batch is simultaneously sent by reaching the minimum size and flush timeout. The deadlock can happen on the following lines:
- https://github.com/open-telemetry/opentelemetry-collector/blob/115bc8e28e009ca93565dc4deb4cf6608fa63622/exporter/exporterhelper/batch_sender.go#L131
- https://github.com/open-telemetry/opentelemetry-collector/blob/115bc8e28e009ca93565dc4deb4cf6608fa63622/exporter/exporterhelper/batch_sender.go#L87

Co-authored-by: Carson Ip <carsonip@users.noreply.github.com>
@dmitryax
Copy link
Member Author

dmitryax commented Jun 5, 2024

Thanks @carsonip!

@dmitryax dmitryax merged commit 9c3481b into open-telemetry:main Jun 5, 2024
49 checks passed
@github-actions github-actions bot added this to the next release milestone Jun 5, 2024
@dmitryax dmitryax deleted the fix-batch-splitting branch June 6, 2024 19:20
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.

None yet

3 participants