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

Fix missing notify of conditional variable in OTLP HTTP exporter test #858

Merged
merged 6 commits into from
Jun 15, 2021

Conversation

ThomsonTan
Copy link
Contributor

Fixes #857

Changes

Added notify_one call to cv_got_events right after HTTP response processing.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@ThomsonTan ThomsonTan requested a review from a team June 15, 2021 02:43
@codecov
Copy link

codecov bot commented Jun 15, 2021

Codecov Report

Merging #858 (066484a) into main (7fca2c3) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #858      +/-   ##
==========================================
+ Coverage   95.49%   95.50%   +0.02%     
==========================================
  Files         156      156              
  Lines        6618     6620       +2     
==========================================
+ Hits         6319     6322       +3     
+ Misses        299      298       -1     
Impacted Files Coverage Δ
ext/test/http/curl_http_test.cc 95.22% <100.00%> (+0.59%) ⬆️

}

cv_got_events.notify_one();
Copy link
Member

@lalitb lalitb Jun 15, 2021

Choose a reason for hiding this comment

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

why is this needed ? cv.wait_for is supposed to be unblocked with a timeout. I think this will fail now if the test is modified so that cv.wait_for has multiple requests to wait for, as now it will be unblocked after a single request?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Timeout in cv.wait_for is the last resort. cv should be waked up anytime its checking condition could be changed, so its condition could be re-checked instead of waiting for timing out. notify_one just tell cv to recheck so it should not trigger failure behavior?

cc @owent

Copy link
Member

Choose a reason for hiding this comment

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

Does it mean that without notification, the cv will keep blocked for 2sec (as configured) even though the condition is satisfied early?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is the case the PR trying to fix.

Copy link
Member

@lalitb lalitb Jun 15, 2021

Choose a reason for hiding this comment

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

Asking because we are using this construct in other places too:

if (cv_got_events.wait_for(lk, std::chrono::milliseconds(1000 * timeOutSec),
, probably they need a change too ( in separate PR ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, it is needed in curl_http_test.cc as well. Added the change to the PR and avoid another 2 timeout to happen there. Thanks for the catch.

Copy link
Member

Choose a reason for hiding this comment

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

Timeout in cv.wait_for is the last resort. cv should be waked up anytime its checking condition could be changed, so its condition could be re-checked instead of waiting for timing out. notify_one just tell cv to recheck so it should not trigger failure behavior?

cc @owent

You are right. LGTM.

@owent
Copy link
Member

owent commented Jun 15, 2021

Could you please remove the TODO I omit in #853 ? I think there is no need to create a PR just to remove the TODO comment.

@ThomsonTan
Copy link
Contributor Author

Could you please remove the TODO I omit in #853 ? I think there is no need to create a PR just to remove the TODO comment.

Sure, just removed that.

@lalitb lalitb merged commit 8a8ffe5 into open-telemetry:main Jun 15, 2021
@lalitb lalitb mentioned this pull request Mar 22, 2022
3 tasks
@ThomsonTan ThomsonTan deleted the FixMissingNotify branch March 13, 2023 22:08
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.

Conditional variable cv_got_events in otlp_http_exporter_test is never notified
3 participants