<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Potential Dangers of the Read Committed Snapshot Isolation Level</title>
	<atom:link href="http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/</link>
	<description>Musings about SQL, databases, and my world in general...</description>
	<lastBuildDate>Tue, 20 Dec 2011 15:37:13 +1000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Umasankar</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-28500</link>
		<dc:creator>Umasankar</dc:creator>
		<pubDate>Wed, 24 Aug 2011 10:34:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-28500</guid>
		<description>Good example to demonstrate the negetive effect of Read commmited snapshot. subsequent Comment that suggested to place Updlock,rowlock is also good way around.Thank you.</description>
		<content:encoded><![CDATA[<p>Good example to demonstrate the negetive effect of Read commmited snapshot. subsequent Comment that suggested to place Updlock,rowlock is also good way around.Thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-25988</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Wed, 25 May 2011 00:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-25988</guid>
		<description>This post is very interesting and quite intriging, but I got truly lost.

How a good quality code performing the above shoold look like?

How to do excactly what the code is doing in snapshot isolation and without it?</description>
		<content:encoded><![CDATA[<p>This post is very interesting and quite intriging, but I got truly lost.</p>
<p>How a good quality code performing the above shoold look like?</p>
<p>How to do excactly what the code is doing in snapshot isolation and without it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chef Zoff</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-18390</link>
		<dc:creator>Chef Zoff</dc:creator>
		<pubDate>Tue, 09 Mar 2010 16:20:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-18390</guid>
		<description>I must say that the example is not the best, but also I have to recognize that it is a true real life example of how bad people write queries. Obviously that we can write better, more consistent and efficient code ways, but the ugly true is that you will find always code like the example, how many developers knows the SQL hints? I think that the example provides maybe one of the most common and lame scenario that we can fine.</description>
		<content:encoded><![CDATA[<p>I must say that the example is not the best, but also I have to recognize that it is a true real life example of how bad people write queries. Obviously that we can write better, more consistent and efficient code ways, but the ugly true is that you will find always code like the example, how many developers knows the SQL hints? I think that the example provides maybe one of the most common and lame scenario that we can fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lions and Tigers and Deadlocks OMY! - rosslotharius.com</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-18381</link>
		<dc:creator>Lions and Tigers and Deadlocks OMY! - rosslotharius.com</dc:creator>
		<pubDate>Mon, 08 Mar 2010 16:30:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-18381</guid>
		<description>[...] There are known concerns with Read Committed Snapshot that mainly exist in older applications that were developed without this isolation level in mind.&#160; For a more detailed description, I recommend checking out this blog post here.&#160; [...]</description>
		<content:encoded><![CDATA[<p>[...] There are known concerns with Read Committed Snapshot that mainly exist in older applications that were developed without this isolation level in mind.&#160; For a more detailed description, I recommend checking out this blog post here.&#160; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13924</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Fri, 28 Aug 2009 01:01:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13924</guid>
		<description>I agree with all comments so far.

I&#039;m definitely not making excuses for this code - it&#039;s terrible, but under a pessimistic concurrency model it works &quot;well enough&quot;.  And if it works &quot;well enough&quot;, then there&#039;s a possibility that someone working for your application vendor has written code like this without a thought as to concurrency models.  In my horrible code sample, this &quot;well enough&quot; has gone from &quot;good enough to work, but still a small chance of problems&quot; to &quot;guaranteed to break much more often&quot; due to the longer available window the row is committed under RCS.

The point of the post comes down to this: if you&#039;re reading data from a table, and something happens to be modifying the data, and the original developer expects the code to wait until the lock occurs, then you&#039;ll be in trouble if you turn on READ COMMITTED SNAPSHOT to try to reduce blocking.  

The idea of the post originally came from a forum post where a guy performed an BEGIN TRAN...UPDATE and didn&#039;t commit or rollback, and wanted to know if there was a way to not block other users (well, apart from committing).

noeldr, regarding your point #1, the SUM() was from an evolution of the code and can be removed.  It took me a while to write code this bad! :)</description>
		<content:encoded><![CDATA[<p>I agree with all comments so far.</p>
<p>I&#8217;m definitely not making excuses for this code &#8211; it&#8217;s terrible, but under a pessimistic concurrency model it works &#8220;well enough&#8221;.  And if it works &#8220;well enough&#8221;, then there&#8217;s a possibility that someone working for your application vendor has written code like this without a thought as to concurrency models.  In my horrible code sample, this &#8220;well enough&#8221; has gone from &#8220;good enough to work, but still a small chance of problems&#8221; to &#8220;guaranteed to break much more often&#8221; due to the longer available window the row is committed under RCS.</p>
<p>The point of the post comes down to this: if you&#8217;re reading data from a table, and something happens to be modifying the data, and the original developer expects the code to wait until the lock occurs, then you&#8217;ll be in trouble if you turn on READ COMMITTED SNAPSHOT to try to reduce blocking.  </p>
<p>The idea of the post originally came from a forum post where a guy performed an BEGIN TRAN&#8230;UPDATE and didn&#8217;t commit or rollback, and wanted to know if there was a way to not block other users (well, apart from committing).</p>
<p>noeldr, regarding your point #1, the SUM() was from an evolution of the code and can be removed.  It took me a while to write code this bad! <img src='http://www.jimmcleod.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Niels Berglund</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13923</link>
		<dc:creator>Niels Berglund</dc:creator>
		<pubDate>Thu, 27 Aug 2009 23:49:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13923</guid>
		<description>I must agree with AK here; the way your code is written you are vulnerable in either case. The only reason you are not seeing as frequent in your READ COMMITTED scenario is due to where you have the waitfor delay statement. Move the waitfor delay, up to after you are selecting the quantity - and you will see the same behavior with &quot;normal&quot; RC.

If this is a scenario you are concerned about, then you should use an update locking hint in your select (but you know that already :) ). 

Niels</description>
		<content:encoded><![CDATA[<p>I must agree with AK here; the way your code is written you are vulnerable in either case. The only reason you are not seeing as frequent in your READ COMMITTED scenario is due to where you have the waitfor delay statement. Move the waitfor delay, up to after you are selecting the quantity &#8211; and you will see the same behavior with &#8220;normal&#8221; RC.</p>
<p>If this is a scenario you are concerned about, then you should use an update locking hint in your select (but you know that already <img src='http://www.jimmcleod.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). </p>
<p>Niels</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SqlServerKudos</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13920</link>
		<dc:creator>SqlServerKudos</dc:creator>
		<pubDate>Thu, 27 Aug 2009 22:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13920</guid>
		<description>&lt;strong&gt;The Potential Dangers of the Read Committed Snapshot Isolation Level...&lt;/strong&gt;

Kudos for a great Sql Server article - Trackback from SqlServerKudos...</description>
		<content:encoded><![CDATA[<p><strong>The Potential Dangers of the Read Committed Snapshot Isolation Level&#8230;</strong></p>
<p>Kudos for a great Sql Server article &#8211; Trackback from SqlServerKudos&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: noeldr</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13911</link>
		<dc:creator>noeldr</dc:creator>
		<pubDate>Thu, 27 Aug 2009 17:17:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13911</guid>
		<description>This could not have been a worse sample to blame it to the isolation level.
There are many things wrong with your code.
1. LocationId + ItemID  was defined as the PK of the table so there can only be ONE Qty for the pair, then why SUM() ?
2. You are suposed to use (QUERY HINT) locks if you are running this in separated statements even with read commited isolation. A simple with (UPDLOCK,ROWLOCK) will suffice on the select query to make the code work under any isolation level.
3. IF you turn the Update as an update + Read operation it will go all smoothly into a single statement which will maintain all ACID properties and no hint is needed at all.</description>
		<content:encoded><![CDATA[<p>This could not have been a worse sample to blame it to the isolation level.<br />
There are many things wrong with your code.<br />
1. LocationId + ItemID  was defined as the PK of the table so there can only be ONE Qty for the pair, then why SUM() ?<br />
2. You are suposed to use (QUERY HINT) locks if you are running this in separated statements even with read commited isolation. A simple with (UPDLOCK,ROWLOCK) will suffice on the select query to make the code work under any isolation level.<br />
3. IF you turn the Update as an update + Read operation it will go all smoothly into a single statement which will maintain all ACID properties and no hint is needed at all.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13901</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Thu, 27 Aug 2009 00:41:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13901</guid>
		<description>Hi AK,

Thanks for your comment!

In the example, READ COMMITTED (RC) is safer than READ COMMITTED SNAPSHOT (RCS) as the RC UPDATE will lock the row, and the second session will be blocked until the update has finished.  Whereas with RCS, they both read the same data without locks, and as the transaction takes a number of seconds to process, there&#039;s a higher chance that the two will be in conflict.

RC is vulnerable as well, but the chance of it occurring is a lot smaller, as the window is only between the time the of the the SELECT Qty and the UPDATE Qty.  Whereas RCS allows the problem to creep in any time during the 10 second transaction.

As I said, it wasn&#039;t perfect code - but it&#039;s code of a quality that I have seen before.  The problem isn&#039;t so much the code, as the effect of changing the entire database&#039;s READ COMMITTED behavior from a pessimistic concurrency model to an optimistic concurrency model.  It can change the entire behavior of the application.</description>
		<content:encoded><![CDATA[<p>Hi AK,</p>
<p>Thanks for your comment!</p>
<p>In the example, READ COMMITTED (RC) is safer than READ COMMITTED SNAPSHOT (RCS) as the RC UPDATE will lock the row, and the second session will be blocked until the update has finished.  Whereas with RCS, they both read the same data without locks, and as the transaction takes a number of seconds to process, there&#8217;s a higher chance that the two will be in conflict.</p>
<p>RC is vulnerable as well, but the chance of it occurring is a lot smaller, as the window is only between the time the of the the SELECT Qty and the UPDATE Qty.  Whereas RCS allows the problem to creep in any time during the 10 second transaction.</p>
<p>As I said, it wasn&#8217;t perfect code &#8211; but it&#8217;s code of a quality that I have seen before.  The problem isn&#8217;t so much the code, as the effect of changing the entire database&#8217;s READ COMMITTED behavior from a pessimistic concurrency model to an optimistic concurrency model.  It can change the entire behavior of the application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AK</title>
		<link>http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/comment-page-1/#comment-13897</link>
		<dc:creator>AK</dc:creator>
		<pubDate>Wed, 26 Aug 2009 22:05:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.jimmcleod.net/blog/index.php/2009/08/27/the-potential-dangers-of-the-read-committed-snapshot-isolation-level/#comment-13897</guid>
		<description>I cannot agree with your conclusion. SNAPSHOT will give you a correct point in time picture. READ COMMITTED is just as vulnerable to the problem you are demonstrating as READ COMMITTED SNAPSHOT is.

Examples:

http://www.simple-talk.com/sql/t-sql-programming/the-case-of-the-skewed-totals/

http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/04/10/selects-under-read-committed-and-repeatable-read-may-return-incorrect-results.aspx</description>
		<content:encoded><![CDATA[<p>I cannot agree with your conclusion. SNAPSHOT will give you a correct point in time picture. READ COMMITTED is just as vulnerable to the problem you are demonstrating as READ COMMITTED SNAPSHOT is.</p>
<p>Examples:</p>
<p><a href="http://www.simple-talk.com/sql/t-sql-programming/the-case-of-the-skewed-totals/" rel="nofollow">http://www.simple-talk.com/sql/t-sql-programming/the-case-of-the-skewed-totals/</a></p>
<p><a href="http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/04/10/selects-under-read-committed-and-repeatable-read-may-return-incorrect-results.aspx" rel="nofollow">http://sqlblog.com/blogs/alexander_kuznetsov/archive/2009/04/10/selects-under-read-committed-and-repeatable-read-may-return-incorrect-results.aspx</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>

