Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It can stay open while connection pooling applies. Example: command timeout can leave locks and TXN because the client sends as "abort".</p> <p>2 solutions:</p> <ul> <li><p>Test in the client, literally:</p> <p><code>IF @@TRANCOUNT &lt;&gt; 0 ROLLBACK TRAN</code></p></li> <li><p>Use <code>SET XACT_ABORT ON</code> to ensured a TXN is cleaned up: <a href="https://stackoverflow.com/questions/1150032/what-is-the-benefit-of-using-set-xactabort-on-in-a-stored-procedure">Question 1</a> and <a href="https://stackoverflow.com/questions/917773/do-i-really-need-to-use-set-xactabort-on">Question 2</a></p></li> </ul> <p>I always use <code>SET XACT_ABORT ON</code>.</p> <p>From <a href="http://weblogs.sqlteam.com/dang/archive/2007/10/20.aspx" rel="nofollow noreferrer">this SQL Team blog</a>:</p> <blockquote> <p>Note that with connection pooling, simply closing the connection without a rollback will only return the connection to the pool and the transaction will remain open until later reused or removed from the pool. This can result in locks begin held unnecessary and cause other timeouts and rolling block</p> </blockquote> <p>From <a href="http://msdn.microsoft.com/en-us/library/8xx3tyca(VS.80).aspx" rel="nofollow noreferrer">MSDN</a>, section "Transaction Support" (my bold)</p> <blockquote> <p>When a connection is closed, it is released back into the pool and into the appropriate subdivision based on its transaction context. Therefore, you can close the connection without generating an error, <strong>even though a distributed transaction is still pending. This allows you to commit or abort the distributed transaction at a later time.</strong></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload