<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.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>Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx</link><description>If you're reading this, please take one minute out of your day and vote for the following Connect item : https://connect.microsoft.com/SQLServer/feedback/details/444030/sys-dm-tran-active-transactions-transaction-state-not-updated-when-an-attention-event-occurs</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#44109</link><pubDate>Wed, 27 Jun 2012 10:08:25 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44109</guid><dc:creator>RichB</dc:creator><description>&lt;p&gt;Just curious - the explanation they gave to my untutored eye appears to contradict the whole concept of ACID. If it doesn't roll back the whole transaction, what does it do - retry? &amp;nbsp;In a nested transaction the whole lot gets rolled back (barring save points), so their analogy seems to be highly misleading. &amp;nbsp;Tbh I'm rather confused now, and would rather have not read it... ;)&lt;/p&gt;
&lt;p&gt;&amp;quot;Each time a statement is run, it starts a virtual scope within the transaction (akin to a nested transaction), which is used to log the changes made by that stement. If an error occurs (such as the attention event), depending on the severity of the exception either the scope will be rolled back or the whole transaction.&lt;/p&gt;
&lt;p&gt;The rollback is limited to the scope for low-severity exceptions or if XACT_ABORT is OFF. For high-severity exceptions, the whole transaction will be rolled back.&lt;/p&gt;
&lt;p&gt;Because of the above, during the time the scope is rolled back, the transaction itself is not necessarily being rolling back, so that's the reason the state remains as ACTIVE (2) in the DMV.&amp;quot;&lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#44117</link><pubDate>Wed, 27 Jun 2012 15:37:59 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44117</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Hi Rich,&lt;/p&gt;
&lt;p&gt;SQL Server internally uses parent and child transaction scopes. These are all bound to the same transaction via the parent, so there is no consequence as far as ACID goes -- it's more for flexibility and granularity. &lt;/p&gt;
&lt;p&gt;For example, if you have a bunch of threads and one of them needs to spill some data to tempdb, it will do so in a child transaction. That data doesn't need to be replayed or rolled back if the parent transaction is interrupted, so there is no worry there. &lt;/p&gt;
&lt;p&gt;Another scenario is with the query I posted in the item. In this case the parent transaction can support numerous child transactions over the course of its lifetime (the big insert being one of them), and if one of them dies all of the work that's already been done can still be committed. That's a feature!&lt;/p&gt;
&lt;p&gt;As far as the DMVs go, unfortunately, it's difficult at best to tie child transactions to parent transactions. You can do it, but only via the sys.dm_tran_locks view, which tends to be very slow and is not reliable. Even worse, the rows in the transaction views for child transactions don't seem to indicate the rollback either. There is a column called &amp;quot;status2&amp;quot; that seems to have something to do with it, but it's totally undocumented and I don't know what to look for. Of course since I can't reliably tie the parent to the child it's a moot point. I simply can't get the right data to figure out what's happening.&lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#44129</link><pubDate>Thu, 28 Jun 2012 10:06:31 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44129</guid><dc:creator>RichB</dc:creator><description>&lt;p&gt;Thanks for the extra info.&lt;/p&gt;
&lt;p&gt;R&lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#44626</link><pubDate>Wed, 08 Aug 2012 17:26:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44626</guid><dc:creator>Rajib Bahar</dc:creator><description>&lt;p&gt;It looks like they won't solve this issue for another 2-4 years assuming their next major release isn't referring to service packs. &lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#44998</link><pubDate>Tue, 04 Sep 2012 17:34:12 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:44998</guid><dc:creator>Mr Tea</dc:creator><description>&lt;p&gt;Can you watch your SPID to see if it is throwing IO_COMPLETION waits ? You can normally see this wait being recorded fairly heavily during crash recovery / transaction rollback.&lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#45006</link><pubDate>Tue, 04 Sep 2012 21:39:53 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:45006</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Mr. Tea: Sure, you can do that, but it may not tell you much. IO_COMPLETION is used for other purposes, so there may not be a rollback happening at all, and even if you are in the midst of a rollback there's no guarantee you'll see it unless your disks happen to be somewhat overloaded. It is unfortunately not a very accurate way of telling what's going on.&lt;/p&gt;
</description></item><item><title>re: Your Transaction is in Jeopardy -- and You Can't Even Know It!</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2012/06/26/your-transaction-is-in-jeorpardy-and-you-can-t-even-know-it.aspx#45022</link><pubDate>Wed, 05 Sep 2012 09:11:04 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:45022</guid><dc:creator>Mr Tea</dc:creator><description>&lt;p&gt;I Agree, IO_COMPLETION is not well documented (I'd love to know the exhaustive list of what causes it) but it may be the best indication we have until someone takes the above request seriously!&lt;/p&gt;
&lt;p&gt;After a few quick tests with extended events to monitor the pattern of waitstats on a SPID, during rollback it shifts from what I expect e.g. PAGEIO/LOCK based on the type of transaction to a bunch of IO_COMPLETION, Ill have to test this on a large transaction that causes churn in the buffer pool to see what kind of wait pattern that gives during rollback.&lt;/p&gt;
&lt;p&gt;From observation, IO_COMPLETION in this case looks like its the log file disk waits when reading the Tlog for rollback/forward.&lt;/p&gt;
</description></item></channel></rss>