<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>After the timeout</title><link>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2013/01/09/after-the-timeout.aspx</link><description>After the timeout, we may sometimes, but not always, end up with an outstanding transaction. If this is the case, we need to rollback the transaction ourselves. Otherwise the consequent commands which use the same connection might not work as expected.</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: After the timeout</title><link>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2013/01/09/after-the-timeout.aspx#47089</link><pubDate>Wed, 09 Jan 2013 20:47:24 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47089</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Hi Alex,&lt;/p&gt;
&lt;p&gt;I don't think that your conclusion logically follows... here's a slightly reformatted version:&lt;/p&gt;
&lt;p&gt;&amp;quot;If we return the connection to the pool and if it is reused, the transaction will be rolled back.&amp;quot;&lt;/p&gt;
&lt;p&gt;Rephrase the second &amp;quot;if&amp;quot; as a &amp;quot;when&amp;quot; and now you have a problem -- because you can't tell me, with any certainty, when that connection will be reused and the transaction rolled back. Which means that you can have a transaction sitting there holding some resource locks for a long time. Maybe even blocking someone else, whose command didn't time out (yet). &lt;/p&gt;
&lt;p&gt;So my conclusion would be different than yours. It would be: &amp;quot;You should always roll back any active transaction after a timeout.&amp;quot;&lt;/p&gt;
&lt;p&gt;--Adam&lt;/p&gt;
</description></item><item><title>re: After the timeout</title><link>http://sqlblog.com/blogs/alexander_kuznetsov/archive/2013/01/09/after-the-timeout.aspx#47091</link><pubDate>Wed, 09 Jan 2013 21:04:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:47091</guid><dc:creator>Alexander Kuznetsov</dc:creator><description>&lt;p&gt;Hi Adam,&lt;/p&gt;
&lt;p&gt;I agree, and I have already implemented two extension methods that roll back active transactions, as well as edited my post.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description></item></channel></rss>