Skip to content

Connection keeps open transaction (open_transaction_count) after connection.commit - works as intended? #754

Description

@qamfmladitsch

Hello,

when using mssql-python we observed that it does not seem to close/commit all transactions.
For example with this script:

with mssql_python.connect(conn_string) as conn:
  with conn.cursor() as cursor:
    cursor.execute("SELECT * FROM People")

print("wait here with debugger")

Before the application exits we see open transactions with this:

SELECT 
  s.session_id,
  s.login_time,
  s.host_name,
  s.program_name,
  s.login_name,
  s.last_request_end_time,
  c.most_recent_sql_handle,
  s.open_transaction_count,
  r.*
FROM sys.dm_exec_sessions s
LEFT JOIN sys.dm_exec_requests r
  ON r.session_id = s.session_id
LEFT JOIN sys.dm_exec_connections c
  ON c.session_id = s.session_id
WHERE s.open_transaction_count > 0

Is this intended behavior? The opened transaction does not seem to block any resources.

When doing a manual commit cursor.execute("IF @@TRANCOUNT > 0 COMMIT TRANSACTION") the transactions are closed properly before the application exits.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area: performanceThroughput, latency, GIL retention, large-param slowness, expensive round-trips, perf-regressionsbugSomething isn't workinginADOregressionTracks issues which are regressionstriage doneIssues that are triaged by dev team and are in investigation.under development

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions