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(grpc): fix segfault with grpc.aio streaming responses [backport 1.20] #9276

Merged
merged 21 commits into from
May 17, 2024

Conversation

wconti27
Copy link
Contributor

@wconti27 wconti27 commented May 15, 2024

Backport 5897cab from #9233 to 1.20.

This PR fixes a few issues with the grpc aio integration. Most notably, the integration was causing segfaults when wrapping async stream responses, most likely since these spans were never being finished. This issue was uncovered when customers upgraded their google-api-core dependencies to 2.17.0; with this upgrade, the package changed many grpc calls to use async streaming. In addition to fixing the segfault, this PR also fixes the Pin object to be correctly placed on the grpcio module.

Fixes #9139

Checklist

  • Change(s) are motivated and described in the PR description
  • Testing strategy is described if automated tests are not included in the PR
  • Risks are described (performance impact, potential for breakage, maintainability)
  • Change is maintainable (easy to change, telemetry, documentation)
  • Library release note guidelines are followed or label changelog/no-changelog is set
  • Documentation is included (in-code, generated user docs, public corp docs)
  • Backport labels are set (if applicable)
  • If this PR changes the public interface, I've notified @DataDog/apm-tees.

Reviewer Checklist

  • Title is accurate
  • All changes are related to the pull request's stated goal
  • Description motivates each change
  • Avoids breaking API changes
  • Testing strategy adequately addresses listed risks
  • Change is maintainable (easy to change, telemetry, documentation)
  • Release note makes sense to a user of the library
  • Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment
  • Backport labels are set in a manner that is consistent with the release branch maintenance policy

This PR fixes a few issues with the `grpc aio` integration. Most
notably, the integration was causing segfaults when wrapping async
stream responses, most likely since these spans were never being
finished. This issue was uncovered when customers upgraded their
`google-api-core` dependencies to `2.17.0`; with this upgrade, the
package changed many grpc calls to use async streaming. In addition to
fixing the segfault, this PR also fixes the Pin object to be correctly
placed on the grpcio module.

Fixes #9139

- [x] Change(s) are motivated and described in the PR description
- [x] Testing strategy is described if automated tests are not included
in the PR
- [x] Risks are described (performance impact, potential for breakage,
maintainability)
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] [Library release note
guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html)
are followed or label `changelog/no-changelog` is set
- [x] Documentation is included (in-code, generated user docs, [public
corp docs](https://github.com/DataDog/documentation/))
- [x] Backport labels are set (if
[applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting))
- [x] If this PR changes the public interface, I've notified
`@DataDog/apm-tees`.

- [x] Title is accurate
- [x] All changes are related to the pull request's stated goal
- [x] Description motivates each change
- [x] Avoids breaking
[API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces)
changes
- [x] Testing strategy adequately addresses listed risks
- [x] Change is maintainable (easy to change, telemetry, documentation)
- [x] Release note makes sense to a user of the library
- [x] Author has acknowledged and discussed the performance implications
of this PR as reported in the benchmarks PR comment
- [x] Backport labels are set in a manner that is consistent with the
[release branch maintenance
policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)

(cherry picked from commit 5897cab)
@wconti27 wconti27 requested review from a team as code owners May 15, 2024 18:24
@wconti27 wconti27 changed the base branch from main to 1.20 May 15, 2024 18:25
@wconti27 wconti27 requested a review from a team as a code owner May 15, 2024 18:25
@wconti27 wconti27 requested a review from majorgreys May 15, 2024 18:25
@pr-commenter
Copy link

pr-commenter bot commented May 15, 2024

Benchmarks

Benchmark execution time: 2024-05-16 19:12:00

Comparing candidate commit 693d3f8 in PR branch backport-9233-to-1.20 with baseline commit 7a0e539 in branch 1.20.

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

@datadog-dd-trace-py-rkomorn
Copy link

datadog-dd-trace-py-rkomorn bot commented May 16, 2024

Datadog Report

Branch report: backport-9233-to-1.20
Commit report: bc6bc81
Test service: dd-trace-py

✅ 0 Failed, 704 Passed, 402 Skipped, 5m 21.29s Total duration (2m 39.96s time saved)

.github/workflows/system-tests.yml Outdated Show resolved Hide resolved
.github/workflows/system-tests.yml Outdated Show resolved Hide resolved
wconti27 and others added 9 commits May 16, 2024 12:42
…ade-abbc097a46b5d032.yaml

Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com>
Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com>
Co-authored-by: Emmett Butler <723615+emmettbutler@users.noreply.github.com>
@wconti27 wconti27 enabled auto-merge (squash) May 16, 2024 18:14
auto-merge was automatically disabled May 16, 2024 20:21

Pull request was closed

@emmettbutler emmettbutler reopened this May 16, 2024
@emmettbutler emmettbutler merged commit a979c73 into 1.20 May 17, 2024
64 of 89 checks passed
@emmettbutler emmettbutler deleted the backport-9233-to-1.20 branch May 17, 2024 18:02
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.

grpc integration causes exception with grpc.aio streaming
3 participants