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

Database query exceptions trigger double execution in [email protected] #109

Open
zawi99 opened this issue Nov 20, 2024 · 1 comment · May be fixed by #110
Open

Database query exceptions trigger double execution in [email protected] #109

zawi99 opened this issue Nov 20, 2024 · 1 comment · May be fixed by #110
Labels
bug Something isn't working

Comments

@zawi99
Copy link

zawi99 commented Nov 20, 2024

Describe the Bug
After upgrading to [email protected] from 1.1.1, database queries executed within a transaction block now fail with the following error:
django.db.utils.InternalError: current transaction is aborted, commands ignored until end of transaction block

It appears the query is being executed twice, and the original exception is not correctly propagated to the application. This behavior may not be limited to transactional queries but could affect all queries where exceptions (e.g., from Django or psycopg) are raised. Double execution in these cases may lead to significant side effects, such as unintended data changes or corrupted transactions.

The issue seems to stem from changes introduced in this commit, where exceptions are wrapped and handled differently.

To Reproduce
Steps to reproduce the behavior:

  1. Execute a database query within a transaction block.
  2. Observe the error that occurs during the execution.

Expected behavior
Exceptions raised during query execution should propagate correctly, without re-executing the query or affecting the transaction state. The behavior should remain consistent with [email protected] as no breaking change announcement/changelog has been found.

Desktop (please complete the following information):

  • Python: 3.12
  • autodynatrace: 2.1.0
  • Django 4.2.16
  • psycopg2-binary: 2.9.10
@zawi99 zawi99 added the bug Something isn't working label Nov 20, 2024
zawi99 added a commit to zawi99/OneAgent-SDK-Python-AutoInstrumentation that referenced this issue Nov 20, 2024
@zawi99
Copy link
Author

zawi99 commented Nov 20, 2024

I have opened a PR to address this issue by separating the handling of SDK function exceptions from wrapped function exceptions. The fix ensures proper propagation while maintaining the intended instrumentation behavior.
Alternatively, the issue could be resolved by raising the original exception and not calling the wrapped function twice. However, I don't know the author's intentions and the background of the changes. Feedback on either approach is appreciated.

@zawi99 zawi99 linked a pull request Nov 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant