microsoft / microsoft/mssql-python

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

クローズ
#754 コメント 4 件 リアクション 1 件 担当者 1 名 GitHub で見る

@sumitmsft がすでに取り組んでいます。

2026年9月9日 から。

area: performance bug inADO regression triage done under development
主要言語
Python
スター
473
フォーク
60
平均マージ
2日 11時間
マージ済み PR(30日)
36

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。