Skip to content

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

Open
@zawi99

Description

@zawi99

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions