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

Guard against sentry initialization mid sqlalchemy cursor #2702

Merged
merged 1 commit into from Feb 5, 2024

Conversation

apmorton
Copy link
Contributor

@apmorton apmorton commented Feb 2, 2024

In an application that is executing sqlalchemy cursors on a thread concurrently with another thread calling sentry_sdk.init it is possible for _after_cursor_execute to be called on a cursor that never had _before_cursor_execute called.

  File "site-packages/sentry_sdk/integrations/sqlalchemy.py", line 98, in _after_cursor_execute
    span = context._sentry_sql_span
           ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'PGExecutionContext_psycopg2' object has no attribute '_sentry_sql_span'

@sentrivana sentrivana added the Trigger: tests using secrets PR code is safe; run CI label Feb 5, 2024
Copy link
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

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

LGTM, thank you @apmorton!

@sentrivana sentrivana enabled auto-merge (squash) February 5, 2024 14:51
@sentrivana sentrivana merged commit 4afb955 into getsentry:master Feb 5, 2024
124 of 126 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Trigger: tests using secrets PR code is safe; run CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants