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 curl integration race condition #2847

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

iamluc
Copy link
Contributor

@iamluc iamluc commented Sep 12, 2024

Description

Spotted by the CI, though not frequent.
e.g. https://app.circleci.com/pipelines/github/DataDog/dd-trace-php/17462/workflows/f2a5d19c-4f05-4f57-aed9-f400f6677938/jobs/5150058

Fix a race condition where curl_multi_exec is called many times while finished ($still_running at false) before curl_multi_info_read.
In that case, the spans could have been removed from the storage.
+
Remove weird code using the last instance of a previous loop value ($requestSpan)

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

… finished ($still_running at false)

before curl_multi_info_read.
In that case, the spans could have been removed from the storage
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.09%. Comparing base (ebaa1ca) to head (1133a8a).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2847      +/-   ##
============================================
+ Coverage     81.06%   81.09%   +0.02%     
+ Complexity     2516     2515       -1     
============================================
  Files           146      146              
  Lines         14653    14648       -5     
============================================
  Hits          11879    11879              
+ Misses         2774     2769       -5     
Flag Coverage Δ
tracer-extension 78.18% <ø> (ø)
tracer-php 82.31% <100.00%> (+0.03%) ⬆️

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

Files with missing lines Coverage Δ
src/DDTrace/Integrations/Curl/CurlIntegration.php 95.23% <100.00%> (+2.75%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebaa1ca...1133a8a. Read the comment docs.

@iamluc iamluc marked this pull request as ready for review September 12, 2024 10:02
@iamluc iamluc requested a review from a team as a code owner September 12, 2024 10:02
@iamluc iamluc force-pushed the luc/fix-curl-integration-race-condition branch from 1133a8a to c4c916f Compare September 12, 2024 12:00
Copy link
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

The difference is essentially that $saveSpans gets always set. I think that's right.

@pr-commenter
Copy link

pr-commenter bot commented Sep 12, 2024

Benchmarks

Benchmark execution time: 2024-09-12 12:24:53

Comparing candidate commit c4c916f in PR branch luc/fix-curl-integration-race-condition with baseline commit ebaa1ca in branch master.

Found 1 performance improvements and 5 performance regressions! Performance is the same for 172 metrics, 0 unstable metrics.

scenario:BM_TeaSapiSpindown

  • 🟥 execution_time [+13.381µs; +28.847µs] or [+2.585%; +5.573%]

scenario:EmptyFileBench/benchEmptyFileBaseline-opcache

  • 🟥 execution_time [+71.938µs; +208.202µs] or [+2.494%; +7.218%]

scenario:LaravelBench/benchLaravelBaseline-opcache

  • 🟥 execution_time [+62.072µs; +209.768µs] or [+2.063%; +6.972%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2

  • 🟥 execution_time [+152.622ns; +548.178ns] or [+2.135%; +7.668%]

scenario:SamplingRuleMatchingBench/benchRegexMatching4

  • 🟥 execution_time [+266.970ns; +701.630ns] or [+3.737%; +9.820%]

scenario:WordPressBench/benchWordPressOverhead

  • 🟩 execution_time [-21.911ms; -21.621ms] or [-83.229%; -82.125%]

@iamluc iamluc merged commit 1a7182c into master Sep 12, 2024
643 of 646 checks passed
@iamluc iamluc deleted the luc/fix-curl-integration-race-condition branch September 12, 2024 14:26
@github-actions github-actions bot added this to the 1.4.0 milestone Sep 12, 2024
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.

3 participants