You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From what I can tell, the issue is that the call to get_parameters() tries to access pgconn.info, but that will throw an operational error if the connection is already closed.
A suggested fix would be something like
if is_psycopg3:
connection_params = {}
if not cursor_or_db.connection.closed
connection_params = cursor_or_db.connection.info.get_parameters()
Expected Result
The expected result is for the sentry-sdk to not try and access a bad connection in _set_db_data
Actual Result
The actual result is that the call to get_parameters() results in a psycopg.OperationalError:
Traceback (most recent call last):
File "/Users/austin/workplace/sentry-psycopg-bug/spbug/tests.py", line 11, in test_bug
connection.connect()
File "/Users/austin/workplace/sentry-psycopg-bug/venv_3_10/lib/python3.10/site-packages/sentry_sdk/utils.py", line 1711, in runner
return sentry_patched_function(*args, **kwargs)
File "/Users/austin/workplace/sentry-psycopg-bug/venv_3_10/lib/python3.10/site-packages/sentry_sdk/integrations/django/__init__.py", line 658, in connect
_set_db_data(span, self)
File "/Users/austin/workplace/sentry-psycopg-bug/venv_3_10/lib/python3.10/site-packages/sentry_sdk/integrations/django/__init__.py", line 693, in _set_db_data
connection_params = cursor_or_db.connection.info.get_parameters()
File "/Users/austin/workplace/sentry-psycopg-bug/venv_3_10/lib/python3.10/site-packages/psycopg/_connection_info.py", line 91, in get_parameters
for i in self.pgconn.info
File "psycopg_binary/pq/pgconn.pyx", line 90, in psycopg_binary.pq.PGconn.info.__get__
File "psycopg_binary/pq/pgconn.pyx", line 635, in psycopg_binary.pq._ensure_pgconn
psycopg.OperationalError: the connection is closed
The text was updated successfully, but these errors were encountered:
@austin-wentz Thank you for reporting this problem, and thanks for the detailed reproduction! I can confirm that I have also observed the same error, so we will try to get a fix ready soon.
Has what you are trying to do ever worked in a previous SDK version, and if so, which version? Also, have you been able to work around the issue?
@austin-wentz Thank you for reporting this problem, and thanks for the detailed reproduction! I can confirm that I have also observed the same error, so we will try to get a fix ready soon.
Has what you are trying to do ever worked in a previous SDK version, and if so, which version? Also, have you been able to work around the issue?
Sorry for the delay in response. We tried previous SDK versions, but the issue was still present. Yes, we were able to work around the issue by creating a new connection rather than trying to [re]connect the existing connection object.
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.1.1
Steps to Reproduce
I created a sample repo that reproduces the bug.
From what I can tell, the issue is that the call to get_parameters() tries to access pgconn.info, but that will throw an operational error if the connection is already closed.
A suggested fix would be something like
Expected Result
The expected result is for the sentry-sdk to not try and access a bad connection in _set_db_data
Actual Result
The actual result is that the call to get_parameters() results in a psycopg.OperationalError:
The text was updated successfully, but these errors were encountered: